keyvault

package
v0.0.0-...-d9f4117 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateKey

func CreateKey(ctx context.Context, vaultName, keyName string) (key keyvault.KeyBundle, err error)

CreateKeyBundle creates a key in the specified keyvault

func CreateVault

func CreateVault(ctx context.Context, vaultName string) (keyvault.Vault, error)

CreateVault creates a new vault

func CreateVaultWithPolicies

func CreateVaultWithPolicies(ctx context.Context, vaultName, userID string) (vault keyvault.Vault, err error)

CreateVaultWithPolicies creates a new Vault with policies granting access to the specified user.

func DeleteVault

func DeleteVault(ctx context.Context, vaultName string) (autorest.Response, error)

DeleteVault deletes an existing vault

func GetVault

func GetVault(ctx context.Context, vaultName string) (keyvault.Vault, error)

GetVault returns an existing vault

func GetVaults

func GetVaults()

GetVaults lists all key vaults in a subscription

func PassManager

func PassManager()

func SetVaultPermissions

func SetVaultPermissions(ctx context.Context, vaultName string) (keyvault.Vault, error)

SetVaultPermissions adds an access policy permitting this app's Client ID to manage keys and secrets.

Example
package main

import (
	"context"

	"github.com/marstr/randname"

	"github.com/Azure-Samples/azure-sdk-for-go-samples/services/internal/config"
	"github.com/Azure-Samples/azure-sdk-for-go-samples/services/internal/util"
	"github.com/Azure-Samples/azure-sdk-for-go-samples/services/resources"
)

var (
	kvName  = randname.GenerateWithPrefix("vault-sample-go-", 5)
	keyName = randname.GenerateWithPrefix("key-sample-go-", 5)
)

func main() {
	var groupName = config.GenerateGroupName("KeyVault")
	config.SetGroupName(groupName)

	ctx := context.Background()
	defer resources.Cleanup(ctx)

	_, err := resources.CreateGroup(ctx, config.GroupName())
	if err != nil {
		util.LogAndPanic(err)
	}
	util.PrintAndLog("resource group created")

	_, err = CreateVault(ctx, kvName)
	if err != nil {
		util.LogAndPanic(err)
	}
	util.PrintAndLog("vault created")

	_, err = SetVaultPermissions(ctx, kvName)
	if err != nil {
		util.LogAndPanic(err)
	}
	util.PrintAndLog("set vault permissions")

	_, err = CreateKey(ctx, kvName, keyName)
	if err != nil {
		util.LogAndPanic(err)
	}
	util.PrintAndLog("created key")

}
Output:

resource group created
vault created
set vault permissions
created key

func SetVaultPermissionsForDeployment

func SetVaultPermissionsForDeployment(ctx context.Context, vaultName string) (keyvault.Vault, error)

SetVaultPermissionsForDeployment updates a key vault to enable deployments and add permissions to the application

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL