provider

package
v0.0.61 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2025 License: MPL-2.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestsResourceDefaultTimeout = "30m"
	TestResourceDefaultTimeout  = "15m"
)
View Source
const (
	ContainerImage = "cgr.dev/chainguard/docker-cli:latest-dev"
)

Variables

This section is empty.

Functions

func DriverResourceSchema added in v0.0.54

func DriverResourceSchema(ctx context.Context) schema.SingleNestedAttribute

func New

func New(version string) func() provider.Provider

func NewContainerVolumeResource added in v0.0.14

func NewContainerVolumeResource() resource.Resource

func NewFeatureResource

func NewFeatureResource() resource.Resource

func NewHarnessDockerResource added in v0.0.15

func NewHarnessDockerResource() resource.Resource

func NewHarnessK3sResource

func NewHarnessK3sResource() resource.Resource

func NewHarnessPterraformResource added in v0.0.29

func NewHarnessPterraformResource() resource.Resource

func NewInventoryDataSource added in v0.0.2

func NewInventoryDataSource() datasource.DataSource

func NewTestDockerRunResource added in v0.0.41

func NewTestDockerRunResource() resource.Resource

func NewTestsResource added in v0.0.54

func NewTestsResource() resource.Resource

func ParseResources added in v0.0.20

func ParseResources(resources *ContainerResources) (docker.ResourcesRequest, error)

ParseResources parses the ContainerResources object into a provider.ContainerResourcesRequest object.

Types

type BaseHarnessResource added in v0.0.29

type BaseHarnessResource struct {
	framework.WithNoOpDelete
	framework.WithNoOpRead
	// contains filtered or unexported fields
}

BaseHarnessResource provides common methods for all BaseHarnessResource implementations.

func (*BaseHarnessResource) Configure added in v0.0.29

func (*BaseHarnessResource) ModifyPlan added in v0.0.29

ModifyPlan adds the harness to the inventory during both the plan and apply phase. This uses the more verbose GetAttribute() instead of Get() because terraform-plugin-framework does not support embedding models without nesting.

type BaseHarnessResourceModel added in v0.0.29

type BaseHarnessResourceModel struct {
	Id        types.String             `tfsdk:"id"`
	Name      types.String             `tfsdk:"name"`
	Inventory InventoryDataSourceModel `tfsdk:"inventory"`
	Timeouts  timeouts.Value           `tfsdk:"timeouts"`
}

type ContainerCpuResources added in v0.0.20

type ContainerCpuResources struct {
	Request types.String `tfsdk:"request"`
	Limit   types.String `tfsdk:"limit"`
}

type ContainerLayerModel added in v0.0.41

type ContainerLayerModel struct {
	Source types.String `tfsdk:"source"`
	Target types.String `tfsdk:"target"`
}

type ContainerMemoryResources added in v0.0.18

type ContainerMemoryResources struct {
	Request types.String `tfsdk:"request"`
	Limit   types.String `tfsdk:"limit"`
}

type ContainerMountModel added in v0.0.29

type ContainerMountModel struct {
	Source      types.String `tfsdk:"source"`
	Destination types.String `tfsdk:"destination"`
	ReadOnly    types.Bool   `tfsdk:"read_only"`
}

type ContainerNetworkModel added in v0.0.29

type ContainerNetworkModel struct {
	Name types.String `tfsdk:"name"`
}

type ContainerResources added in v0.0.18

type ContainerResources struct {
	Memory *ContainerMemoryResources `tfsdk:"memory"`
	Cpu    *ContainerCpuResources    `tfsdk:"cpu"`
}

type ContainerVolumeResource added in v0.0.14

type ContainerVolumeResource struct {
	framework.WithTypeName
	BaseHarnessResource
}

func (*ContainerVolumeResource) Create added in v0.0.14

func (*ContainerVolumeResource) Schema added in v0.0.14

func (*ContainerVolumeResource) Update added in v0.0.14

type ContainerVolumeResourceModel added in v0.0.14

type ContainerVolumeResourceModel struct {
	Id        types.String             `tfsdk:"id"`
	Name      types.String             `tfsdk:"name"`
	Inventory InventoryDataSourceModel `tfsdk:"inventory"`
}

type DockerInDockerDriverResourceModel added in v0.0.54

type DockerInDockerDriverResourceModel struct {
	Image types.String `tfsdk:"image"`
}

type DockerRegistryResourceModel added in v0.0.17

type DockerRegistryResourceModel struct {
	Auth *RegistryResourceAuthModel `tfsdk:"auth"`
}

type DriverResourceModel added in v0.0.54

