diff --git a/pkg/controller/utils/capability_test.go b/pkg/controller/utils/capability_test.go index 4d8a2cc13..25276deb2 100644 --- a/pkg/controller/utils/capability_test.go +++ b/pkg/controller/utils/capability_test.go @@ -423,6 +423,34 @@ variable "aaa" { config = string })) default = [] +}`, + }, + }, + "configuration is remote with path": { + args: args{ + name: "aws-subnet", + url: "https://github.com/kubevela-contrib/terraform-modules.git", + path: "aws/subnet", + data: []byte(` +variable "aaa" { + type = list(object({ + type = string + sourceArn = string + config = string + })) + default = [] +}`), + variableFile: "variables.tf", + }, + want: want{ + config: ` +variable "aaa" { + type = list(object({ + type = string + sourceArn = string + config = string + })) + default = [] }`, }, }, @@ -454,7 +482,12 @@ variable "aaa" { } patch := ApplyFunc(git.PlainCloneContext, func(ctx context.Context, path string, isBare bool, o *git.CloneOptions) (*git.Repository, error) { - tmpPath := filepath.Join("./tmp/terraform", tc.args.name) + var tmpPath string + if tc.args.path != "" { + tmpPath = filepath.Join("./tmp/terraform", tc.args.name, tc.args.path) + } else { + tmpPath = filepath.Join("./tmp/terraform", tc.args.name) + } err := os.MkdirAll(tmpPath, os.ModePerm) assert.NilError(t, err) err = ioutil.WriteFile(filepath.Clean(filepath.Join(tmpPath, tc.args.variableFile)), tc.args.data, 0644)