Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add resource update tests, force-new on sign, use OCI validators #17

Merged
merged 3 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- uses: actions/setup-go@v4
with:
go-version: '1.18'
go-version: 1.20.x
- run: go generate ./...
- name: git diff
run: |
Expand Down Expand Up @@ -43,22 +43,11 @@ jobs:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- uses: actions/setup-go@v4
with:
go-version: '1.18'

- uses: imjasonh/setup-crane@v0.3
- uses: chainguard-dev/actions/setup-registry@main
with:
port: 5000

go-version: 1.20.x
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false

- run: go mod download
- run: go build -v .
- run: |
crane copy --insecure cgr.dev/chainguard/static:latest-glibc localhost:5000/cosign-testing
export TEST_IMAGE=localhost:5000/cosign-testing@$(crane digest --insecure localhost:5000/cosign-testing)

TF_ACC=1 go test -v -cover ./internal/provider/
- run: TF_ACC=1 go test -v -cover ./internal/provider/
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/chainguard-dev/terraform-provider-cosign
go 1.19

require (
github.com/chainguard-dev/terraform-provider-oci v0.0.0-20230426201150-f82273dff08e
github.com/google/go-containerregistry v0.14.1-0.20230409045903-ed5c185df419
github.com/google/uuid v1.3.0
github.com/hashicorp/terraform-plugin-docs v0.14.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chainguard-dev/terraform-provider-oci v0.0.0-20230426201150-f82273dff08e h1:9FgJN0uYkNRTKa9b4ds8yKWD0ic5ETUlP5mmAZfYmOc=
github.com/chainguard-dev/terraform-provider-oci v0.0.0-20230426201150-f82273dff08e/go.mod h1:c0UCXzRaVhzUcS1raw1wrDsXJpOkwWvyv5RcnvAmX7U=
github.com/chrismellard/docker-credential-acr-env v0.0.0-20221002210726-e883f69e0206 h1:lG6Usi/kX/JBZzGz1H+nV+KwM97vThQeKunCbS6PutU=
github.com/chrismellard/docker-credential-acr-env v0.0.0-20221002210726-e883f69e0206/go.mod h1:1UmFRnmMnVsHwD+ZntmLkoVBB1ZLa6V+XXEbF6hZCxU=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
Expand Down
89 changes: 0 additions & 89 deletions internal/provider/attest_resource_test.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package provider
import (
"context"

"github.com/chainguard-dev/terraform-provider-oci/pkg/validators"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"
"github.com/hashicorp/terraform-plugin-framework/datasource"
Expand Down Expand Up @@ -43,7 +44,7 @@ func (d *VerifyDataSource) Schema(ctx context.Context, req datasource.SchemaRequ
"image": schema.StringAttribute{
MarkdownDescription: "The image tag or digest of the container image to verify.",
Required: true,
Validators: []validator.String{refValidator{}},
Validators: []validator.String{validators.RefValidator{}},
},
"policy": schema.StringAttribute{
MarkdownDescription: "The sigstore policy-controller policy to verify the image against.",
Expand Down
27 changes: 0 additions & 27 deletions internal/provider/digest_validator.go

This file was deleted.

27 changes: 0 additions & 27 deletions internal/provider/json_validator.go

This file was deleted.

25 changes: 0 additions & 25 deletions internal/provider/ref_validator.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"

"github.com/chainguard-dev/terraform-provider-oci/pkg/validators"
"github.com/google/go-containerregistry/pkg/name"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
Expand Down Expand Up @@ -57,7 +58,7 @@ func (r *AttestResource) Schema(ctx context.Context, req resource.SchemaRequest,
MarkdownDescription: "The digest of the container image to attest.",
Optional: false,
Required: true,
Validators: []validator.String{digestValidator{}},
Validators: []validator.String{validators.DigestValidator{}},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Expand All @@ -66,7 +67,7 @@ func (r *AttestResource) Schema(ctx context.Context, req resource.SchemaRequest,
MarkdownDescription: "The in-toto predicate type of the claim being attested.",
Optional: false,
Required: true,
Validators: []validator.String{urlValidator{}},
Validators: []validator.String{validators.URLValidator{}},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Expand All @@ -75,7 +76,7 @@ func (r *AttestResource) Schema(ctx context.Context, req resource.SchemaRequest,
MarkdownDescription: "The JSON body of the in-toto predicate's claim.",
Optional: false,
Required: true,
Validators: []validator.String{jsonValidator{}},
Validators: []validator.String{validators.JSONValidator{}},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Expand Down
Loading