Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cmd/clusters-service/app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Options struct {
ProfileHelmRepository string
HelmRepositoryCacheDirectory string
CAPIClustersNamespace string
CAPIEnabled string
CAPIEnabled bool
EntitlementSecretKey client.ObjectKey
HtmlRootPath string
ClientGetter kube.ClientGetter
Expand Down Expand Up @@ -194,3 +194,9 @@ func WithTLSConfig(tlsCert, tlsKey string, noTLS bool) Option {
o.NoTLS = noTLS
}
}

func WithCAPIEnabled(capiEnabled bool) Option {
return func(o *Options) {
o.CAPIEnabled = capiEnabled
}
}
7 changes: 4 additions & 3 deletions cmd/clusters-service/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type Params struct {
capiTemplatesNamespace string
injectPruneAnnotation string
addBasesKustomization string
capiEnabled string
capiEnabled bool
capiTemplatesRepositoryUrl string
capiRepositoryPath string
capiRepositoryClustersPath string
Expand Down Expand Up @@ -160,7 +160,7 @@ func NewAPIServerCommand(log logr.Logger, tempDir string) *cobra.Command {
cmd.Flags().StringVar(&p.htmlRootPath, "html-root-path", "/html", "Where to serve static assets from")
cmd.Flags().StringVar(&p.gitProviderType, "git-provider-type", "", "")
cmd.Flags().StringVar(&p.gitProviderHostname, "git-provider-hostname", "", "")
cmd.Flags().StringVar(&p.capiEnabled, "capi-enabled", "true", "")
cmd.Flags().BoolVar(&p.capiEnabled, "capi-enabled", true, "")
cmd.Flags().StringVar(&p.capiClustersNamespace, "capi-clusters-namespace", corev1.NamespaceAll, "where to look for GitOps cluster resources, defaults to looking in all namespaces")
cmd.Flags().StringVar(&p.capiTemplatesNamespace, "capi-templates-namespace", "", "where to look for CAPI template resources, required")
cmd.Flags().StringVar(&p.injectPruneAnnotation, "inject-prune-annotation", "", "")
Expand Down Expand Up @@ -268,7 +268,7 @@ func StartServer(ctx context.Context, log logr.Logger, tempDir string, p Params)
authv1.AddToScheme,
}

if p.capiEnabled == "true" {
if p.capiEnabled {
schemeBuilder = append(schemeBuilder, capiv1.AddToScheme)
}

Expand Down Expand Up @@ -409,6 +409,7 @@ func StartServer(ctx context.Context, log logr.Logger, tempDir string, p Params)
WithClientGetter(clientGetter),
WithOIDCConfig(p.OIDC),
WithTLSConfig(p.TLSCert, p.TLSKey, p.NoTLS),
WithCAPIEnabled(p.capiEnabled),
)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/clusters-service/pkg/server/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (s *server) ListGitopsClusters(ctx context.Context, msg *capiv1_proto.ListG
return nil, err
}

if s.capiEnabled == "true" {
if s.capiEnabled {
clusters, err = AddCAPIClusters(ctx, client, clusters)
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions cmd/clusters-service/pkg/server/clusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestListGitopsClusters(t *testing.T) {
clusterState []runtime.Object
refType string
expected []*capiv1_protos.GitopsCluster
capiEnabled string
capiEnabled bool
err error
}{
{
Expand Down Expand Up @@ -267,7 +267,7 @@ func TestListGitopsClusters(t *testing.T) {
ControlPlane: true,
},
},
capiEnabled: "true",
capiEnabled: true,
},
{
name: "capi-enabled is false",
Expand Down Expand Up @@ -313,7 +313,7 @@ func TestListGitopsClusters(t *testing.T) {
ControlPlane: true,
},
},
capiEnabled: "false",
capiEnabled: false,
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/clusters-service/pkg/server/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type serverOptions struct {
ns string
hr *sourcev1.HelmRepository
clientsFactory clustersmngr.ClientsFactory
capiEnabled string
capiEnabled bool
}

func createServer(t *testing.T, o serverOptions) capiv1_protos.ClustersServiceServer {
Expand Down
4 changes: 2 additions & 2 deletions cmd/clusters-service/pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type server struct {
ns string // The namespace where cluster objects reside
profileHelmRepositoryName string
helmRepositoryCacheDir string
capiEnabled string
capiEnabled bool
}

type ServerOpts struct {
Expand All @@ -52,7 +52,7 @@ type ServerOpts struct {
ClustersNamespace string
ProfileHelmRepositoryName string
HelmRepositoryCacheDir string
CAPIEnabled string
CAPIEnabled bool
}

func NewClusterServer(opts ServerOpts) capiv1_proto.ClustersServiceServer {
Expand Down