type DriverResourceModel string
const (
	DriverK3sInDocker    DriverResourceModel = "k3s_in_docker"
	DriverDockerInDocker DriverResourceModel = "docker_in_docker"
	DriverEKSWithEksctl  DriverResourceModel = "eks_with_eksctl"
)

type EKSWithEksctlDriverResourceModel added in v0.0.56

type EKSWithEksctlDriverResourceModel struct{}

type FeatureHarnessResourceModel added in v0.0.2

type FeatureHarnessResourceModel struct {
	Id        types.String             `tfsdk:"id"`
	Name      types.String             `tfsdk:"name"`
	Inventory InventoryDataSourceModel `tfsdk:"inventory"`
}

FeatureHarnessResourceModel is the common data model all harnesses output to be passed into dependent features.

type FeatureHarnessVolumeMountModel added in v0.0.14

type FeatureHarnessVolumeMountModel struct {
	Source      ContainerVolumeResourceModel `tfsdk:"source"`
	Destination string                       `tfsdk:"destination"`
}

type FeatureResource

type FeatureResource struct {
	framework.WithTypeName
	framework.WithNoOpRead
	framework.WithNoOpDelete
	// contains filtered or unexported fields
}

FeatureResource defines the resource implementation.

func (*FeatureResource) Configure

func (*FeatureResource) Create

func (*FeatureResource) ModifyPlan added in v0.0.2

ModifyPlan implements resource.ResourceWithModifyPlan.

func (*FeatureResource) Schema

func (*FeatureResource) Update

type FeatureResourceModel

type FeatureResourceModel struct {
	Id            types.String       `tfsdk:"id"`
	Name          types.String       `tfsdk:"name"`
	Description   types.String       `tfsdk:"description"`
	Labels        types.Map          `tfsdk:"labels"`
	Before        []FeatureStepModel `tfsdk:"before"`
	After         []FeatureStepModel `tfsdk:"after"`
	Steps         []FeatureStepModel `tfsdk:"steps"`
	Timeouts      timeouts.Value     `tfsdk:"timeouts"`
	Skipped       types.String       `tfsdk:"skipped"`
	WarnOnFailure types.Bool         `tfsdk:"warn_on_failure"`

	Harness FeatureHarnessResourceModel `tfsdk:"harness"`
}

FeatureResourceModel describes the resource data model.

type FeatureStepBackoffModel added in v0.0.10

type FeatureStepBackoffModel struct {
	Attempts types.Int64   `tfsdk:"attempts"`
	Delay    types.String  `tfsdk:"delay"`
	Factor   types.Float64 `tfsdk:"factor"`
}

type FeatureStepModel

type FeatureStepModel struct {
	Name    types.String             `tfsdk:"name"`
	Cmd     types.String             `tfsdk:"cmd"`
	Workdir types.String             `tfsdk:"workdir"`
	Retry   *FeatureStepBackoffModel `tfsdk:"retry"`
}

type HarnessContainerEnvs added in v0.0.29

type HarnessContainerEnvs map[string]string

func (HarnessContainerEnvs) Slice added in v0.0.29

func (e HarnessContainerEnvs) Slice() []string

type HarnessDockerResource added in v0.0.15

type HarnessDockerResource struct {
	framework.WithTypeName
	BaseHarnessResource
}

HarnessDockerResource defines the resource implementation.

func (*HarnessDockerResource) Create added in v0.0.15

func (*HarnessDockerResource) Schema added in v0.0.15

func (*HarnessDockerResource) Update added in v0.0.15

type HarnessDockerResourceModel added in v0.0.15

type HarnessDockerResourceModel struct {
	BaseHarnessResourceModel

	Image        types.String                           `tfsdk:"image"`
	Volumes      []FeatureHarnessVolumeMountModel       `tfsdk:"volumes"`
	Privileged   types.Bool                             `tfsdk:"privileged"`
	Envs         *HarnessContainerEnvs                  `tfsdk:"envs"`
	Mounts       []ContainerMountModel                  `tfsdk:"mounts"`
	Layers       []ContainerLayerModel                  `tfsdk:"layers"`
	Packages     []string                               `tfsdk:"packages"`
	Repositories []string                               `tfsdk:"repositories"`
	Keyrings     []string                               `tfsdk:"keyrings"`
	Networks     map[string]ContainerNetworkModel       `tfsdk:"networks"`
	Registries   map[string]DockerRegistryResourceModel `tfsdk:"registries"`
	Resources    *ContainerResources                    `tfsdk:"resources"`
}

HarnessDockerResourceModel describes the resource data model.

type HarnessHooksModel added in v0.0.24

