Skip to content

Commit

Permalink
Update mocks & README
Browse files Browse the repository at this point in the history
  • Loading branch information
bdwyertech authored and ytsarev committed Apr 3, 2024
1 parent 92bc309 commit 4fdad62
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions internal/controller/workspace/workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 },
}
Expand Down Expand Up @@ -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 },
}
Expand Down Expand Up @@ -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 },
}
Expand Down Expand Up @@ -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 },
}
Expand Down Expand Up @@ -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 },
}
Expand Down Expand Up @@ -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 },
}
Expand Down Expand Up @@ -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 },
}
Expand Down Expand Up @@ -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 },
}
Expand Down Expand Up @@ -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 }}
},
},
Expand All @@ -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 },
Expand All @@ -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 },
}
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down

0 comments on commit 4fdad62

Please sign in to comment.