Skip to content
This repository was archived by the owner on Nov 18, 2020. It is now read-only.

Commit b650ea3

Browse files
authored
vault/cmd/.../main.go: update operator main.go (#29)
The old main.go file from the vault-operator was outdated and did not work outside of the default namespace. This update resyncs it based on the current main.go template, which supports non-default namespaces.
1 parent 18984e7 commit b650ea3

File tree

1 file changed

+14
-1
lines changed
  • vault-operator/cmd/vault-operator

1 file changed

+14
-1
lines changed

vault-operator/cmd/vault-operator/main.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import (
66

77
stub "github.com/operator-framework/operator-sdk-samples/vault-operator/pkg/stub"
88
sdk "github.com/operator-framework/operator-sdk/pkg/sdk"
9+
k8sutil "github.com/operator-framework/operator-sdk/pkg/util/k8sutil"
910
sdkVersion "github.com/operator-framework/operator-sdk/version"
1011

1112
"github.com/sirupsen/logrus"
13+
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
1214
)
1315

1416
func printVersion() {
@@ -19,7 +21,18 @@ func printVersion() {
1921

2022
func main() {
2123
printVersion()
22-
sdk.Watch("vault.security.coreos.com/v1alpha1", "VaultService", "default", 5)
24+
25+
sdk.ExposeMetricsPort()
26+
27+
resource := "vault.security.coreos.com/v1alpha1"
28+
kind := "VaultService"
29+
namespace, err := k8sutil.GetWatchNamespace()
30+
if err != nil {
31+
logrus.Fatalf("failed to get watch namespace: %v", err)
32+
}
33+
resyncPeriod := 5
34+
logrus.Infof("Watching %s, %s, %s, %d", resource, kind, namespace, resyncPeriod)
35+
sdk.Watch(resource, kind, namespace, resyncPeriod)
2336
sdk.Handle(stub.NewHandler())
2437
sdk.Run(context.TODO())
2538
}

0 commit comments

Comments
 (0)