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 "global" harness configs plumbed through provider configs #7

Merged
merged 1 commit into from
Jan 9, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Release
on:
push:
tags:
- 'v*'
- "v*"

# Releases need permissions to read and write the repository contents.
# GitHub considers creating releases and uploading assets as writing contents.
Expand All @@ -23,7 +23,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"
cache: true
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.0
Expand Down
18 changes: 7 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ name: Tests
on:
pull_request:
paths-ignore:
- 'README.md'
- "README.md"
push:
paths-ignore:
- 'README.md'
- "README.md"

# Testing only needs permissions to read the repository contents.
permissions:
Expand All @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"
cache: true
- run: go mod download
- run: go build -v .
Expand All @@ -40,7 +40,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"
cache: true
- run: go generate ./...
- name: git diff
Expand All @@ -57,18 +57,14 @@ jobs:
strategy:
fail-fast: false
matrix:
# list whatever Terraform versions here you would like to support
terraform:
- '1.0.*'
- '1.1.*'
- '1.2.*'
- '1.3.*'
- '1.4.*'
- "1.5.*"
- "1.6.*"
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"
cache: true
- uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
with:
Expand Down
82 changes: 82 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,85 @@ description: |-

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `harnesses` (Attributes) (see [below for nested schema](#nestedatt--harnesses))

<a id="nestedatt--harnesses"></a>
### Nested Schema for `harnesses`

Optional:

- `container` (Attributes) (see [below for nested schema](#nestedatt--harnesses--container))
- `k3s` (Attributes) (see [below for nested schema](#nestedatt--harnesses--k3s))

<a id="nestedatt--harnesses--container"></a>
### Nested Schema for `harnesses.container`

Optional:

- `envs` (Map of String) Environment variables to set on the container.
- `mounts` (Attributes List) The list of mounts to create on the container. (see [below for nested schema](#nestedatt--harnesses--container--mounts))
- `networks` (Attributes Map) A map of existing networks to attach the container to. (see [below for nested schema](#nestedatt--harnesses--container--networks))

<a id="nestedatt--harnesses--container--mounts"></a>
### Nested Schema for `harnesses.container.mounts`

Required:

- `destination` (String) The absolute path on the container to mount the source directory to.
- `source` (String) The relative or absolute path on the host to the source directory to mount.


<a id="nestedatt--harnesses--container--networks"></a>
### Nested Schema for `harnesses.container.networks`

Required:

- `name` (String) The name of the existing network to attach the container to.



<a id="nestedatt--harnesses--k3s"></a>
### Nested Schema for `harnesses.k3s`

Optional:

- `registries` (Attributes Map) A map of registries containing configuration for optional auth, tls, and mirror configuration. (see [below for nested schema](#nestedatt--harnesses--k3s--registries))

<a id="nestedatt--harnesses--k3s--registries"></a>
### Nested Schema for `harnesses.k3s.registries`

Optional:

- `auth` (Attributes) (see [below for nested schema](#nestedatt--harnesses--k3s--registries--auth))
- `mirror` (Attributes) (see [below for nested schema](#nestedatt--harnesses--k3s--registries--mirror))
- `tls` (Attributes) (see [below for nested schema](#nestedatt--harnesses--k3s--registries--tls))

<a id="nestedatt--harnesses--k3s--registries--auth"></a>
### Nested Schema for `harnesses.k3s.registries.tls`

Optional:

- `auth` (String)
- `password` (String, Sensitive)
- `username` (String)


<a id="nestedatt--harnesses--k3s--registries--mirror"></a>
### Nested Schema for `harnesses.k3s.registries.tls`

Optional:

- `endpoints` (List of String)


<a id="nestedatt--harnesses--k3s--registries--tls"></a>
### Nested Schema for `harnesses.k3s.registries.tls`

Optional:

- `ca_file` (String)
- `cert_file` (String)
- `key_file` (String)
2 changes: 1 addition & 1 deletion docs/resources/feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ Example resource

### Required

- `harness` (String) The ID of the test harness to use for the feature
- `name` (String) The name of the feature

### Optional

- `after` (Attributes List) Actions to run againast the harness after the core steps have run OR after a step has failed. (see [below for nested schema](#nestedatt--after))
- `before` (Attributes List) Actions to run against the harness before the core feature steps. (see [below for nested schema](#nestedatt--before))
- `description` (String) A descriptor of the feature
- `harness` (String) The ID of the test harness to use for the feature
- `labels` (Map of String) A set of labels used to optionally filter execution of the feature
- `steps` (Attributes List) Actions to run against the harness. (see [below for nested schema](#nestedatt--steps))

Expand Down
11 changes: 10 additions & 1 deletion docs/resources/harness_container.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ A harness that runs steps in a sandbox container.
- `envs` (Map of String) Environment variables to set on the container.
- `image` (String) The full image reference to use for the k3s container.
- `mounts` (Attributes List) The list of mounts to create on the container. (see [below for nested schema](#nestedatt--mounts))
- `networks` (Attributes Map) A map of existing networks to attach the container to. (see [below for nested schema](#nestedatt--networks))
- `privileged` (Boolean)

### Read-Only
Expand All @@ -31,5 +32,13 @@ A harness that runs steps in a sandbox container.

Required:

- `destination` (String) The absolute path on the container to mount the source directory to.
- `destination` (String) The absolute path on the container to mount the source directory.
- `source` (String) The relative or absolute path on the host to the source directory to mount.


<a id="nestedatt--networks"></a>
### Nested Schema for `networks`

Required:

- `name` (String) The name of the existing network to attach the container to.
37 changes: 37 additions & 0 deletions docs/resources/harness_k3s.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,44 @@ A harness that runs steps in a sandbox container networked to a running k3s clus
- `disable_metrics_server` (Boolean) When true, the builtin metrics server will be disabled.
- `disable_traefik` (Boolean) When true, the builtin traefik ingress controller will be disabled.
- `image` (String) The full image reference to use for the k3s container.
- `registries` (Attributes Map) A map of registries containing configuration for optional auth, tls, and mirror configuration. (see [below for nested schema](#nestedatt--registries))

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedatt--registries"></a>
### Nested Schema for `registries`

Optional:

- `auth` (Attributes) (see [below for nested schema](#nestedatt--registries--auth))
- `mirror` (Attributes) (see [below for nested schema](#nestedatt--registries--mirror))
- `tls` (Attributes) (see [below for nested schema](#nestedatt--registries--tls))

<a id="nestedatt--registries--auth"></a>
### Nested Schema for `registries.auth`

Optional:

- `auth` (String)
- `password` (String, Sensitive)
- `username` (String)


<a id="nestedatt--registries--mirror"></a>
### Nested Schema for `registries.mirror`

Optional:

- `endpoints` (List of String)


<a id="nestedatt--registries--tls"></a>
### Nested Schema for `registries.tls`

Optional:

- `ca_file` (String)
- `cert_file` (String)
- `key_file` (String)
13 changes: 0 additions & 13 deletions examples/resources/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ provider "imagetest" {}
# Create a harness that runs features in a container.
resource "imagetest_harness_container" "this" {
image = "cgr.dev/chainguard/wolfi-base:latest"
mounts = [
{
source = path.module
destination = "/src"
}
]
}
resource "imagetest_harness_teardown" "container" { harness = imagetest_harness_container.this.id }

Expand All @@ -34,12 +28,6 @@ resource "imagetest_feature" "container" {
apk add curl
EOF
},
{
name = "Access files we mounted from the host"
cmd = <<EOF
ls -lah /src
EOF
},
]

labels = {
Expand All @@ -66,7 +54,6 @@ resource "imagetest_feature" "k3s" {
cmd = <<EOF
kubectl get no
kubectl get po -A
kubectl run nginx --image=cgr.dev/chainguard/nginx:latest
EOF
},
]
Expand Down
19 changes: 12 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,32 @@ module github.com/chainguard-dev/terraform-provider-imagetest
go 1.21

require (
github.com/dustinkirkland/golang-petname v0.0.0-20231002161417-6a283f1aaaf2
github.com/google/go-containerregistry v0.17.0
github.com/google/uuid v1.5.0
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-framework v1.4.2
github.com/hashicorp/terraform-plugin-go v0.20.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-testing v1.6.0
golang.org/x/sync v0.5.0
golang.org/x/sync v0.6.0
)

require (
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/cli v24.0.7+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/docker-credential-helpers v0.8.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.16.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
Expand Down Expand Up @@ -83,14 +88,14 @@ require (
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.14.1 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect
google.golang.org/grpc v1.60.1 // indirect
google.golang.org/protobuf v1.32.0 // indirect
)
Loading
Loading