Skip to content

Commit f7f02de

Browse files
djzagerShawn Hurley
authored andcommitted
ansible: Use operator-sdk's dynamic restmapper (#1661)
* 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 * 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(...).
1 parent 283ac6f commit f7f02de

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

pkg/ansible/run.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/operator-framework/operator-sdk/pkg/k8sutil"
2828
"github.com/operator-framework/operator-sdk/pkg/leader"
2929
"github.com/operator-framework/operator-sdk/pkg/metrics"
30+
"github.com/operator-framework/operator-sdk/pkg/restmapper"
3031
sdkVersion "github.com/operator-framework/operator-sdk/version"
3132
"k8s.io/api/core/v1"
3233
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -71,6 +72,7 @@ func Run(flags *aoflags.AnsibleOperatorFlags) error {
7172
// TODO: probably should expose the host & port as an environment variables
7273
mgr, err := manager.New(cfg, manager.Options{
7374
Namespace: namespace,
75+
MapperProvider: restmapper.NewDynamicRESTMapper,
7476
MetricsBindAddress: fmt.Sprintf("0.0.0.0:%d", metricsPort),
7577
})
7678
if err != nil {

pkg/ansible/watches/watches_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func TestLoad(t *testing.T) {
4646
if err != nil {
4747
t.Fatalf("Unable to create valid.yaml: %v", err)
4848
}
49+
defer os.Remove("testdata/valid.yaml")
4950
err = tmpl.Execute(f, validTemplate)
5051
if err != nil {
5152
t.Fatalf("Unable to create valid.yaml: %v", err)

0 commit comments

Comments
 (0)