Skip to content

Commit

Permalink
Add empty string validators to : credentials, access_token, impersona…
Browse files Browse the repository at this point in the history
…te_service_account, project, billing_project, region, zone
  • Loading branch information
SarahFrench committed Sep 22, 2023
1 parent 3147daa commit ab01d1b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
17 changes: 17 additions & 0 deletions mmv1/third_party/terraform/fwprovider/framework_provider.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
path.MatchRoot("access_token"),
}...),
CredentialsValidator(),
NonEmptyStringValidator(),
},
},
"access_token": schema.StringAttribute{
Expand All @@ -79,26 +80,42 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
stringvalidator.ConflictsWith(path.Expressions{
path.MatchRoot("credentials"),
}...),
NonEmptyStringValidator(),
},
},
"impersonate_service_account": schema.StringAttribute{
Optional: true,
Validators: []validator.String{
NonEmptyStringValidator(),
},
},
"impersonate_service_account_delegates": schema.ListAttribute{
Optional: true,
ElementType: types.StringType,
},
"project": schema.StringAttribute{
Optional: true,
Validators: []validator.String{
NonEmptyStringValidator(),
},
},
"billing_project": schema.StringAttribute{
Optional: true,
Validators: []validator.String{
NonEmptyStringValidator(),
},
},
"region": schema.StringAttribute{
Optional: true,
Validators: []validator.String{
NonEmptyStringValidator(),
},
},
"zone": schema.StringAttribute{
Optional: true,
Validators: []validator.String{
NonEmptyStringValidator(),
},
},
"scopes": schema.ListAttribute{
Optional: true,
Expand Down
36 changes: 21 additions & 15 deletions mmv1/third_party/terraform/provider/provider.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,23 @@ func Provider() *schema.Provider {
provider := &schema.Provider{
Schema: map[string]*schema.Schema{
"credentials": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: ValidateCredentials,
Type: schema.TypeString,
Optional: true,
ValidateFunc: ValidateCredentials,
ConflictsWith: []string{"access_token"},
},

"access_token": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
ValidateFunc: ValidateEmptyStrings,
ConflictsWith: []string{"credentials"},
},

"impersonate_service_account": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
ValidateFunc: ValidateEmptyStrings,
},

"impersonate_service_account_delegates": {
Expand All @@ -82,23 +84,27 @@ func Provider() *schema.Provider {
},

"project": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
ValidateFunc: ValidateEmptyStrings,
},

"billing_project": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
ValidateFunc: ValidateEmptyStrings,
},

"region": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
ValidateFunc: ValidateEmptyStrings,
},

"zone": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
ValidateFunc: ValidateEmptyStrings,
},

"scopes": {
Expand Down

0 comments on commit ab01d1b

Please sign in to comment.