diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9210d7f7..318327f7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -22,10 +22,10 @@ jobs: test: runs-on: ubuntu-18.04 steps: - - name: Set up Go 1.13 + - name: Set up Go 1.15 uses: actions/setup-go@v1 with: - go-version: 1.13 + go-version: 1.15 - name: Check out code into the Go module directory uses: actions/checkout@v1 - name: Test diff --git a/Dockerfile b/Dockerfile index 9f6ce36f..c0c0dec1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ # Build the manager binary -FROM golang:1.13 as builder +FROM golang:1.15 as builder WORKDIR /workspace # Install Helm 3 -RUN bash -c "curl -s https://get.helm.sh/helm-v3.3.1-linux-amd64.tar.gz > helm3.tar.gz" && tar -zxvf helm3.tar.gz linux-amd64/helm && chmod +x linux-amd64/helm && mv linux-amd64/helm /workspace/helm && rm helm3.tar.gz && rm -R linux-amd64 +RUN bash -c "curl -s https://get.helm.sh/helm-v3.5.2-linux-amd64.tar.gz > helm3.tar.gz" && tar -zxvf helm3.tar.gz linux-amd64/helm && chmod +x linux-amd64/helm && mv linux-amd64/helm /workspace/helm && rm helm3.tar.gz && rm -R linux-amd64 # Copy the Go Modules manifests COPY go.mod go.mod diff --git a/pkg/apiserver/registry/account/rest_test.go b/pkg/apiserver/registry/account/rest_test.go index 56af2fbc..a33933d2 100644 --- a/pkg/apiserver/registry/account/rest_test.go +++ b/pkg/apiserver/registry/account/rest_test.go @@ -4,6 +4,7 @@ import ( "context" tenancyv1alpha1 "github.com/loft-sh/kiosk/pkg/apis/tenancy/v1alpha1" rbacv1 "k8s.io/api/rbac/v1" + "sigs.k8s.io/controller-runtime/pkg/client" testingutil "github.com/loft-sh/kiosk/pkg/util/testing" @@ -215,9 +216,17 @@ func TestAccountUpdate(t *testing.T) { userCtx := request.WithUser(ctx, &user.DefaultInfo{Name: "foo"}) accountStorage := NewAccountREST(fakeClient, fakeClient, scheme).(*accountREST) + // Get old account + oldAccount := &configv1alpha1.Account{} + err := fakeClient.Get(ctx, client.ObjectKey{Name: "test"}, oldAccount) + if err != nil { + t.Fatal(err) + } + newObj, updated, err := accountStorage.Update(userCtx, "test", &fakeUpdater{out: &tenancy.Account{ ObjectMeta: metav1.ObjectMeta{ Name: "test", + ResourceVersion: oldAccount.ResourceVersion, Labels: map[string]string{ "Updated": "true", }, diff --git a/pkg/apiserver/registry/space/rest.go b/pkg/apiserver/registry/space/rest.go index 4a068a10..bedce53c 100644 --- a/pkg/apiserver/registry/space/rest.go +++ b/pkg/apiserver/registry/space/rest.go @@ -288,6 +288,13 @@ func (r *spaceStorage) Create(ctx context.Context, obj runtime.Object, createVal return nil, err } + + // wait until we get access + err = r.waitForAccess(ctx, a.GetUser(), namespace) + if err != nil { + // if this happens it is kind of weird, but its not a reason to return an error and abort the request + klog.Infof("error waiting for access to namespace %s for user %s: %v", namespace.Name, a.GetUser().GetName(), err) + } } else { err := r.client.Create(ctx, namespace, &client.CreateOptions{ Raw: options, @@ -297,12 +304,6 @@ func (r *spaceStorage) Create(ctx context.Context, obj runtime.Object, createVal } } - err = r.waitForAccess(ctx, a.GetUser(), namespace) - if err != nil { - // if this happens it is kind of weird, but its not a reason to return an error and abort the request - klog.Infof("error waiting for access to namespace %s for user %s: %v", namespace.Name, a.GetUser().GetName(), err) - } - return ConvertNamespace(namespace), nil } diff --git a/pkg/apiserver/registry/space/rest_test.go b/pkg/apiserver/registry/space/rest_test.go index 060af19a..8584c401 100644 --- a/pkg/apiserver/registry/space/rest_test.go +++ b/pkg/apiserver/registry/space/rest_test.go @@ -3,6 +3,7 @@ package space import ( tenancyv1alpha1 "github.com/loft-sh/kiosk/pkg/apis/tenancy/v1alpha1" rbacv1 "k8s.io/api/rbac/v1" + "sigs.k8s.io/controller-runtime/pkg/client" "testing" "github.com/loft-sh/kiosk/pkg/apis/tenancy" @@ -243,11 +244,17 @@ func TestCreateSpace(t *testing.T) { t.Fatal("Expected error but got nil") } + // Get old account + oldAccount := &configv1alpha1.Account{} + err = fakeClient.Get(ctx, client.ObjectKey{Name: "test"}, oldAccount) + if err != nil { + t.Fatal(err) + } + // Set index value + test := "test" newAccount := &configv1alpha1.Account{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test", - }, + ObjectMeta: oldAccount.ObjectMeta, Spec: configv1alpha1.AccountSpec{ Subjects: []rbacv1.Subject{ { @@ -258,6 +265,7 @@ func TestCreateSpace(t *testing.T) { }, Space: configv1alpha1.AccountSpace{ Limit: &spaceLimit, + ClusterRole: &test, SpaceTemplate: configv1alpha1.AccountSpaceTemplate{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{