Skip to content

Commit 1586993

Browse files
authored
chore: refactoring of command naming and documentation (#56)
1 parent 19e4aa3 commit 1586993

File tree

6 files changed

+166
-18
lines changed

6 files changed

+166
-18
lines changed

README.md

Lines changed: 150 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@
77
The openmcp bootstrapper is a command line tool that is able to set up an openmcp landscape initially and to update existing openmcp landscapes with new versions of the openmcp project.
88

99
Supported commands:
10-
* `ocmTransfer`: Transfers the specified OCM component version from the source location to the target location.
10+
* `ocm-transfer`: Transfers the specified OCM component version from the source location to the target location.
11+
* `deploy-flux`: Deploys the FluxCD components to the specified Kubernetes cluster.
12+
* `manage-deployment-repo`: Templates the openMCP git ops templates and applies them to the specified git repository and all kustomized resources to the specified Kubernetes cluster.
1113

12-
### `ocmTransfer`
14+
Supported global flags:
15+
* `--verbosity`: Sets the verbosity level of the logging output. Supported levels are `trace`, `debug`, `info`, `warn`, `error`. Default is `info`.
1316

14-
The `ocmTransfer` command is used to transfer an OCM component version from a source location to a target location.
15-
The `ocmTransfer` requires the following parameters:
17+
### `ocm-transfer`
18+
19+
The `ocm-transfer` command is used to transfer an OCM component version from a source location to a target location.
20+
The `ocm-transfer` requires the following parameters:
1621
* `source`: The source location of the OCM component version to be transferred.
1722
* `target`: The target location where the OCM component version should be transferred to.
1823

1924
Optional parameters:
20-
* `--config`: Path to the OCM configuration file.
25+
* `--ocm-config`: Path to the OCM configuration file.
2126

2227
```shell
2328
openmcp-bootstrapper ocmTransfer <source-location> <target-location> --config <path-to-ocm-config>
@@ -31,11 +36,149 @@ ocm --config <path-to-ocm-config> transfer componentversion --recursive --copy-r
3136

3237
Example:
3338
```shell
34-
openmcp-bootstrapper ocmTransfer ghcr.io/openmcp-project/components//github.com/openmcp-project/openmcp:v0.0.11 ./ctf
35-
openmcp-bootstrapper ocmTransfer ghcr.io/openmcp-project/components//github.com/openmcp-project/openmcp:v0.0.11 ghcr.io/my-github-user
39+
openmcp-bootstrapper ocm-transfer ghcr.io/openmcp-project/components//github.com/openmcp-project/openmcp:v0.0.11 ./ctf
40+
openmcp-bootstrapper ocm-transfer ghcr.io/openmcp-project/components//github.com/openmcp-project/openmcp:v0.0.11 ghcr.io/my-github-user
41+
```
42+
43+
## `deploy-flux`
44+
45+
The `deploy-flux` command is used to deploy the FluxCD components to a Kubernetes cluster.
46+
The `deploy-flux` command requires the following parameters:
47+
* `bootstrapper-config`: Path to the bootstrapper configuration file.
48+
49+
Optional parameters:
50+
* `--kubeconfig`: Path to the kubeconfig file of the target Kubernetes cluster. If not set, the value of the `KUBECONFIG` environment variable will be used. If the `KUBECONFIG` environment variable is not set, the default kubeconfig file located at `$HOME/.kube/config` will be used.
51+
* `--ocm-config`: Path to the OCM configuration file.
52+
* `--git-config`: Path to the git configuration file containing the credentials for accessing the git repository. If not set, no authentication will be configured.
53+
54+
### bootstrapper configuration file
55+
56+
The `deploy-flux` command requires a bootstrapper configuration file in YAML format. The configuration file contains the following sections:
57+
* `component` (required): The OCM component version to be deployed. The location must be in the format `<OCM Registry Location>//<Component Name>:<version>`. For example: `ghcr.io/openmcp-project/components//github.com/openmcp-project/openmcp:v0.0.18`.
58+
* `repository` (required): The git repository where the FluxCD components should be deployed to. The `url` field specifies the URL of the git repository and the `branch` field specifies the branch to be used.
59+
* `environment` (required): The name of the openMCP environment that shall be managed by FluxCD. For example: `dev`, `prod`, `dev-eu10`, etc.
60+
61+
```yaml
62+
component:
63+
location: <OCM Registry Location>//<Component Name>:<version>
64+
65+
repository:
66+
url: <git-repo-url>
67+
branch: <branch-name>
68+
69+
environment:
70+
name: <environment-name>
71+
```
72+
73+
Example:
74+
```shell
75+
openmcp-bootstrapper deploy-flux ./examples/bootstrapper-config.yaml --kubeconfig ~/.kube/config --ocm-config ./examples/ocm-config.yaml --git-config ./examples/git-config.yaml ./examples/bootstrapper-config.yaml
3676
```
3777

78+
## `manage-deployment-repo`
79+
80+
The `manageDeploymentRepo` command is used to template the openMCP git ops templates and apply them to the specified git repository and all kustomized resources to the specified Kubernetes cluster.
81+
The `manageDeploymentRepo` command requires the following parameters:
82+
* `bootstrapper-config`: Path to the bootstrapper configuration file.
83+
* `--git-config`: Path to the git configuration file containing the credentials for accessing the git repository.
3884

85+
Optional parameters:
86+
* `--kubeconfig`: Path to the kubeconfig file of the target Kubernetes cluster. If not set, the value of the `KUBECONFIG` environment variable will be used. If the `KUBECONFIG` environment variable is not set, the default kubeconfig file located at `$HOME/.kube/config` will be used.
87+
* `--ocm-config`: Path to the OCM configuration file.
88+
* `--extra-manifest-dir` (repeatable): Path to an extra manifest directory that should be added to the kustomization. This can be used to add custom resources to the deployment.
89+
*
90+
91+
92+
The `manage-deployment-repo` requires a bootstrapper configuration file in YAML format. The configuration file contains the following sections:
93+
* `component` (required): The OCM component version to be deployed. The location must be in the format `<OCM Registry Location>//<Component Name>:<version>`. For example: `gh
94+
* `repository` (required): The git repository where the FluxCD components should be deployed to. The `url` field specifies the URL of the git repository and the `branch` field specifies the branch to be used.
95+
* `environment` (required): The name of the openMCP environment that shall be managed by FluxCD. For example: `dev`, `prod`, `dev-eu10`, etc.
96+
* `imagePullSecrets` (optional): A list of image pull secrets that shall be used for all Kubernetes deployments created by the bootstrapper. The secrets must already exist in the target cluster in the namespace `openmcp-system`.
97+
* `providers` (optional): A list of `cluster-providers`, `service-providers`, and `platform-services` that shall be enabled in the deployment. Each provider can have its own configuration.
98+
* `openmcpOperator` (required): Configuration for the openmcp operator.
99+
100+
```yaml
101+
component:
102+
location: <OCM Registry Location>//<Component Name>:<version>
103+
104+
repository:
105+
url: <git-repo-url>
106+
branch: <branch-name>
107+
108+
environment:
109+
name: <environment-name>
110+
111+
imagePullSecrets:
112+
- <image-pull-secret-name>
113+
114+
providers:
115+
clusterProviders:
116+
- name: kind
117+
config:
118+
extraVolumeMounts:
119+
- mountPath: /var/run/docker.sock
120+
name: docker
121+
extraVolumes:
122+
- name: docker
123+
hostPath:
124+
path: /var/run/host-docker.sock
125+
type: Socket
126+
verbosity: debug
127+
serviceProviders:
128+
- name: landscaper
129+
config:
130+
verbosity: debug
131+
132+
platformServices: []
133+
134+
openmcpOperator:
135+
config:
136+
managedControlPlane:
137+
mcpClusterPurpose: mcp-worker
138+
reconcileMCPEveryXDays: 7
139+
scheduler:
140+
scope: Cluster
141+
purposeMappings:
142+
mcp:
143+
template:
144+
spec:
145+
profile: kind
146+
tenancy: Exclusive
147+
mcp-worker:
148+
template:
149+
spec:
150+
profile: kind
151+
tenancy: Exclusive
152+
platform:
153+
template:
154+
metadata:
155+
labels:
156+
clusters.openmcp.cloud/delete-without-requests: "false"
157+
spec:
158+
profile: kind
159+
tenancy: Shared
160+
onboarding:
161+
template:
162+
metadata:
163+
labels:
164+
clusters.openmcp.cloud/delete-without-requests: "false"
165+
spec:
166+
profile: kind
167+
tenancy: Shared
168+
workload:
169+
tenancyCount: 20
170+
template:
171+
metadata:
172+
namespace: workload-clusters
173+
spec:
174+
profile: kind
175+
tenancy: Shared
176+
```
177+
178+
Example:
179+
```shell
180+
openmcp-bootstrapper manage-deployment-repo --kubeconfig ~/.kube/config --ocm-config ./examples/ocm-config.yaml --git-config ./examples/git-config.yaml --extra-manifest-dir ./my-custom-manifests ./examples/bootstrapper-config.yaml
181+
```
39182

40183
## Requirements and Setup
41184

cmd/constants.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package cmd
2+
3+
const (
4+
FlagGitConfig = "git-config"
5+
FlagOcmConfig = "ocm-config"
6+
FlagKubeConfig = "kubeconfig"
7+
)

cmd/deploy_flux.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var deployFluxCmd = &cobra.Command{
2222
ArgAliases: []string{
2323
"configFile",
2424
},
25+
Example: ` openmcp-bootstrapper deploy-flux "./config.yaml"`,
2526
RunE: func(cmd *cobra.Command, args []string) error {
2627
configFilePath := args[0]
2728

cmd/manageDeploymentRepo.go renamed to cmd/manage_deployment_repo.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ import (
1717
)
1818

1919
const (
20-
FlagGitConfig = "git-config"
21-
FlagOcmConfig = "ocm-config"
22-
FlagKubeConfig = "kubeconfig"
2320
FlagExtraManifestDir = "extra-manifest-dir"
2421
)
2522

@@ -33,16 +30,16 @@ func (w LogWriter) Write(p []byte) (n int, err error) {
3330

3431
// manageDeploymentRepoCmd represents the manageDeploymentRepo command
3532
var manageDeploymentRepoCmd = &cobra.Command{
36-
Use: "manageDeploymentRepo",
33+
Use: "manage-deployment-repo",
3734
Short: "Updates the openMCP deployment specification in the specified Git repository",
3835
Long: `Updates the openMCP deployment specification in the specified Git repository.
3936
The update is based on the specified component version.
40-
openmcp-bootstrapper manageDeploymentRepo <configFile>`,
37+
openmcp-bootstrapper manage-deployment-repo <configFile>`,
4138
Args: cobra.ExactArgs(1),
4239
ArgAliases: []string{
4340
"configFile",
4441
},
45-
Example: ` openmcp-bootstrapper manageDeploymentRepo "./config.yaml"`,
42+
Example: ` openmcp-bootstrapper manage-deployment-repo "./config.yaml"`,
4643
RunE: func(cmd *cobra.Command, args []string) error {
4744
configFilePath := args[0]
4845

cmd/ocmTransfer.go renamed to cmd/ocm_transfer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
// ocmTransferCmd represents the "ocm transfer componentversion" command
1111
var ocmTransferCmd = &cobra.Command{
12-
Use: "ocmTransfer source target",
12+
Use: "ocm-transfer source target",
1313
Short: "Transfer an OCM component from a source to a target location",
1414
Long: `Transfers the specified OCM component version from the source location to the target location.`,
1515
Aliases: []string{
@@ -23,7 +23,7 @@ var ocmTransferCmd = &cobra.Command{
2323
RunE: func(cmd *cobra.Command, args []string) error {
2424
log := log.GetLogger()
2525

26-
log.Debugf("Executing ocmTransfer with source: %s, target: %s", args[0], args[1])
26+
log.Debugf("Executing ocm-transfer with source: %s, target: %s", args[0], args[1])
2727

2828
transferCommands := []string{
2929
"transfer",
@@ -38,12 +38,12 @@ var ocmTransferCmd = &cobra.Command{
3838
args[1], // target
3939
}
4040

41-
return ocmcli.Execute(cmd.Context(), transferCommands, transferArgs, cmd.Flag("config").Value.String())
41+
return ocmcli.Execute(cmd.Context(), transferCommands, transferArgs, cmd.Flag(FlagOcmConfig).Value.String())
4242
},
4343
}
4444

4545
func init() {
4646
RootCmd.AddCommand(ocmTransferCmd)
4747

48-
ocmTransferCmd.PersistentFlags().StringP("config", "c", "", "ocm configuration file")
48+
ocmTransferCmd.PersistentFlags().String(FlagOcmConfig, "", "ocm configuration file")
4949
}

cmd/ocmTransfer_test.go renamed to cmd/ocm_transfer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestOcmTransfer(t *testing.T) {
4444
for _, tc := range testCases {
4545
t.Run(tc.desc, func(t *testing.T) {
4646
root := cmd.RootCmd
47-
args := []string{"ocmTransfer"}
47+
args := []string{"ocm-transfer"}
4848
if len(tc.arguments) > 0 {
4949
args = append(args, tc.arguments...)
5050
}

0 commit comments

Comments
 (0)