diff --git a/README.md b/README.md index a06241f..5f32fbd 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,15 @@ spec: # Use any module source supported by terraform init -from-module. source: Remote module: https://github.com/crossplane/tf + # Environment variables can be passed through + env: + - name: TFENV_TERRAFORM_VERSION + value: '1.3.5' + - name: ENV_FROM_CONFIGMAP + configMapKeyRef: + namespace: my-namespace + name: my-config-map + key: target-key # Variables can be specified inline as a list of key-value pairs or as an json object, or loaded from a ConfigMap or Secret. vars: - key: region diff --git a/internal/controller/workspace/workspace_test.go b/internal/controller/workspace/workspace_test.go index 9c0cff7..1a54b8b 100644 --- a/internal/controller/workspace/workspace_test.go +++ b/internal/controller/workspace/workspace_test.go @@ -124,7 +124,7 @@ func TestConnect(t *testing.T) { kube client.Client usage resource.Tracker fs afero.Afero - terraform func(dir string, usePluginCache bool) tfclient + terraform func(dir string, usePluginCache bool, envs ...string) tfclient } type args struct { @@ -216,7 +216,7 @@ func TestConnect(t *testing.T) { }, usage: resource.TrackerFn(func(_ context.Context, _ resource.Managed) error { return nil }), fs: afero.Afero{Fs: afero.NewMemMapFs()}, - terraform: func(_ string, _ bool) tfclient { + terraform: func(_ string, _ bool, _ ...string) tfclient { return &MockTf{ MockInit: func(ctx context.Context, o ...terraform.InitOption) error { return nil }, } @@ -255,7 +255,7 @@ func TestConnect(t *testing.T) { errs: map[string]error{filepath.Join(tfDir, string(uid), tfCreds): errBoom}, }, }, - terraform: func(_ string, _ bool) tfclient { + terraform: func(_ string, _ bool, _ ...string) tfclient { return &MockTf{ MockInit: func(ctx context.Context, o ...terraform.InitOption) error { return nil }, } @@ -294,7 +294,7 @@ func TestConnect(t *testing.T) { errs: map[string]error{filepath.Join(tfDir, string(uid), "subdir", tfCreds): errBoom}, }, }, - terraform: func(_ string, _ bool) tfclient { + terraform: func(_ string, _ bool, _ ...string) tfclient { return &MockTf{ MockInit: func(ctx context.Context, o ...terraform.InitOption) error { return nil }, } @@ -338,7 +338,7 @@ func TestConnect(t *testing.T) { errs: map[string]error{filepath.Join("/tmp", tfDir, string(uid), ".git-credentials"): errBoom}, }, }, - terraform: func(_ string, _ bool) tfclient { + terraform: func(_ string, _ bool, _ ...string) tfclient { return &MockTf{ MockInit: func(ctx context.Context, o ...terraform.InitOption) error { return nil }, } @@ -381,7 +381,7 @@ func TestConnect(t *testing.T) { errs: map[string]error{filepath.Join("/tmp", tfDir, string(uid)): errBoom}, }, }, - terraform: func(_ string, _ bool) tfclient { + terraform: func(_ string, _ bool, _ ...string) tfclient { return &MockTf{ MockInit: func(ctx context.Context, o ...terraform.InitOption) error { return nil }, } @@ -422,7 +422,7 @@ func TestConnect(t *testing.T) { errs: map[string]error{filepath.Join(tfDir, string(uid), tfConfig): errBoom}, }, }, - terraform: func(_ string, _ bool) tfclient { + terraform: func(_ string, _ bool, _ ...string) tfclient { return &MockTf{ MockInit: func(ctx context.Context, o ...terraform.InitOption) error { return nil }, } @@ -463,7 +463,7 @@ func TestConnect(t *testing.T) { errs: map[string]error{filepath.Join(tfDir, string(uid), "subdir", tfConfig): errBoom}, }, }, - terraform: func(_ string, _ bool) tfclient { + terraform: func(_ string, _ bool, _ ...string) tfclient { return &MockTf{ MockInit: func(ctx context.Context, o ...terraform.InitOption) error { return nil }, } @@ -499,7 +499,7 @@ func TestConnect(t *testing.T) { errs: map[string]error{filepath.Join(tfDir, string(uid), tfMain): errBoom}, }, }, - terraform: func(_ string, _ bool) tfclient { + terraform: func(_ string, _ bool, _ ...string) tfclient { return &MockTf{ MockInit: func(ctx context.Context, o ...terraform.InitOption) error { return nil }, } @@ -529,7 +529,7 @@ func TestConnect(t *testing.T) { }, usage: resource.TrackerFn(func(_ context.Context, _ resource.Managed) error { return nil }), fs: afero.Afero{Fs: afero.NewMemMapFs()}, - terraform: func(_ string, _ bool) tfclient { + terraform: func(_ string, _ bool, _ ...string) tfclient { return &MockTf{MockInit: func(_ context.Context, _ ...terraform.InitOption) error { return errBoom }} }, }, @@ -553,7 +553,7 @@ func TestConnect(t *testing.T) { }, usage: resource.TrackerFn(func(_ context.Context, _ resource.Managed) error { return nil }), fs: afero.Afero{Fs: afero.NewMemMapFs()}, - terraform: func(_ string, _ bool) tfclient { + terraform: func(_ string, _ bool, _ ...string) tfclient { return &MockTf{ MockInit: func(ctx context.Context, o ...terraform.InitOption) error { return nil }, MockWorkspace: func(_ context.Context, _ string) error { return errBoom }, @@ -579,7 +579,7 @@ func TestConnect(t *testing.T) { }, usage: resource.TrackerFn(func(_ context.Context, _ resource.Managed) error { return nil }), fs: afero.Afero{Fs: afero.NewMemMapFs()}, - terraform: func(_ string, _ bool) tfclient { + terraform: func(_ string, _ bool, _ ...string) tfclient { return &MockTf{ MockGenerateChecksum: func(ctx context.Context) (string, error) { return "", errBoom }, } @@ -613,7 +613,7 @@ func TestConnect(t *testing.T) { }, usage: resource.TrackerFn(func(_ context.Context, _ resource.Managed) error { return nil }), fs: afero.Afero{Fs: afero.NewMemMapFs()}, - terraform: func(_ string, _ bool) tfclient { + terraform: func(_ string, _ bool, _ ...string) tfclient { return &MockTf{ MockGenerateChecksum: func(ctx context.Context) (string, error) { return tfChecksum, nil }, MockWorkspace: func(_ context.Context, _ string) error { return nil }, @@ -649,7 +649,7 @@ func TestConnect(t *testing.T) { }, usage: resource.TrackerFn(func(_ context.Context, _ resource.Managed) error { return nil }), fs: afero.Afero{Fs: afero.NewMemMapFs()}, - terraform: func(_ string, _ bool) tfclient { + terraform: func(_ string, _ bool, _ ...string) tfclient { return &MockTf{ MockInit: func(ctx context.Context, o ...terraform.InitOption) error { return nil }, MockGenerateChecksum: func(ctx context.Context) (string, error) { return tfChecksum, nil },