type HarnessHooksModel struct {
	PreStart  types.List `tfsdk:"pre_start"`
	PostStart types.List `tfsdk:"post_start"`
}

type HarnessK3sResource

type HarnessK3sResource struct {
	framework.WithTypeName
	BaseHarnessResource
}

HarnessK3sResource defines the resource implementation.

func (*HarnessK3sResource) Create

func (*HarnessK3sResource) Schema

func (*HarnessK3sResource) Update

type HarnessK3sResourceModel

type HarnessK3sResourceModel struct {
	BaseHarnessResourceModel

	Image                types.String                     `tfsdk:"image"`
	DisableCni           types.Bool                       `tfsdk:"disable_cni"`
	DisableNetworkPolicy types.Bool                       `tfsdk:"disable_network_policy"`
	DisableTraefik       types.Bool                       `tfsdk:"disable_traefik"`
	DisableMetricsServer types.Bool                       `tfsdk:"disable_metrics_server"`
	Registries           map[string]RegistryResourceModel `tfsdk:"registries"`
	Networks             map[string]ContainerNetworkModel `tfsdk:"networks"`
	Sandbox              *HarnessK3sSandboxResourceModel  `tfsdk:"sandbox"`
	Resources            *ContainerResources              `tfsdk:"resources"`
	Hooks                *HarnessHooksModel               `tfsdk:"hooks"`
	KubeletConfig        types.String                     `tfsdk:"kubelet_config"`
}

HarnessK3sResourceModel describes the resource data model.

type HarnessK3sSandboxResourceModel added in v0.0.3

type HarnessK3sSandboxResourceModel struct {
	Image        types.String                     `tfsdk:"image"`
	Privileged   types.Bool                       `tfsdk:"privileged"`
	Envs         map[string]string                `tfsdk:"envs"`
	Mounts       []ContainerMountModel            `tfsdk:"mounts"`
	Layers       []ContainerLayerModel            `tfsdk:"layers"`
	Networks     map[string]ContainerNetworkModel `tfsdk:"networks"`
	Packages     []string                         `tfsdk:"packages"`
	Repositories []string                         `tfsdk:"repositories"`
	Keyrings     []string                         `tfsdk:"keyrings"`
}

type HarnessPterraformResource added in v0.0.29

type HarnessPterraformResource struct {
	framework.WithTypeName
	BaseHarnessResource
}

func (*HarnessPterraformResource) Create added in v0.0.29

func (*HarnessPterraformResource) Schema added in v0.0.29

func (*HarnessPterraformResource) Update added in v0.0.29

type HarnessPterraformResourceModel added in v0.0.29

type HarnessPterraformResourceModel struct {
	Id        types.String             `tfsdk:"id"`
	Name      types.String             `tfsdk:"name"`
	Inventory InventoryDataSourceModel `tfsdk:"inventory"`
	Timeouts  timeouts.Value           `tfsdk:"timeouts"`

	Path types.String `tfsdk:"path"`
	Vars types.String `tfsdk:"vars"`
}

type ImageTestProvider

type ImageTestProvider struct {
	// contains filtered or unexported fields
}

ImageTestProvider defines the provider implementation.

func (*ImageTestProvider) Configure

func (*ImageTestProvider) DataSources

func (p *ImageTestProvider) DataSources(ctx context.Context) []func() datasource.DataSource

func (*ImageTestProvider) Metadata

func (*ImageTestProvider) Resources

func (p *ImageTestProvider) Resources(_ context.Context) []func() resource.Resource

func (*ImageTestProvider) Schema

type ImageTestProviderHarnessModel

type ImageTestProviderHarnessModel struct {
	K3s     *ProviderHarnessK3sModel     `tfsdk:"k3s"`
	Docker  *ProviderHarnessDockerModel  `tfsdk:"docker"`
	Cluster *ProviderHarnessClusterModel `tfsdk:"cluster"`
}

type ImageTestProviderModel

type ImageTestProviderModel struct {
	Harnesses     *ImageTestProviderHarnessModel `tfsdk:"harnesses"`
	TestExecution *ProviderTestExecutionModel    `tfsdk:"test_execution"`
	Repo          types.String                   `tfsdk:"repo"`
	ExtraRepos    []string                       `tfsdk:"extra_repos"`
	Sandbox       *ProviderSandboxModel          `tfsdk:"sandbox"`
}

ImageTestProviderModel describes the provider data model.

type InventoryDataSource added in v0.0.2

type InventoryDataSource struct {
	// contains filtered or unexported fields
}

InventoryDataSource defines the data source implementation.

func (*InventoryDataSource) Configure added in v0.0.2

func (*InventoryDataSource) Metadata added in v0.0.2

