From 7e2cee94be894d6e07138a8cfa4adb87181b20f8 Mon Sep 17 00:00:00 2001 From: Marcin Owsiany Date: Thu, 21 Nov 2019 10:14:18 +0100 Subject: [PATCH 1/3] Add a basic Dispatchfile. --- Dispatchfile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Dispatchfile diff --git a/Dispatchfile b/Dispatchfile new file mode 100644 index 000000000..1c7f80ad4 --- /dev/null +++ b/Dispatchfile @@ -0,0 +1,28 @@ +resource "src-git": { + type: "git" + param url: "$(context.git.url)" + param revision: "$(context.git.commit)" +} + +task "test": { + inputs: ["src-git"] + steps: [ + { + name: "test" + image: "kudobuilder/golang:1.13" + command: [ "make", "test" ], + workingDir: "/workspace/src-git" + } + ] +} + +actions: [ + { + tasks: ["test"] + on push branches: ["master"] + }, + { + tasks: ["test"] + on pull_request chatops: ["test"] + } +] \ No newline at end of file From 4a594f90fb322a0fb20295b1aff416713d476a19 Mon Sep 17 00:00:00 2001 From: Marcin Owsiany Date: Thu, 21 Nov 2019 10:14:34 +0100 Subject: [PATCH 2/3] Remove a problematic test. When `go test` itself is being run on a (kind) cluster, this test fails with: ``` W1119 10:50:47.569598 12523 client_config.go:541] Neither --kubeconfig nor --master was specified. Using the inClusterConfig. This might not work. --- FAIL: TestNewK2oClient (0.01s) kudo_test.go:32: assertion failed: expected error to contain "invalid configuration: no configuration has been provided", got operators: customresourcedefinitions.apiextensions.k8s.io "operators.kudo.dev" is forbidden: User "system:serviceaccount:dispatch:local-runner" cannot get resource "customresourcedefinitions" in API group "apiextensions.k8s.io" at the cluster scope ``` This is because of [this special case in `BuildConfigFromFlags`](https://github.com/kubernetes/client-go/blob/571c0ef67034a5e72b9e30e662044b770361641e/tools/clientcmd/client_config.go#L542-L546) which falls back to `restclient.InClusterConfig()` when available. Regardless of whether this config is usable in a `dispatch` kind cluster or not, this special case proves the assumption that this test makes ("it is not possible to create a client without a config") wrong in general. Therefore removing this test altogether seems like the best course of action. --- pkg/kudoctl/util/kudo/kudo_test.go | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/pkg/kudoctl/util/kudo/kudo_test.go b/pkg/kudoctl/util/kudo/kudo_test.go index 8299b3158..ee5de02f4 100644 --- a/pkg/kudoctl/util/kudo/kudo_test.go +++ b/pkg/kudoctl/util/kudo/kudo_test.go @@ -19,20 +19,6 @@ func newTestSimpleK2o() *Client { return NewClientFromK8s(fake.NewSimpleClientset()) } -func TestNewK2oClient(t *testing.T) { - tests := []struct { - err string - }{ - {"invalid configuration: no configuration has been provided"}, // non existing test - } - - for _, tt := range tests { - // Just interested in errors - _, err := NewClient("", 0) - assert.ErrorContains(t, err, tt.err) - } -} - func TestKudoClient_OperatorExistsInCluster(t *testing.T) { obj := v1beta1.Operator{ From 66862da069a74f7a664363dfa51bb2937a48d1b0 Mon Sep 17 00:00:00 2001 From: Marcin Owsiany Date: Mon, 2 Dec 2019 13:04:20 +0100 Subject: [PATCH 3/3] rename --- Dispatchfile => Dispatchfile.cue | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Dispatchfile => Dispatchfile.cue (100%) diff --git a/Dispatchfile b/Dispatchfile.cue similarity index 100% rename from Dispatchfile rename to Dispatchfile.cue