Skip to content

Commit

Permalink
Add oneof validation to cluster options type (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
vandyliu authored Apr 23, 2024
1 parent fe87c9a commit b5bb9ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ jobs:
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
with:
args: release --clean
args: release --clean ${{ env.SIGNING_DISABLED == 'true' && '--skip sign' }}
env:
# GitHub sets the GITHUB_TOKEN secret automatically.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
SIGNING_DISABLED: 'true'
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package datasources_test

import (
"fmt"
"regexp"
"testing"

"github.com/astronomer/astronomer-terraform-provider/internal/utils"
Expand All @@ -18,6 +19,10 @@ func TestAcc_DataSourceClusterOptions(t *testing.T) {
},
ProtoV6ProviderFactories: astronomerprovider.TestAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: astronomerprovider.ProviderConfig(t, true) + clusterOptions("invalid", "AWS"),
ExpectError: regexp.MustCompile(`type value must be one of`),
},
{
Config: astronomerprovider.ProviderConfig(t, true) + clusterOptions("HYBRID", "AWS"),
Check: resource.ComposeTestCheckFunc(
Expand Down
6 changes: 6 additions & 0 deletions internal/provider/schemas/cluster_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ func ClusterOptionsDataSourceSchemaAttributes() map[string]schema.Attribute {
},
"type": schema.StringAttribute{
Required: true,
Validators: []validator.String{
stringvalidator.OneOf(
string(platform.ClusterTypeDEDICATED),
string(platform.ClusterTypeHYBRID),
),
},
},
"cloud_provider": schema.StringAttribute{
Optional: true,
Expand Down

0 comments on commit b5bb9ff

Please sign in to comment.