func (*InventoryDataSource) Read added in v0.0.2

func (*InventoryDataSource) Schema added in v0.0.2

type InventoryDataSourceModel added in v0.0.2

type InventoryDataSourceModel struct {
	Seed types.String `tfsdk:"seed"`
}

InventoryDataSourceModel describes the data source data model.

type K3sInDockerDriverRegistriesMirrorResourceModel added in v0.0.54

type K3sInDockerDriverRegistriesMirrorResourceModel struct {
	Endpoints []string `tfsdk:"endpoints"`
}

type K3sInDockerDriverRegistriesResourceModel added in v0.0.54

type K3sInDockerDriverRegistriesResourceModel struct {
	Mirrors *K3sInDockerDriverRegistriesMirrorResourceModel `tfsdk:"mirrors"`
}

type K3sInDockerDriverResourceModel added in v0.0.54

type K3sInDockerDriverResourceModel struct {
	Image         types.String                                         `tfsdk:"image"`
	Cni           types.Bool                                           `tfsdk:"cni"`
	NetworkPolicy types.Bool                                           `tfsdk:"network_policy"`
	Traefik       types.Bool                                           `tfsdk:"traefik"`
	MetricsServer types.Bool                                           `tfsdk:"metrics_server"`
	Registries    map[string]*K3sInDockerDriverRegistriesResourceModel `tfsdk:"registries"`
}

type ProviderHarnessClusterModel added in v0.0.26

type ProviderHarnessClusterModel struct {
	Kubeconfig *string `tfsdk:"kubeconfig"`
}

type ProviderHarnessDockerModel added in v0.0.15

type ProviderHarnessDockerModel struct {
	HostSocketPath *string                                `tfsdk:"host_socket_path"`
	Networks       map[string]ContainerNetworkModel       `tfsdk:"networks"`
	Envs           *HarnessContainerEnvs                  `tfsdk:"envs"`
	Mounts         []ContainerMountModel                  `tfsdk:"mounts"`
	Registries     map[string]DockerRegistryResourceModel `tfsdk:"registries"`
}

type ProviderHarnessK3sModel

type ProviderHarnessK3sModel struct {
	Networks   map[string]ContainerNetworkModel `tfsdk:"networks"`
	Registries map[string]RegistryResourceModel `tfsdk:"registries"`
}

type ProviderSandboxModel added in v0.0.37

type ProviderSandboxModel struct {
	ExtraRepos    []string `tfsdk:"extra_repos"`
	ExtraKeyrings []string `tfsdk:"extra_keyrings"`
	ExtraPackages []string `tfsdk:"extra_packages"`
}

type ProviderStore

type ProviderStore struct {
	// contains filtered or unexported fields
}

ProviderStore manages the global runtime state of the provider. The provider uses this to look up the defined relationships between resources, and manage shared external state.

func NewProviderStore

func NewProviderStore(repo name.Repository) (*ProviderStore, error)

func (*ProviderStore) Encode added in v0.0.2

func (s *ProviderStore) Encode(components ...string) (string, error)

func (*ProviderStore) Logger added in v0.0.2

func (s *ProviderStore) Logger(ctx context.Context, inv InventoryDataSourceModel, withs ...any) (context.Context, error)

Logger initializes the context logger for the given inventory.

func (*ProviderStore) SkipTeardown added in v0.0.8

func (s *ProviderStore) SkipTeardown() bool

SkipTeardown returns true if harnesses should skip teardown steps.

type ProviderTestExecutionModel added in v0.0.37

type ProviderTestExecutionModel struct {
	SkipAll      types.Bool `tfsdk:"skip_all_tests"`
	SkipTeardown types.Bool `tfsdk:"skip_teardown"`
	Include      types.Map  `tfsdk:"include_by_label"`
	Exclude      types.Map  `tfsdk:"exclude_by_label"`
}

type RegistryResourceAuthModel

type RegistryResourceAuthModel struct {
	Username types.String `tfsdk:"username"`
	Password types.String `tfsdk:"password"`
	Auth     types.String `tfsdk:"auth"`
}

type RegistryResourceMirrorModel

type RegistryResourceMirrorModel struct {
	Endpoints types.List `tfsdk:"endpoints"`
}

type RegistryResourceModel

type RegistryResourceModel struct {
	Auth   *RegistryResourceAuthModel   `tfsdk:"auth"`
	Tls    *RegistryResourceTlsModel    `tfsdk:"tls"`
	Mirror *RegistryResourceMirrorModel `tfsdk:"mirror"`
}

type RegistryResourceTlsModel

