• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang logical.ListResponse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/hashicorp/vault/logical.ListResponse函数的典型用法代码示例。如果您正苦于以下问题:Golang ListResponse函数的具体用法?Golang ListResponse怎么用?Golang ListResponse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ListResponse函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: handleList

func (b *CubbyholeBackend) handleList(
	req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
	if req.ClientToken == "" {
		return nil, fmt.Errorf("[ERR] cubbyhole list: Client token empty")
	}

	// Right now we only handle directories, so ensure it ends with /; however,
	// some physical backends may not handle the "/" case properly, so only add
	// it if we're not listing the root
	path := req.Path
	if path != "" && !strings.HasSuffix(path, "/") {
		path = path + "/"
	}

	// List the keys at the prefix given by the request
	keys, err := req.Storage.List(req.ClientToken + "/" + path)
	if err != nil {
		return nil, err
	}

	// Strip the token
	strippedKeys := make([]string, len(keys))
	for i, key := range keys {
		strippedKeys[i] = strings.TrimPrefix(key, req.ClientToken+"/")
	}

	// Generate the response
	return logical.ListResponse(strippedKeys), nil
}
开发者ID:thomaso-mirodin,项目名称:vault,代码行数:29,代码来源:logical_cubbyhole.go


示例2: pathList

func (p *PathMap) pathList(req *logical.Request, d *FieldData) (*logical.Response, error) {
	rootPath := fmt.Sprintf("struct/%s/", req.Path)
	keys, err := req.Storage.List(rootPath)
	if err != nil {
		return nil, err
	}

	var out []string
	for _, key := range keys {
		val, err := p.pathStruct(key, false).Get(req.Storage)

		if err != nil {
			return nil, err
		}

		app, ok := val["key"].(string)
		if !ok {
			return nil, fmt.Errorf("Could not decode app")
		}

		out = append(out, app)
	}

	return logical.ListResponse(out), nil
}
开发者ID:chris-west-travelex,项目名称:vault,代码行数:25,代码来源:path_map.go


示例3: pathRoleList

func (b *backend) pathRoleList(req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
	entries, err := req.Storage.List("roles/")
	if err != nil {
		return nil, err
	}

	return logical.ListResponse(entries), nil
}
开发者ID:citywander,项目名称:vault,代码行数:8,代码来源:path_roles.go


示例4: pathGroupList

func (b *backend) pathGroupList(
	req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
	groups, err := req.Storage.List("group/")
	if err != nil {
		return nil, err
	}
	return logical.ListResponse(groups), nil
}
开发者ID:citywander,项目名称:vault,代码行数:8,代码来源:path_groups.go


示例5: pathFetchCertList

func (b *backend) pathFetchCertList(req *logical.Request, data *framework.FieldData) (response *logical.Response, retErr error) {
	entries, err := req.Storage.List("certs/")
	if err != nil {
		return nil, err
	}

	return logical.ListResponse(entries), nil
}
开发者ID:mhurne,项目名称:vault,代码行数:8,代码来源:path_fetch.go


示例6: pathUserList

func (b *backend) pathUserList(
	req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
	users, err := req.Storage.List("user/")
	if err != nil {
		return nil, err
	}
	return logical.ListResponse(users), nil
}
开发者ID:GauntletWizard,项目名称:vault,代码行数:8,代码来源:path_users.go


示例7: pathCertList

func (b *backend) pathCertList(
	req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
	certs, err := req.Storage.List("cert/")
	if err != nil {
		return nil, err
	}
	return logical.ListResponse(certs), nil
}
开发者ID:GauntletWizard,项目名称:vault,代码行数:8,代码来源:path_certs.go


示例8: pathWhitelistIdentitiesList

// pathWhitelistIdentitiesList is used to list all the instance IDs that are present
// in the identity whitelist. This will list both valid and expired entries.
func (b *backend) pathWhitelistIdentitiesList(
	req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
	identities, err := req.Storage.List("whitelist/identity/")
	if err != nil {
		return nil, err
	}
	return logical.ListResponse(identities), nil
}
开发者ID:quixoten,项目名称:vault,代码行数:10,代码来源:path_identity_whitelist.go


示例9: pathList

func (p *PathMap) pathList(
	req *logical.Request, d *FieldData) (*logical.Response, error) {
	keys, err := req.Storage.List(req.Path)
	if err != nil {
		return nil, err
	}

	return logical.ListResponse(keys), nil
}
开发者ID:vincentaubert,项目名称:vault,代码行数:9,代码来源:path_map.go


示例10: handlePolicyList

// handlePolicyList handles the "policy" endpoint to provide the enabled policies
func (b *SystemBackend) handlePolicyList(
	req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
	// Get all the configured policies
	policies, err := b.Core.policy.ListPolicies()

	// Add the special "root" policy
	policies = append(policies, "root")
	return logical.ListResponse(policies), err
}
开发者ID:kgutwin,项目名称:vault,代码行数:10,代码来源:logical_system.go


