當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。