Skip to content

Commit

Permalink
changing the field name secretstore->secret
Browse files Browse the repository at this point in the history
Signed-off-by: Vishwanath Hiremath <[email protected]>
  • Loading branch information
vishwahiremat committed Feb 16, 2024
1 parent 188e3d8 commit e717d11
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 42 deletions.

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions pkg/corerp/api/v20231001preview/environment_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ func toRecipeConfigDatamodel(config *RecipeConfigProperties) datamodel.RecipeCon
if gitConfig != nil {
recipeConfig.Terraform.Authentication.Git = datamodel.GitAuthConfig{}
if gitConfig.Pat != nil {
p := map[string]datamodel.Secret{}
p := map[string]datamodel.SecretConfig{}
for k, v := range gitConfig.Pat {
p[k] = datamodel.Secret{
SecretStore: to.String(v.SecretStore),
p[k] = datamodel.SecretConfig{
Secret: to.String(v.Secret),
}
}
recipeConfig.Terraform.Authentication.Git.PAT = p
Expand All @@ -221,14 +221,14 @@ func fromRecipeConfigDatamodel(config datamodel.RecipeConfigProperties) *RecipeC
if !reflect.DeepEqual(config.Terraform.Authentication.Git, datamodel.GitAuthConfig{}) {
recipeConfig.Terraform.Authentication.Git = &GitAuthConfig{}
if config.Terraform.Authentication.Git.PAT != nil {
recipeConfig.Terraform.Authentication.Git.Pat = map[string]*Secret{}
recipeConfig.Terraform.Authentication.Git.Pat = map[string]*SecretConfig{}
}
}
}
}
for k, v := range config.Terraform.Authentication.Git.PAT {
recipeConfig.Terraform.Authentication.Git.Pat[k] = &Secret{
SecretStore: to.Ptr(v.SecretStore),
recipeConfig.Terraform.Authentication.Git.Pat[k] = &SecretConfig{
Secret: to.Ptr(v.Secret),
}
}
return recipeConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ func TestConvertVersionedToDataModel(t *testing.T) {
Terraform: datamodel.TerraformConfigProperties{
Authentication: datamodel.AuthConfig{
Git: datamodel.GitAuthConfig{
PAT: map[string]datamodel.Secret{
"dev.azure.com": datamodel.Secret{
SecretStore: "/planes/radius/local/resourcegroups/default/providers/Applications.Core/secretStores/github",
PAT: map[string]datamodel.SecretConfig{
"dev.azure.com": datamodel.SecretConfig{
Secret: "/planes/radius/local/resourcegroups/default/providers/Applications.Core/secretStores/github",
},
},
},
Expand Down Expand Up @@ -381,7 +381,7 @@ func TestConvertDataModelToVersioned(t *testing.T) {
if tt.filename == "environmentresourcedatamodel.json" {
require.Equal(t, "Azure/cosmosdb/azurerm", string(*versioned.Properties.Recipes[ds_ctrl.MongoDatabasesResourceType]["terraform-recipe"].GetRecipeProperties().TemplatePath))
require.Equal(t, recipes.TemplateKindTerraform, string(*versioned.Properties.Recipes[ds_ctrl.MongoDatabasesResourceType]["terraform-recipe"].GetRecipeProperties().TemplateKind))
require.Equal(t, "/planes/radius/local/resourcegroups/default/providers/Applications.Core/secretStores/github", string(*versioned.Properties.RecipeConfig.Terraform.Authentication.Git.Pat["dev.azure.com"].SecretStore))
require.Equal(t, "/planes/radius/local/resourcegroups/default/providers/Applications.Core/secretStores/github", string(*versioned.Properties.RecipeConfig.Terraform.Authentication.Git.Pat["dev.azure.com"].Secret))
switch c := recipeDetails.(type) {
case *TerraformRecipeProperties:
require.Equal(t, "1.1.0", string(*c.TemplateVersion))
Expand Down
8 changes: 4 additions & 4 deletions pkg/corerp/api/v20231001preview/zz_generated_models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions pkg/corerp/api/v20231001preview/zz_generated_models_serde.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/corerp/datamodel/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ type AuthConfig struct {
// GitAuthConfig - Specifies authentication information needed to use private terraform module repositories from git module source
type GitAuthConfig struct {
// GitAuthConfig specifies the secret details of type personal access token for each different git platforms
PAT map[string]Secret `json:"pat,omitempty"`
PAT map[string]SecretConfig `json:"pat,omitempty"`
}

// Secret - Specifies the secret details of type personal access token for each different git platforms
type Secret struct {
// SecretConfig - Specifies the secret details of type personal access token for each different git platforms
type SecretConfig struct {
// Secret represent the resource id for the secret store containing credentials
SecretStore string `json:"secretStore,omitempty"`
Secret string `json:"secret,omitempty"`
}

// EnvironmentRecipeProperties represents the properties of environment's recipe.
Expand Down
12 changes: 6 additions & 6 deletions pkg/recipes/configloader/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ func TestGetConfiguration(t *testing.T) {
Terraform: &model.TerraformConfigProperties{
Authentication: &model.AuthConfig{
Git: &model.GitAuthConfig{
Pat: map[string]*model.Secret{
"dev.azure.com": &model.Secret{
SecretStore: to.Ptr("secretStoreID"),
Pat: map[string]*model.SecretConfig{
"dev.azure.com": &model.SecretConfig{
Secret: to.Ptr("secretStoreID"),
},
},
},
Expand All @@ -213,9 +213,9 @@ func TestGetConfiguration(t *testing.T) {
Terraform: datamodel.TerraformConfigProperties{
Authentication: datamodel.AuthConfig{
Git: datamodel.GitAuthConfig{
PAT: map[string]datamodel.Secret{
"dev.azure.com": datamodel.Secret{
SecretStore: "secretStoreID",
PAT: map[string]datamodel.SecretConfig{
"dev.azure.com": datamodel.SecretConfig{
Secret: "secretStoreID",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/recipes/terraform/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func getSecretStoreID(envConfig recipes.Configuration, templatePath string) (str
return "", err
}

return envConfig.RecipeConfig.Terraform.Authentication.Git.PAT[strings.TrimPrefix(url.Hostname(), "www.")].SecretStore, nil
return envConfig.RecipeConfig.Terraform.Authentication.Git.PAT[strings.TrimPrefix(url.Hostname(), "www.")].Secret, nil
}

// getMainConfigFilePath returns the path of the Terraform main config file.
Expand Down
6 changes: 3 additions & 3 deletions pkg/recipes/terraform/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,9 @@ func Test_getSecretStoreID(t *testing.T) {
Terraform: datamodel.TerraformConfigProperties{
Authentication: datamodel.AuthConfig{
Git: datamodel.GitAuthConfig{
PAT: map[string]datamodel.Secret{
"dev.azure.com": datamodel.Secret{
SecretStore: "secret-store1",
PAT: map[string]datamodel.SecretConfig{
"dev.azure.com": datamodel.SecretConfig{
Secret: "secret-store1",
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4041,7 +4041,7 @@
"type": "object",
"description": "Specifies the secret details of type personal access token for each different git platforms",
"additionalProperties": {
"$ref": "#/definitions/Secret"
"$ref": "#/definitions/SecretConfig"
}
}
}
Expand Down Expand Up @@ -5011,11 +5011,11 @@
}
}
},
"Secret": {
"SecretConfig": {
"type": "object",
"description": "Specifies the secret details of type personal access token for each different git platforms",
"properties": {
"secretStore": {
"secret": {
"type": "string",
"description": "The resource id for the Applications.Core/SecretStore resource containing credentials."
}
Expand Down
6 changes: 3 additions & 3 deletions typespec/Applications.Core/environments.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ model AuthConfig{
@doc("Specifies authentication information needed to access private terraform modules from Git repository sources.")
model GitAuthConfig{
@doc("Specifies the secret details of type personal access token for each different git platforms")
pat?: Record<Secret>;
pat?: Record<SecretConfig>;
}

@doc("Specifies the secret details of type personal access token for each different git platforms")
model Secret {
model SecretConfig {
@doc("The resource id for the Applications.Core/SecretStore resource containing credentials.")
secretStore?: string;
secret?: string;
}

@doc("The Cloud providers configuration")
Expand Down

0 comments on commit e717d11

Please sign in to comment.