Skip to content

Commit

Permalink
SCALRCORE-30896 Provider configurations owners
Browse files Browse the repository at this point in the history
  • Loading branch information
DayS1eeper committed Apr 25, 2024
1 parent 88a7be1 commit cf2950b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions provider_configuration.go
Expand Up @@ -64,6 +64,7 @@ type ProviderConfiguration struct {
Account *Account `jsonapi:"relation,account"`
Parameters []*ProviderConfigurationParameter `jsonapi:"relation,parameters"`
Environments []*Environment `jsonapi:"relation,environments"`
Owners []*Team `jsonapi:"relation,owners"`
}

// ProviderConfigurationsListOptions represents the options for listing provider configurations.
Expand Down Expand Up @@ -132,6 +133,7 @@ type ProviderConfigurationCreateOptions struct {

Account *Account `jsonapi:"relation,account,omitempty"`
Environments []*Environment `jsonapi:"relation,environments,omitempty"`
Owners []*Team `jsonapi:"relation,owners"`
}

// Create is used to create a new provider configuration.
Expand Down Expand Up @@ -207,6 +209,7 @@ type ProviderConfigurationUpdateOptions struct {
GoogleUseDefaultProject *bool `jsonapi:"attr,google-use-default-project,omitempty"`
ScalrHostname *string `jsonapi:"attr,scalr-hostname"`
ScalrToken *string `jsonapi:"attr,scalr-token"`
Owners []*Team `jsonapi:"relation,owners"`
}

// Update an existing provider configuration.
Expand Down
10 changes: 10 additions & 0 deletions provider_configuration_test.go
Expand Up @@ -91,13 +91,17 @@ func TestProviderConfigurationCreateScalr(t *testing.T) {
ctx := context.Background()

t.Run("success scalr", func(t *testing.T) {
ownerTeam, ownerTeamCleanup := createTeam(t, client, nil)
defer ownerTeamCleanup()

options := ProviderConfigurationCreateOptions{
Account: &Account{ID: defaultAccountID},
Name: String("scalr_dev"),
ProviderName: String("scalr"),
ExportShellVariables: Bool(false),
ScalrHostname: String(scalrHostname),
ScalrToken: String(scalrToken),
Owners: []*Team{{ID: ownerTeam.ID}},
}
pcfg, err := client.ProviderConfigurations.Create(ctx, options)
if err != nil {
Expand All @@ -114,6 +118,7 @@ func TestProviderConfigurationCreateScalr(t *testing.T) {
assert.Equal(t, *options.ExportShellVariables, pcfg.ExportShellVariables)
assert.Equal(t, *options.ScalrHostname, pcfg.ScalrHostname)
assert.Equal(t, "", pcfg.ScalrToken)
assert.Equal(t, &options.Owners, &pcfg.Owners)
})
}

Expand Down Expand Up @@ -573,13 +578,17 @@ func TestProviderConfigurationUpdateScalr(t *testing.T) {
}
defer client.ProviderConfigurations.Delete(ctx, configuration.ID)

ownerTeam, ownerTeamCleanup := createTeam(t, client, nil)
defer ownerTeamCleanup()

updateOptions := ProviderConfigurationUpdateOptions{
Name: String("scalr_prod"),
ExportShellVariables: Bool(true),
ScalrHostname: String(scalrHostname + "/"),
ScalrToken: String(scalrToken),
IsShared: Bool(true),
Environments: []*Environment{},
Owners: []*Team{{ID: ownerTeam.ID}},
}
updatedConfiguration, err := client.ProviderConfigurations.Update(
ctx, configuration.ID, updateOptions,
Expand All @@ -589,6 +598,7 @@ func TestProviderConfigurationUpdateScalr(t *testing.T) {
assert.Equal(t, *updateOptions.ExportShellVariables, updatedConfiguration.ExportShellVariables)
assert.Equal(t, *updateOptions.ScalrHostname, updatedConfiguration.ScalrHostname)
assert.Equal(t, *updateOptions.IsShared, updatedConfiguration.IsShared)
assert.Equal(t, &updateOptions.Owners, &updatedConfiguration.Owners)
})
}

Expand Down

0 comments on commit cf2950b

Please sign in to comment.