当前位置: 首页>>代码示例>>Golang>>正文


Golang logical.ListResponse函数代码示例

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


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


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