From 761a3890bd5836d618aec907a11365b25a05aa97 Mon Sep 17 00:00:00 2001 From: Denys Kolomytskyi Date: Fri, 23 Jun 2023 14:48:31 +0300 Subject: [PATCH] SCALRCORE-26905 Provider configurations > Google > Workload identity --- provider_configuration.go | 131 ++++++++++++++++++--------------- provider_configuration_test.go | 1 + 2 files changed, 71 insertions(+), 61 deletions(-) diff --git a/provider_configuration.go b/provider_configuration.go index 2588ea9..6bcdaa8 100644 --- a/provider_configuration.go +++ b/provider_configuration.go @@ -32,27 +32,30 @@ type ProviderConfigurationsList struct { // ProviderConfiguration represents a Scalr provider configuration. type ProviderConfiguration struct { - ID string `jsonapi:"primary,provider-configurations"` - Name string `jsonapi:"attr,name"` - ProviderName string `jsonapi:"attr,provider-name"` - ExportShellVariables bool `jsonapi:"attr,export-shell-variables"` - IsShared bool `jsonapi:"attr,is-shared"` - IsCustom bool `jsonapi:"attr,is-custom"` - AwsAccessKey string `jsonapi:"attr,aws-access-key"` - AwsSecretKey string `jsonapi:"attr,aws-secret-key"` - AwsAccountType string `jsonapi:"attr,aws-account-type"` - AwsCredentialsType string `jsonapi:"attr,aws-credentials-type"` - AwsTrustedEntityType string `jsonapi:"attr,aws-trusted-entity-type"` - AwsRoleArn string `jsonapi:"attr,aws-role-arn"` - AwsExternalId string `jsonapi:"attr,aws-external-id"` - AzurermClientId string `jsonapi:"attr,azurerm-client-id"` - AzurermClientSecret string `jsonapi:"attr,azurerm-client-secret"` - AzurermSubscriptionId string `jsonapi:"attr,azurerm-subscription-id"` - AzurermTenantId string `jsonapi:"attr,azurerm-tenant-id"` - GoogleProject string `jsonapi:"attr,google-project"` - GoogleCredentials string `jsonapi:"attr,google-credentials"` - ScalrHostname string `jsonapi:"attr,scalr-hostname"` - ScalrToken string `jsonapi:"attr,scalr-token"` + ID string `jsonapi:"primary,provider-configurations"` + Name string `jsonapi:"attr,name"` + ProviderName string `jsonapi:"attr,provider-name"` + ExportShellVariables bool `jsonapi:"attr,export-shell-variables"` + IsShared bool `jsonapi:"attr,is-shared"` + IsCustom bool `jsonapi:"attr,is-custom"` + AwsAccessKey string `jsonapi:"attr,aws-access-key"` + AwsSecretKey string `jsonapi:"attr,aws-secret-key"` + AwsAccountType string `jsonapi:"attr,aws-account-type"` + AwsCredentialsType string `jsonapi:"attr,aws-credentials-type"` + AwsTrustedEntityType string `jsonapi:"attr,aws-trusted-entity-type"` + AwsRoleArn string `jsonapi:"attr,aws-role-arn"` + AwsExternalId string `jsonapi:"attr,aws-external-id"` + AzurermClientId string `jsonapi:"attr,azurerm-client-id"` + AzurermClientSecret string `jsonapi:"attr,azurerm-client-secret"` + AzurermSubscriptionId string `jsonapi:"attr,azurerm-subscription-id"` + AzurermTenantId string `jsonapi:"attr,azurerm-tenant-id"` + GoogleAuthType string `jsonapi:"attr,google-auth-type"` + GoogleServiceAccountEmail string `jsonapi:"attr,google-service-account-email"` + GoogleWorkloadProviderName string `jsonapi:"attr,google-workload-provider-name"` + GoogleProject string `jsonapi:"attr,google-project"` + GoogleCredentials string `jsonapi:"attr,google-credentials"` + ScalrHostname string `jsonapi:"attr,scalr-hostname"` + ScalrToken string `jsonapi:"attr,scalr-token"` Account *Account `jsonapi:"relation,account"` Parameters []*ProviderConfigurationParameter `jsonapi:"relation,parameters"` @@ -94,27 +97,30 @@ func (s *providerConfigurations) List(ctx context.Context, options ProviderConfi // ProviderConfigurationCreateOptions represents the options for creating a new provider configuration. type ProviderConfigurationCreateOptions struct { - ID string `jsonapi:"primary,provider-configurations"` - Name *string `jsonapi:"attr,name"` - ProviderName *string `jsonapi:"attr,provider-name"` - ExportShellVariables *bool `jsonapi:"attr,export-shell-variables,omitempty"` - IsShared *bool `jsonapi:"attr,is-shared,omitempty"` - IsCustom *bool `jsonapi:"attr,is-custom,omitempty"` - AwsAccessKey *string `jsonapi:"attr,aws-access-key,omitempty"` - AwsSecretKey *string `jsonapi:"attr,aws-secret-key,omitempty"` - AwsAccountType *string `jsonapi:"attr,aws-account-type"` - AwsCredentialsType *string `jsonapi:"attr,aws-credentials-type"` - AwsTrustedEntityType *string `jsonapi:"attr,aws-trusted-entity-type"` - AwsRoleArn *string `jsonapi:"attr,aws-role-arn"` - AwsExternalId *string `jsonapi:"attr,aws-external-id"` - AzurermClientId *string `jsonapi:"attr,azurerm-client-id,omitempty"` - AzurermClientSecret *string `jsonapi:"attr,azurerm-client-secret,omitempty"` - AzurermSubscriptionId *string `jsonapi:"attr,azurerm-subscription-id,omitempty"` - AzurermTenantId *string `jsonapi:"attr,azurerm-tenant-id,omitempty"` - GoogleProject *string `jsonapi:"attr,google-project,omitempty"` - GoogleCredentials *string `jsonapi:"attr,google-credentials,omitempty"` - ScalrHostname *string `jsonapi:"attr,scalr-hostname,omitempty"` - ScalrToken *string `jsonapi:"attr,scalr-token,omitempty"` + ID string `jsonapi:"primary,provider-configurations"` + Name *string `jsonapi:"attr,name"` + ProviderName *string `jsonapi:"attr,provider-name"` + ExportShellVariables *bool `jsonapi:"attr,export-shell-variables,omitempty"` + IsShared *bool `jsonapi:"attr,is-shared,omitempty"` + IsCustom *bool `jsonapi:"attr,is-custom,omitempty"` + AwsAccessKey *string `jsonapi:"attr,aws-access-key,omitempty"` + AwsSecretKey *string `jsonapi:"attr,aws-secret-key,omitempty"` + AwsAccountType *string `jsonapi:"attr,aws-account-type"` + AwsCredentialsType *string `jsonapi:"attr,aws-credentials-type"` + AwsTrustedEntityType *string `jsonapi:"attr,aws-trusted-entity-type"` + AwsRoleArn *string `jsonapi:"attr,aws-role-arn"` + AwsExternalId *string `jsonapi:"attr,aws-external-id"` + AzurermClientId *string `jsonapi:"attr,azurerm-client-id,omitempty"` + AzurermClientSecret *string `jsonapi:"attr,azurerm-client-secret,omitempty"` + AzurermSubscriptionId *string `jsonapi:"attr,azurerm-subscription-id,omitempty"` + AzurermTenantId *string `jsonapi:"attr,azurerm-tenant-id,omitempty"` + GoogleAuthType *string `jsonapi:"attr,google-auth-type,omitempty"` + GoogleServiceAccountEmail *string `jsonapi:"attr,google-service-account-email,omitempty"` + GoogleWorkloadProviderName *string `jsonapi:"attr,google-workload-provider-name,omitempty"` + GoogleProject *string `jsonapi:"attr,google-project,omitempty"` + GoogleCredentials *string `jsonapi:"attr,google-credentials,omitempty"` + ScalrHostname *string `jsonapi:"attr,scalr-hostname,omitempty"` + ScalrToken *string `jsonapi:"attr,scalr-token,omitempty"` Account *Account `jsonapi:"relation,account,omitempty"` Environments []*Environment `jsonapi:"relation,environments,omitempty"` @@ -167,25 +173,28 @@ func (s *providerConfigurations) Read(ctx context.Context, configurationID strin type ProviderConfigurationUpdateOptions struct { ID string `jsonapi:"primary,provider-configurations"` - Name *string `jsonapi:"attr,name"` - IsShared *bool `jsonapi:"attr,is-shared,omitempty"` - Environments []*Environment `jsonapi:"relation,environments"` - ExportShellVariables *bool `jsonapi:"attr,export-shell-variables"` - AwsAccessKey *string `jsonapi:"attr,aws-access-key"` - AwsSecretKey *string `jsonapi:"attr,aws-secret-key"` - AwsAccountType *string `jsonapi:"attr,aws-account-type"` - AwsCredentialsType *string `jsonapi:"attr,aws-credentials-type"` - AwsTrustedEntityType *string `jsonapi:"attr,aws-trusted-entity-type"` - AwsRoleArn *string `jsonapi:"attr,aws-role-arn"` - AwsExternalId *string `jsonapi:"attr,aws-external-id"` - AzurermClientId *string `jsonapi:"attr,azurerm-client-id"` - AzurermClientSecret *string `jsonapi:"attr,azurerm-client-secret"` - AzurermSubscriptionId *string `jsonapi:"attr,azurerm-subscription-id"` - AzurermTenantId *string `jsonapi:"attr,azurerm-tenant-id"` - GoogleProject *string `jsonapi:"attr,google-project"` - GoogleCredentials *string `jsonapi:"attr,google-credentials"` - ScalrHostname *string `jsonapi:"attr,scalr-hostname"` - ScalrToken *string `jsonapi:"attr,scalr-token"` + Name *string `jsonapi:"attr,name"` + IsShared *bool `jsonapi:"attr,is-shared,omitempty"` + Environments []*Environment `jsonapi:"relation,environments"` + ExportShellVariables *bool `jsonapi:"attr,export-shell-variables"` + AwsAccessKey *string `jsonapi:"attr,aws-access-key"` + AwsSecretKey *string `jsonapi:"attr,aws-secret-key"` + AwsAccountType *string `jsonapi:"attr,aws-account-type"` + AwsCredentialsType *string `jsonapi:"attr,aws-credentials-type"` + AwsTrustedEntityType *string `jsonapi:"attr,aws-trusted-entity-type"` + AwsRoleArn *string `jsonapi:"attr,aws-role-arn"` + AwsExternalId *string `jsonapi:"attr,aws-external-id"` + AzurermClientId *string `jsonapi:"attr,azurerm-client-id"` + AzurermClientSecret *string `jsonapi:"attr,azurerm-client-secret"` + AzurermSubscriptionId *string `jsonapi:"attr,azurerm-subscription-id"` + AzurermTenantId *string `jsonapi:"attr,azurerm-tenant-id"` + GoogleAuthType *string `jsonapi:"attr,google-auth-type"` + GoogleServiceAccountEmail *string `jsonapi:"attr,google-service-account-email"` + GoogleWorkloadProviderName *string `jsonapi:"attr,google-workload-provider-name"` + GoogleProject *string `jsonapi:"attr,google-project"` + GoogleCredentials *string `jsonapi:"attr,google-credentials"` + ScalrHostname *string `jsonapi:"attr,scalr-hostname"` + ScalrToken *string `jsonapi:"attr,scalr-token"` } // Update an existing provider configuration. diff --git a/provider_configuration_test.go b/provider_configuration_test.go index 5ec8bff..e2147fd 100644 --- a/provider_configuration_test.go +++ b/provider_configuration_test.go @@ -254,6 +254,7 @@ func TestProviderConfigurationCreateGoogle(t *testing.T) { assert.Equal(t, *options.ExportShellVariables, pcfg.ExportShellVariables) assert.Equal(t, *options.GoogleProject, pcfg.GoogleProject) assert.Equal(t, "", pcfg.GoogleCredentials) + assert.Equal(t, "service-account-key", pcfg.GoogleAuthType) }) }