Skip to content

Commit 2cced7a

Browse files
committed
feat: deploy-flux command
1 parent d1029e1 commit 2cced7a

17 files changed

+915
-8
lines changed

cmd/deploy_flux.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/openmcp-project/controller-utils/pkg/clusters"
7+
"github.com/spf13/cobra"
8+
9+
"github.com/openmcp-project/bootstrapper/internal/flux_deployer"
10+
)
11+
12+
const (
13+
flagOCMConfig = "ocm-config"
14+
flagGitCredentials = "git-credentials"
15+
flagKubeconfig = "kubeconfig"
16+
flagFluxCDNamespace = "fluxcd-namespace"
17+
)
18+
19+
// deployFluxCmd represents the "deploy flux" command
20+
var deployFluxCmd = &cobra.Command{
21+
Use: "deploy-flux source target",
22+
Short: "Transfer an OCM component from a source to a target location",
23+
Long: `Transfers the specified OCM component version from the source location to the target location.`,
24+
Args: cobra.ExactArgs(4),
25+
ArgAliases: []string{
26+
"component-location",
27+
"deployment-templates",
28+
"deployment-repository",
29+
"deployment-repository-branch",
30+
},
31+
RunE: func(cmd *cobra.Command, args []string) error {
32+
platformKubeconfig := cmd.Flag(flagKubeconfig).Value.String()
33+
platformCluster := clusters.New("platform").WithConfigPath(platformKubeconfig)
34+
if err := platformCluster.InitializeRESTConfig(); err != nil {
35+
return fmt.Errorf("error initializing REST config for platform cluster: %w", err)
36+
}
37+
if err := platformCluster.InitializeClient(nil); err != nil {
38+
return fmt.Errorf("error initializing client for platform cluster: %w", err)
39+
}
40+
41+
d := flux_deployer.NewFluxDeployer(args[0], args[1], args[2], args[3],
42+
cmd.Flag(flagOCMConfig).Value.String(),
43+
cmd.Flag(flagGitCredentials).Value.String(),
44+
cmd.Flag(flagFluxCDNamespace).Value.String(),
45+
platformKubeconfig,
46+
platformCluster)
47+
return d.Deploy(cmd.Context())
48+
},
49+
}
50+
51+
func init() {
52+
RootCmd.AddCommand(deployFluxCmd)
53+
54+
deployFluxCmd.Flags().StringP(flagOCMConfig, "c", "", "ocm configuration file")
55+
deployFluxCmd.Flags().StringP(flagGitCredentials, "g", "", "git credentials configuration file that configures basic auth, personal access token, ssh private key. This will be used in the fluxcd GitSource for spec.secretRef to authenticate against the deploymentRepository. If not set, no authentication will be configured.")
56+
deployFluxCmd.Flags().StringP(flagKubeconfig, "k", "", "kubeconfig of the Kubernetes cluster on which the flux deployment will be created/updated. If not set, the current context will be used.")
57+
deployFluxCmd.Flags().StringP(flagFluxCDNamespace, "n", "", "namespace on the Kubernetes cluster in which the namespaced fluxcd resources will be deployed. Default 'flux-system'.")
58+
}

go.mod

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,67 @@ module github.com/openmcp-project/bootstrapper
33
go 1.25.0
44

55
require (
6+
github.com/openmcp-project/controller-utils v0.17.0
67
github.com/sirupsen/logrus v1.9.3
78
github.com/spf13/cobra v1.9.1
89
github.com/stretchr/testify v1.10.0
10+
k8s.io/api v0.33.3
11+
k8s.io/apimachinery v0.33.3
912
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
13+
sigs.k8s.io/controller-runtime v0.21.0
1014
sigs.k8s.io/yaml v1.6.0
1115
)
1216

1317
require (
14-
github.com/davecgh/go-spew v1.1.1 // indirect
18+
github.com/beorn7/perks v1.0.1 // indirect
19+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
20+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
21+
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
22+
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
23+
github.com/fsnotify/fsnotify v1.8.0 // indirect
24+
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
25+
github.com/go-logr/logr v1.4.3 // indirect
26+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
27+
github.com/go-openapi/jsonreference v0.21.0 // indirect
28+
github.com/go-openapi/swag v0.23.0 // indirect
29+
github.com/gogo/protobuf v1.3.2 // indirect
30+
github.com/google/btree v1.1.3 // indirect
31+
github.com/google/gnostic-models v0.6.9 // indirect
32+
github.com/google/go-cmp v0.7.0 // indirect
33+
github.com/google/uuid v1.6.0 // indirect
1534
github.com/inconshreveable/mousetrap v1.1.0 // indirect
16-
github.com/pmezard/go-difflib v1.0.0 // indirect
35+
github.com/josharian/intern v1.0.0 // indirect
36+
github.com/json-iterator/go v1.1.12 // indirect
37+
github.com/mailru/easyjson v0.9.0 // indirect
38+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
39+
github.com/modern-go/reflect2 v1.0.2 // indirect
40+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
41+
github.com/pkg/errors v0.9.1 // indirect
42+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
43+
github.com/prometheus/client_golang v1.22.0 // indirect
44+
github.com/prometheus/client_model v0.6.1 // indirect
45+
github.com/prometheus/common v0.62.0 // indirect
46+
github.com/prometheus/procfs v0.15.1 // indirect
1747
github.com/spf13/pflag v1.0.7 // indirect
48+
github.com/x448/float16 v0.8.4 // indirect
1849
go.yaml.in/yaml/v2 v2.4.2 // indirect
19-
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
50+
golang.org/x/net v0.43.0 // indirect
51+
golang.org/x/oauth2 v0.27.0 // indirect
52+
golang.org/x/sync v0.16.0 // indirect
53+
golang.org/x/sys v0.35.0 // indirect
54+
golang.org/x/term v0.34.0 // indirect
55+
golang.org/x/text v0.28.0 // indirect
56+
golang.org/x/time v0.10.0 // indirect
57+
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
58+
google.golang.org/protobuf v1.36.6 // indirect
59+
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
60+
gopkg.in/inf.v0 v0.9.1 // indirect
2061
gopkg.in/yaml.v3 v3.0.1 // indirect
62+
k8s.io/apiextensions-apiserver v0.33.3 // indirect
63+
k8s.io/client-go v0.33.3 // indirect
64+
k8s.io/klog/v2 v2.130.1 // indirect
65+
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
66+
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
67+
sigs.k8s.io/randfill v1.0.0 // indirect
68+
sigs.k8s.io/structured-merge-diff/v4 v4.7.0 // indirect
2169
)

0 commit comments

Comments
 (0)