Repository: crossplane-contrib/provider-terraform (go)

Issue:
Update terraform base image to version 1.2.3
### What happened?
The provider base image is running terraform version 1.0.1 which is over a year old.  The latest release is v1.2.3 which has a large number of fixes and updates that might be helpful.

This issue tracks the update of the base image to v1.2.3

Pull request:
Update base terraform image to v1.2.3 (#65)
Signed-off-by: Bob Haddleton <bob.haddleton@nokia.com>

### Description of your changes
Update the base terraform image to v1.2.3

Fixes #65 

I have:

- [X] Read and followed Crossplane's [contribution process].
- [X] Run `make reviewable test` to ensure this PR is ready for review.

### How has this code been tested
It has been running in our dev environment for 2 days

[contribution process]: https://git.io/fj2m9


Patch:
diff --git a/cluster/images/provider-terraform-controller/Makefile b/cluster/images/provider-terraform-controller/Makefile
index 4998d6c..6d89058 100755
--- a/cluster/images/provider-terraform-controller/Makefile
+++ b/cluster/images/provider-terraform-controller/Makefile
@@ -6,7 +6,7 @@ include ../../../build/makelib/common.mk
 
 # ====================================================================================
 #  Options
-OSBASEIMAGE = hashicorp/terraform:1.0.1
+OSBASEIMAGE = hashicorp/terraform:1.2.3
 IMAGE = $(BUILD_REGISTRY)/provider-terraform-controller-$(ARCH)
 include ../../../build/makelib/image.mk
 
diff --git a/go.mod b/go.mod
index 4fc5e7f..936d43c 100644
--- a/go.mod
+++ b/go.mod
@@ -6,6 +6,7 @@ require (
 	github.com/crossplane/crossplane-runtime v0.14.0
 	github.com/crossplane/crossplane-tools v0.0.0-20201201125637-9ddc70edfd0d
 	github.com/google/go-cmp v0.5.2
+	github.com/google/uuid v1.1.2
 	github.com/hashicorp/go-getter v1.4.0
 	github.com/pkg/errors v0.9.1
 	github.com/spf13/afero v1.5.1
@@ -39,7 +40,6 @@ require (
 	github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
 	github.com/golang/protobuf v1.4.3 // indirect
 	github.com/google/gofuzz v1.1.0 // indirect
-	github.com/google/uuid v1.1.2 // indirect
 	github.com/googleapis/gax-go/v2 v2.0.5 // indirect
 	github.com/googleapis/gnostic v0.5.1 // indirect
 	github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
diff --git a/internal/workdir/workdir.go b/internal/workdir/workdir.go
index 3866c65..6e59571 100644
--- a/internal/workdir/workdir.go
+++ b/internal/workdir/workdir.go
@@ -22,11 +22,13 @@ import (
 	"strings"
 	"time"
 
-	"github.com/crossplane-contrib/provider-terraform/apis/v1alpha1"
 	"github.com/crossplane/crossplane-runtime/pkg/logging"
+	"github.com/google/uuid"
 	"github.com/pkg/errors"
 	"github.com/spf13/afero"
 	"sigs.k8s.io/controller-runtime/pkg/client"
+
+	"github.com/crossplane-contrib/provider-terraform/apis/v1alpha1"
 )
 
 // Error strings.
@@ -99,6 +101,11 @@ func (gc *GarbageCollector) Run(ctx context.Context) {
 	}
 }
 
+func isUUID(u string) bool {
+	_, err := uuid.Parse(u)
+	return err == nil
+}
+
 func (gc *GarbageCollector) collect(ctx context.Context) error {
 	l := &v1alpha1.WorkspaceList{}
 	if err := gc.kube.List(ctx, l); err != nil {
@@ -109,7 +116,6 @@ func (gc *GarbageCollector) collect(ctx context.Context) error {
 	for _, ws := range l.Items {
 		exists[string(ws.GetUID())] = true
 	}
-
 	fis, err := gc.fs.ReadDir(gc.parentDir)
 	if err != nil {
 		return errors.Wrapf(err, errFmtReadDir, gc.parentDir)
@@ -117,7 +123,7 @@ func (gc *GarbageCollector) collect(ctx context.Context) error {
 
 	failed := make([]string, 0)
 	for _, fi := range fis {
-		if !fi.IsDir() {
+		if !fi.IsDir() || !isUUID(fi.Name()) {
 			continue
 		}
 		if exists[fi.Name()] {


Test patch:
diff --git a/internal/workdir/workdir_test.go b/internal/workdir/workdir_test.go
index 59e3860..cadd9f3 100644
--- a/internal/workdir/workdir_test.go
+++ b/internal/workdir/workdir_test.go
@@ -102,21 +102,23 @@ func TestCollect(t *testing.T) {
 			fields: fields{
 				kube: &test.MockClient{MockList: test.NewMockListFn(nil, func(obj client.ObjectList) error {
 					*obj.(*v1alpha1.WorkspaceList) = v1alpha1.WorkspaceList{Items: []v1alpha1.Workspace{
-						{ObjectMeta: metav1.ObjectMeta{UID: types.UID("a")}},
-						{ObjectMeta: metav1.ObjectMeta{UID: types.UID("b")}},
+						{ObjectMeta: metav1.ObjectMeta{UID: types.UID("8371dd9e-dd3f-4a42-bd8c-340c4744f6de")}},
+						{ObjectMeta: metav1.ObjectMeta{UID: types.UID("ebaac629-43a3-4b39-8138-d7ac19cafe11")}},
 					}}
 					return nil
 				})},
 				parentdDir: parentDir,
 				fs: withDirs(afero.Afero{Fs: afero.NewMemMapFs()},
 					parentDir,
-					filepath.Join(parentDir, "a"),
-					filepath.Join(parentDir, "b"),
-					filepath.Join(parentDir, "c"),
+					filepath.Join(parentDir, "8371dd9e-dd3f-4a42-bd8c-340c4744f6de"),
+					filepath.Join(parentDir, "ebaac629-43a3-4b39-8138-d7ac19cafe11"),
+					filepath.Join(parentDir, "0d177133-1a2f-4ce2-93d2-f8212d3344e7"),
+					filepath.Join(parentDir, "helm"),
+					filepath.Join(parentDir, "registry.terraform.io"),
 				),
 			},
 			want: want{
-				dirs: []string{"a", "b"},
+				dirs: []string{"8371dd9e-dd3f-4a42-bd8c-340c4744f6de", "ebaac629-43a3-4b39-8138-d7ac19cafe11", "helm", "registry.terraform.io"},
 			},
 		},
 	}