type RegistryResourceTlsModel struct {
	CertFile types.String `tfsdk:"cert_file"`
	KeyFile  types.String `tfsdk:"key_file"`
	CaFile   types.String `tfsdk:"ca_file"`
}

type TestContentResourceModel added in v0.0.54

type TestContentResourceModel struct {
	Source types.String `tfsdk:"source"`
	Target types.String `tfsdk:"target"`
}

type TestDockerRunResource added in v0.0.41

type TestDockerRunResource struct {
	framework.WithTypeName
	framework.WithNoOpRead
	framework.WithNoOpDelete
	// contains filtered or unexported fields
}

TestDockerRunResource defines the resource implementation.

func (*TestDockerRunResource) Configure added in v0.0.41

func (*TestDockerRunResource) Create added in v0.0.41

func (*TestDockerRunResource) Schema added in v0.0.41

func (*TestDockerRunResource) Update added in v0.0.41

type TestDockerRunResourceModel added in v0.0.41

type TestDockerRunResourceModel struct {
	Name        types.String   `tfsdk:"name"`
	Description types.String   `tfsdk:"description"`
	Labels      types.Map      `tfsdk:"labels"`
	Timeouts    timeouts.Value `tfsdk:"timeouts"`
	Skipped     types.String   `tfsdk:"skipped"`

	Cid        types.String          `tfsdk:"cid"`
	Result     types.String          `tfsdk:"result"`
	Image      types.String          `tfsdk:"image"`
	Entrypoint []string              `tfsdk:"entrypoint"`
	Cmd        []string              `tfsdk:"cmd"`
	Mounts     []ContainerMountModel `tfsdk:"mounts"`
	User       types.String          `tfsdk:"user"`
}

TestDockerRunResourceModel describes the resource data model.

type TestResourceModel added in v0.0.54

type TestResourceModel struct {
	Name    types.String               `tfsdk:"name"`
	Image   types.String               `tfsdk:"image"`
	Content []TestContentResourceModel `tfsdk:"content"`
	Envs    map[string]string          `tfsdk:"envs"`
	Cmd     types.String               `tfsdk:"cmd"`
	Timeout types.String               `tfsdk:"timeout"`
}

type TestResult added in v0.0.41

type TestResult string
const (
	TestResultPass TestResult = "PASS"
	TestResultFail TestResult = "FAIL"
)

type TestsDriversResourceModel added in v0.0.54

type TestsDriversResourceModel struct {
	K3sInDocker    *K3sInDockerDriverResourceModel    `tfsdk:"k3s_in_docker"`
	DockerInDocker *DockerInDockerDriverResourceModel `tfsdk:"docker_in_docker"`
	EKSWithEksctl  *EKSWithEksctlDriverResourceModel  `tfsdk:"eks_with_eksctl"`
}

type TestsImageResource added in v0.0.54

type TestsImageResource map[string]string

func (TestsImageResource) Resolve added in v0.0.54

func (t TestsImageResource) Resolve() (map[string]TestsImagesParsed, error)

type TestsImagesParsed added in v0.0.54

type TestsImagesParsed struct {
	Registry     string `json:"registry"`
	Repo         string `json:"repo"`
	RegistryRepo string `json:"registry_repo"`
	Digest       string `json:"digest"`
	PseudoTag    string `json:"pseudo_tag"`
	Ref          string `json:"ref"`
}

type TestsResource added in v0.0.54

type TestsResource struct {
	framework.WithTypeName
	framework.WithNoOpDelete
	framework.WithNoOpRead
	// contains filtered or unexported fields
}

func (*TestsResource) Configure added in v0.0.54

func (*TestsResource) Create added in v0.0.54

func (TestsResource) LoadDriver added in v0.0.54

func (*TestsResource) Schema added in v0.0.54

func (*TestsResource) Update added in v0.0.54

type TestsResourceModel added in v0.0.54

type TestsResourceModel struct {
	Id           types.String               `tfsdk:"id"`
	Name         types.String               `tfsdk:"name"`
	Driver       DriverResourceModel        `tfsdk:"driver"`
	Drivers      *TestsDriversResourceModel `tfsdk:"drivers"`
	Images       TestsImageResource         `tfsdk:"images"`
	Tests        []TestResourceModel        `tfsdk:"tests"`
	Timeout      types.String               `tfsdk:"timeout"`
	Labels       map[string]string          `tfsdk:"labels"`
	Skipped      types.Bool                 `tfsdk:"skipped"`
	RepoOverride types.String               `tfsdk:"repo"`
}

Directories

Path Synopsis
Package framework contains code related to the Terraform Plugin Framework.
Package framework contains code related to the Terraform Plugin Framework.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL