Skip to content

Commit 693e501

Browse files
committed
ROX-29638: Add gitops install command to acsfleetctl
1 parent e8e3c41 commit 693e501

File tree

12 files changed

+1334
-28
lines changed

12 files changed

+1334
-28
lines changed

.secrets.baseline

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,15 @@
262262
"line_number": 1343
263263
}
264264
],
265+
"internal/central/pkg/gitops/secrets_manager_client_moq.go": [
266+
{
267+
"type": "Secret Keyword",
268+
"filename": "internal/central/pkg/gitops/secrets_manager_client_moq.go",
269+
"hashed_secret": "44e17306b837162269a410204daaa5ecee4ec22c",
270+
"is_verified": true,
271+
"line_number": 52
272+
}
273+
],
265274
"internal/central/pkg/services/centralservice_moq.go": [
266275
{
267276
"type": "Secret Keyword",

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,9 @@ image/build/probe:
546546
image/build/fleet-manager-tools: GOOS=linux
547547
image/build/fleet-manager-tools: IMAGE_REF="$(external_image_registry)/fleet-manager-tools:$(image_tag)"
548548
image/build/fleet-manager-tools: fleet-manager fleetshard-sync acsfleetctl
549-
$(DOCKER) build -t $(IMAGE_REF) -f Dockerfile.tools .
549+
$(DOCKER) build -t $(IMAGE_REF) -f tools.Dockerfile .
550550
$(DOCKER) tag $(IMAGE_REF) fleet-manager-tools:$(image_tag)
551-
.PHONY: image/build/multi-target/fleet-manager-tools
551+
.PHONY: image/build/fleet-manager-tools
552552

553553
image/push/fleet-manager-tools: IMAGE_REF="$(external_image_registry)/fleet-manager-tools:$(image_tag)"
554554
image/push/fleet-manager-tools: image/build/fleet-manager-tools

cmd/acsfleetctl/main.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22
package main
33

44
import (
5+
"flag"
56
"os"
67

8+
"github.com/golang/glog"
79
"github.com/spf13/cobra"
10+
"github.com/spf13/pflag"
811
"github.com/stackrox/acs-fleet-manager/internal/central/pkg/cmd/admin"
912
"github.com/stackrox/acs-fleet-manager/internal/central/pkg/cmd/centrals"
1013
gitopsCmd "github.com/stackrox/acs-fleet-manager/internal/central/pkg/gitops/cmd"
1114
)
1215

1316
func main() {
17+
defer glog.Flush()
1418
rootCmd := &cobra.Command{
1519
Use: "acsfleetctl",
1620
Long: "acsfleetctl is a CLI used to interact with the ACSCS fleet-manager API",
@@ -21,11 +25,17 @@ func main() {
2125
if err := rootCmd.Execute(); err != nil {
2226
os.Exit(1)
2327
}
24-
2528
}
2629

2730
func setupSubCommands(rootCmd *cobra.Command) {
2831
rootCmd.AddCommand(centrals.NewCentralsCommand())
2932
rootCmd.AddCommand(admin.NewAdminCommand())
3033
rootCmd.AddCommand(gitopsCmd.NewGitOpsCommand())
3134
}
35+
36+
func init() {
37+
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
38+
if err := flag.Set("logtostderr", "true"); err != nil {
39+
glog.Infof("Unable to set logtostderr to true")
40+
}
41+
}

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
github.com/aws/aws-sdk-go v1.55.7
1010
github.com/aws/aws-sdk-go-v2 v1.36.3
1111
github.com/aws/aws-sdk-go-v2/config v1.29.9
12+
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.35.4
1213
github.com/aws/aws-sdk-go-v2/service/ses v1.29.9
1314
github.com/bxcodec/faker/v3 v3.8.1
1415
github.com/caarlos0/env/v6 v6.10.1
@@ -35,6 +36,7 @@ require (
3536
github.com/openshift-online/ocm-sdk-go v0.1.456
3637
github.com/openshift/addon-operator/apis v0.0.0-20231110045543-dd01f2f5c184
3738
github.com/openshift/api v0.0.0-20240415161129-d7aff303fa1a
39+
github.com/operator-framework/api v0.31.0
3840
github.com/patrickmn/go-cache v2.1.0+incompatible
3941
github.com/pkg/errors v0.9.1
4042
github.com/prometheus/client_golang v1.20.5
@@ -251,8 +253,8 @@ require (
251253
golang.org/x/time v0.8.0 // indirect
252254
golang.org/x/tools v0.30.0 // indirect
253255
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
254-
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
255-
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
256+
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect
257+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250227231956-55c901821b1e // indirect
256258
google.golang.org/grpc v1.68.1 // indirect
257259
google.golang.org/protobuf v1.36.6 // indirect
258260
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect

go.sum

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 h1:eAh2A4b
125125
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3/go.mod h1:0yKJC/kb8sAnmlYa6Zs3QVYqaC8ug2AbnNChv5Ox3uA=
126126
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 h1:dM9/92u2F1JbDaGooxTq18wmmFzbJRfXfVfy96/1CXM=
127127
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15/go.mod h1:SwFBy2vjtA0vZbjjaFtfN045boopadnoVPhu4Fv66vY=
128+
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.35.4 h1:EKXYJ8kgz4fiqef8xApu7eH0eae2SrVG+oHCLFybMRI=
129+
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.35.4/go.mod h1:yGhDiLKguA3iFJYxbrQkQiNzuy+ddxesSZYWVeeEH5Q=
128130
github.com/aws/aws-sdk-go-v2/service/ses v1.29.9 h1:MIiyk/qQEBO+AI1WHRQDSZft9w2XGAenB58lhzVrByg=
129131
github.com/aws/aws-sdk-go-v2/service/ses v1.29.9/go.mod h1:TPNs3cjA3xDkDpSlPajkTr0VrSw8U9dh8sE+n77QjgE=
130132
github.com/aws/aws-sdk-go-v2/service/sso v1.25.1 h1:8JdC7Gr9NROg1Rusk25IcZeTO59zLxsKgE0gkh5O6h0=
@@ -692,6 +694,8 @@ github.com/openshift/api v0.0.0-20240415161129-d7aff303fa1a/go.mod h1:CxgbWAlvu2
692694
github.com/openshift/client-go v0.0.0-20240415191513-dcdeb09390b4 h1:l/gocTF9qYhmm+RWgPS9GVPyeisDqCYluSUy2+F3G2E=
693695
github.com/openshift/client-go v0.0.0-20240415191513-dcdeb09390b4/go.mod h1:Q3mt/X5xrxnR5R6BE7duF2ToLioRQJYnTYaaDS4QZTs=
694696
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
697+
github.com/operator-framework/api v0.31.0 h1:tRsFTuZ51xD8U5QgiPo3+mZgVipHZVgRXYrI6RRXOh8=
698+
github.com/operator-framework/api v0.31.0/go.mod h1:57oCiHNeWcxmzu1Se8qlnwEKr/GGXnuHvspIYFCcXmY=
695699
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
696700
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
697701
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
@@ -938,8 +942,9 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu
938942
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
939943
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
940944
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
941-
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
942945
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
946+
golang.org/x/lint v0.0.0-20241112194109-818c5a804067 h1:adDmSQyFTCiv19j015EGKJBoaa7ElV0Q1Wovb/4G7NA=
947+
golang.org/x/lint v0.0.0-20241112194109-818c5a804067/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
943948
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
944949
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
945950
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
@@ -1456,10 +1461,10 @@ google.golang.org/genproto v0.0.0-20220518221133-4f43b3371335/go.mod h1:RAyBrSAP
14561461
google.golang.org/genproto v0.0.0-20220523171625-347a074981d8/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4=
14571462
google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA=
14581463
google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA=
1459-
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 h1:M0KvPgPmDZHPlbRbaNU1APr28TvwvvdUPlSv7PUvy8g=
1460-
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:dguCy7UOdZhTvLzDyt15+rOrawrpM4q7DD9dQ1P11P4=
1461-
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 h1:XVhgTWWV3kGQlwJHR3upFWZeTsei6Oks1apkZSeonIE=
1462-
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
1464+
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb h1:p31xT4yrYrSM/G4Sn2+TNUkVhFCbG9y8itM2S6Th950=
1465+
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb/go.mod h1:jbe3Bkdp+Dh2IrslsFCklNhweNTBgSYanP1UXhJDhKg=
1466+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250227231956-55c901821b1e h1:YA5lmSs3zc/5w+xsRcHqpETkaYyK63ivEPzNTcUUlSA=
1467+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250227231956-55c901821b1e/go.mod h1:LuRYeWDFV6WOn90g357N17oMCaxpgCnbi/44qJvDn2I=
14631468
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
14641469
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
14651470
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Package cmd ...
2+
package cmd
3+
4+
import (
5+
"github.com/spf13/cobra"
6+
)
7+
8+
// NewGitOpsCommand creates a new gitops command.
9+
func NewGitOpsCommand() *cobra.Command {
10+
cmd := &cobra.Command{
11+
Use: "gitops",
12+
Short: "Perform actions like validation on the gitops config.",
13+
Long: "Perform actions like validation on the gitops config.",
14+
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
15+
}
16+
cmd.AddCommand(
17+
newValidateCommand(),
18+
newInstallCommand(),
19+
)
20+
21+
return cmd
22+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package cmd
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"time"
7+
8+
"github.com/spf13/cobra"
9+
"github.com/stackrox/acs-fleet-manager/internal/central/pkg/gitops"
10+
)
11+
12+
func newInstallCommand() *cobra.Command {
13+
installCmd := &cobra.Command{
14+
Use: "install",
15+
Short: "Installs the gitops operator.",
16+
Long: "A command that installs ArgoCD aka openshift-gitops-operator",
17+
RunE: func(cmd *cobra.Command, args []string) error {
18+
timeoutDuration, err := cmd.Flags().GetDuration("timeout")
19+
if err != nil {
20+
return fmt.Errorf("failed to parse timeout flag: %w", err)
21+
}
22+
ctx, cancel := context.WithTimeout(context.Background(), timeoutDuration)
23+
defer cancel()
24+
clusterName, err := cmd.Flags().GetString("cluster-name")
25+
if err != nil {
26+
return fmt.Errorf("failed to parse 'cluster-name' flag: %w", err)
27+
}
28+
bootstrapRev, err := cmd.Flags().GetString("bootstrap-revision")
29+
if err != nil {
30+
return fmt.Errorf("failed to parse 'bootstrap-revision' flag: %w", err)
31+
}
32+
return gitops.InstallGitopsOperator(ctx,
33+
gitops.WithClusterName(clusterName),
34+
gitops.WithBootstrapAppTargetRevision(bootstrapRev))
35+
},
36+
}
37+
installCmd.Flags().DurationP("timeout", "t", 5*time.Minute, "Timeout for the install operation (e.g., 30s, 1m, 2h30m), defaults to 5 minutes.")
38+
installCmd.Flags().String("cluster-name", "", "Optional cluster name. If not specified, the cluster name will attempt to resolve automatically.")
39+
installCmd.Flags().String("bootstrap-revision", "HEAD", "Bootstrap app target revision.")
40+
return installCmd
41+
}

internal/central/pkg/gitops/cmd/validate.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,6 @@ import (
99
"github.com/stackrox/acs-fleet-manager/internal/central/pkg/gitops"
1010
)
1111

12-
// NewGitOpsCommand creates a new gitops command.
13-
func NewGitOpsCommand() *cobra.Command {
14-
cmd := &cobra.Command{
15-
Use: "gitops",
16-
Short: "Perform actions like validation on the gitops config.",
17-
Long: "Perform actions like validation on the gitops config.",
18-
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
19-
}
20-
cmd.AddCommand(
21-
newValidateCommand(),
22-
)
23-
24-
return cmd
25-
}
26-
2712
func newValidateCommand() *cobra.Command {
2813
return &cobra.Command{
2914
Use: "validate",

0 commit comments

Comments
 (0)