This commit is contained in:
Jim Minter 2020-11-17 16:25:01 -06:00
Родитель b7db581571
Коммит 611ef65c28
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 0730CBDA10D1A2D3
4 изменённых файлов: 11 добавлений и 16 удалений

Просмотреть файл

@ -23,8 +23,8 @@ steady state: manage ACR tokens, DNS zone records, private endpoints.
## rpAuthorizer
The managed identity attached to the RP VM, in the AME tenant, for use against
ARM. Used for bootstrapping: finding the CosmosDB account and key, finding the
DNS zone, populating the SKU list.
ARM. Used for bootstrapping: finding the CosmosDB key, finding the DNS zone,
populating the SKU list.
## rpKVAuthorizer

Просмотреть файл

@ -268,9 +268,9 @@ locations.
export RP_MODE='development'
export PULL_SECRET='$PULL_SECRET'
export SECRET_SA_ACCOUNT_NAME='$SECRET_SA_ACCOUNT_NAME'
export DATABASE_ACCOUNT_NAME="\$RESOURCEGROUP"
export KEYVAULT_PREFIX="\$RESOURCEGROUP"
ADMIN_OBJECT_ID='$ADMIN_OBJECT_ID'
DATABASE_ACCOUNT_NAME="\$RESOURCEGROUP"
DOMAIN_NAME="\$RESOURCEGROUP"
PARENT_DOMAIN_NAME='$PARENT_DOMAIN_NAME'
PARENT_DOMAIN_RESOURCEGROUP='$PARENT_DOMAIN_RESOURCEGROUP'

Просмотреть файл

@ -84,6 +84,14 @@ func databaseName(deploymentMode deployment.Mode) (string, error) {
}
func find(ctx context.Context, env env.Core) (string, string, error) {
for _, key := range []string{
"DATABASE_ACCOUNT_NAME",
} {
if _, found := os.LookupEnv(key); !found {
return "", "", fmt.Errorf("environment variable %q unset", key)
}
}
rpAuthorizer, err := env.NewRPAuthorizer(env.Environment().ResourceManagerEndpoint)
if err != nil {
return "", "", err
@ -92,18 +100,6 @@ func find(ctx context.Context, env env.Core) (string, string, error) {
databaseaccounts := documentdb.NewDatabaseAccountsClient(env.SubscriptionID(), rpAuthorizer)
acctName := os.Getenv("DATABASE_ACCOUNT_NAME")
if acctName == "" {
accts, err := databaseaccounts.ListByResourceGroup(ctx, env.ResourceGroup())
if err != nil {
return "", "", err
}
if len(*accts.Value) != 1 {
return "", "", fmt.Errorf("found %d database accounts, expected 1", len(*accts.Value))
}
acctName = *(*accts.Value)[0].Name
}
keys, err := databaseaccounts.ListKeys(ctx, env.ResourceGroup(), acctName)
if err != nil {

Просмотреть файл

@ -12,7 +12,6 @@ import (
// DatabaseAccountsClient is a minimal interface for azure DatabaseAccountsClient
type DatabaseAccountsClient interface {
ListByResourceGroup(ctx context.Context, resourceGroupName string) (result mgmtdocumentdb.DatabaseAccountsListResult, err error)
ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result mgmtdocumentdb.DatabaseAccountListKeysResult, err error)
}