示例11: pathRoleList

// pathRoleList is used to list all the AMI IDs registered with Vault.
func (b *backend) pathRoleList(
	req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
	b.roleMutex.RLock()
	defer b.roleMutex.RUnlock()

	roles, err := req.Storage.List("role/")
	if err != nil {
		return nil, err
	}
	return logical.ListResponse(roles), nil
}
开发者ID:chrishoffman,项目名称:vault,代码行数:12,代码来源:path_role.go


示例12: pathCertificatesList

// pathCertificatesList is used to list all the AWS public certificates registered with Vault.
func (b *backend) pathCertificatesList(
	req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
	b.configMutex.RLock()
	defer b.configMutex.RUnlock()

	certs, err := req.Storage.List("config/certificate/")
	if err != nil {
		return nil, err
	}
	return logical.ListResponse(certs), nil
}
开发者ID:GauntletWizard,项目名称:vault,代码行数:12,代码来源:path_config_certificate.go


示例13: handleList

func (b *PassthroughBackend) handleList(
	req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
	// List the keys at the prefix given by the request
	keys, err := req.Storage.List(req.Path)
	if err != nil {
		return nil, err
	}

	// Generate the response
	return logical.ListResponse(keys), nil
}
开发者ID:n1tr0g,项目名称:vault,代码行数:11,代码来源:logical_passthrough.go


示例14: tokenStoreRoleList

func (ts *TokenStore) tokenStoreRoleList(
	req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
	entries, err := ts.view.List(rolesPrefix)
	if err != nil {
		return nil, err
	}

	ret := make([]string, len(entries))
	for i, entry := range entries {
		ret[i] = strings.TrimPrefix(entry, rolesPrefix)
	}

	return logical.ListResponse(ret), nil
}
开发者ID:geckoboard,项目名称:vault,代码行数:14,代码来源:token_store.go


示例15: handlePolicyList

// handlePolicyList handles the "policy" endpoint to provide the enabled policies
func (b *SystemBackend) handlePolicyList(
	req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
	// Get all the configured policies
	policies, err := b.Core.policyStore.ListPolicies()

	// Add the special "root" policy
	policies = append(policies, "root")
	resp := logical.ListResponse(policies)

	// Backwords compatibility
	resp.Data["policies"] = resp.Data["keys"]

	return resp, err
}
开发者ID:jantman,项目名称:vault,代码行数:15,代码来源:logical_system.go


示例16: handleList

func (b *PassthroughBackend) handleList(
	req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
	// Right now we only handle directories, so ensure it ends with /; however,
	// some physical backends may not handle the "/" case properly, so only add
	// it if we're not listing the root
	path := req.Path
	if path != "" && !strings.HasSuffix(path, "/") {
		path = path + "/"
	}

	// List the keys at the prefix given by the request
	keys, err := req.Storage.List(path)
	if err != nil {
		return nil, err
	}

	// Generate the response
	return logical.ListResponse(keys), nil
}
开发者ID:faradayio,项目名称:vault-1,代码行数:19,代码来源:logical_passthrough.go


示例17: handleList

func (b *CubbyholeBackend) handleList(
	req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
	if req.ClientToken == "" {
		return nil, fmt.Errorf("[ERR] cubbyhole list: Client token empty")
	}
	// List the keys at the prefix given by the request
	keys, err := req.Storage.List(req.ClientToken + "/" + req.Path)
	if err != nil {
		return nil, err
	}

	strippedKeys := []string{}
	for _, key := range keys {
		strippedKeys = append(strippedKeys, strings.TrimPrefix(key, req.ClientToken+"/"))
	}

	// Generate the response
	return logical.ListResponse(strippedKeys), nil
}
开发者ID:samjaninf,项目名称:vault,代码行数:19,代码来源:logical_cubbyhole.go


示例18: pathRoletagBlacklistsList

// Lists all the blacklisted role tags.
func (b *backend) pathRoletagBlacklistsList(
	req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
	b.blacklistMutex.RLock()
	defer b.blacklistMutex.RUnlock()

	tags, err := req.Storage.List("blacklist/roletag/")
	if err != nil {
		return nil, err
	}

	// Tags are base64 encoded before indexing to avoid problems
	// with the path separators being present in the tag.
	// Reverse it before returning the list response.
	for i, keyB64 := range tags {
		if key, err := base64.StdEncoding.DecodeString(keyB64); err != nil {
			return nil, err
		} else {
			// Overwrite the result with the decoded string.
			tags[i] = string(key)
		}
	}
	return logical.ListResponse(tags), nil
}
开发者ID:quixoten,项目名称:vault,代码行数:24,代码来源:path_roletag_blacklist.go



注:本文中的github.com/hashicorp/vault/logical.ListResponse函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang logical.RenewAuthRequest函数代码示例发布时间:2022-05-28
下一篇:
Golang logical.ErrorResponse函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap