From 7517a0a2d1c0cfadb62b44d88f21bb2db15c5f31 Mon Sep 17 00:00:00 2001 From: David Zager Date: Wed, 10 Jul 2019 16:31:22 -0400 Subject: [PATCH 1/2] ansible: Use operator-sdk's dynamic restmapper This makes it possible for ansible based operators to interact with CRDs that didn't exist when the operator started. fixes #1330 --- pkg/ansible/run.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/ansible/run.go b/pkg/ansible/run.go index 3f4e5efce23..6be6dd7a047 100644 --- a/pkg/ansible/run.go +++ b/pkg/ansible/run.go @@ -27,6 +27,7 @@ import ( "github.com/operator-framework/operator-sdk/pkg/k8sutil" "github.com/operator-framework/operator-sdk/pkg/leader" "github.com/operator-framework/operator-sdk/pkg/metrics" + "github.com/operator-framework/operator-sdk/pkg/restmapper" sdkVersion "github.com/operator-framework/operator-sdk/version" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -71,6 +72,7 @@ func Run(flags *aoflags.AnsibleOperatorFlags) error { // TODO: probably should expose the host & port as an environment variables mgr, err := manager.New(cfg, manager.Options{ Namespace: namespace, + MapperProvider: restmapper.NewDynamicRESTMapper, MetricsBindAddress: fmt.Sprintf("0.0.0.0:%d", metricsPort), }) if err != nil { From b0f756dabcc253fb91e655b4dbd55693a8613147 Mon Sep 17 00:00:00 2001 From: David Zager Date: Wed, 10 Jul 2019 16:36:38 -0400 Subject: [PATCH 2/2] Remove testdata from watches test on completion Before this change a `make test` would leave around testdata you wouldn't want to put in version control. This change just updates the watches test to defer os.Remove(...). --- pkg/ansible/watches/watches_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/ansible/watches/watches_test.go b/pkg/ansible/watches/watches_test.go index 05f096a32c1..0ff02f73770 100644 --- a/pkg/ansible/watches/watches_test.go +++ b/pkg/ansible/watches/watches_test.go @@ -46,6 +46,7 @@ func TestLoad(t *testing.T) { if err != nil { t.Fatalf("Unable to create valid.yaml: %v", err) } + defer os.Remove("testdata/valid.yaml") err = tmpl.Execute(f, validTemplate) if err != nil { t.Fatalf("Unable to create valid.yaml: %v", err)