Skip to content

Commit

Permalink
fix: do not create k8s client if no resources configured
Browse files Browse the repository at this point in the history
Signed-off-by: Ievgenii Shepeliuk <eshepelyuk@gmail.com>
  • Loading branch information
eshepelyuk committed Oct 27, 2023
1 parent b50799a commit 6cc872b
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions cmd/kube-mgmt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,23 @@ func run(params *params) {
if err != nil {
logrus.Fatalf("Failed to get dynamic client: %v", err)
}
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

opts := data.WithIgnoreNamespaces(params.replicateIgnoreNs)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

for _, gvk := range params.replicateCluster {
sync := data.NewFromInterface(client, opa.New(params.opaURL, params.opaAuth).Prefix(params.replicatePath), getResourceType(gvk, false), opts)
go sync.RunContext(ctx)
}
opts := data.WithIgnoreNamespaces(params.replicateIgnoreNs)

for _, gvk := range params.replicateCluster {
sync := data.NewFromInterface(client, opa.New(params.opaURL, params.opaAuth).Prefix(params.replicatePath), getResourceType(gvk, false), opts)
go sync.RunContext(ctx)
}

for _, gvk := range params.replicateNamespace {
sync := data.NewFromInterface(client, opa.New(params.opaURL, params.opaAuth).Prefix(params.replicatePath), getResourceType(gvk, true), opts)
go sync.RunContext(ctx)
for _, gvk := range params.replicateNamespace {
sync := data.NewFromInterface(client, opa.New(params.opaURL, params.opaAuth).Prefix(params.replicatePath), getResourceType(gvk, true), opts)
go sync.RunContext(ctx)
}
}

quit := make(chan struct{})
<-quit
}
Expand Down

0 comments on commit 6cc872b

Please sign in to comment.