From 55532bd052f7ce1681ca9942bf5fdc2af2c5900d Mon Sep 17 00:00:00 2001 From: kranurag7 <81210977+kranurag7@users.noreply.github.com> Date: Fri, 23 Feb 2024 22:27:12 +0530 Subject: [PATCH] rename the project to csctl (#77) we want to rename the project to csctl given the client tool deals with cluster stacks. Signed-off-by: kranurag7 --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- .github/renovate.json5 | 14 +++---- .github/renovate/groups.json5 | 6 +-- .github/workflows/build.yml | 4 +- .github/workflows/builder-image.yml | 2 +- .github/workflows/pr-lint.yml | 2 +- .github/workflows/schedule-link-checker.yml | 2 +- .github/workflows/schedule-update-bot.yaml | 4 +- .gitignore | 2 +- .goreleaser.yaml | 4 +- Makefile | 6 +-- README.md | 17 +++++---- docs/README.md | 14 +++---- docs/design.md | 38 +++++++++---------- ...ctl.md => developing-and-testing-csctl.md} | 16 ++++---- ...w_to_use_csmctl.md => how_to_use_csctl.md} | 30 +++++++-------- docs/preparing_your_clusterstack_directory.md | 20 +++++----- go.mod | 2 +- hack/upgrade-builder-image.sh | 10 ++--- images/builder/Dockerfile | 2 +- images/builder/build.sh | 8 ++-- main.go | 4 +- pkg/clusterstack/config.go | 36 +++++++++--------- pkg/clusterstack/mode.go | 4 +- pkg/cmd/create.go | 16 ++++---- pkg/cmd/root.go | 2 +- pkg/github/release.go | 2 +- pkg/template/template.go | 10 ++--- tests/cluster-stacks/docker/ferrol/csctl.yaml | 7 ++++ .../cluster-stacks/docker/ferrol/csmctl.yaml | 7 ---- 31 files changed, 148 insertions(+), 147 deletions(-) rename docs/{developing-and-testing-csmctl.md => developing-and-testing-csctl.md} (65%) rename docs/{how_to_use_csmctl.md => how_to_use_csctl.md} (73%) create mode 100644 tests/cluster-stacks/docker/ferrol/csctl.yaml delete mode 100644 tests/cluster-stacks/docker/ferrol/csmctl.yaml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 762c563b..ad4d3ae7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -19,5 +19,5 @@ about: Tell us about a problem you are experiencing. **Environment:** -- csmctl version: (use `csmctl version`) +- csctl version: (use `csctl version`) - OS (e.g. from `/etc/os-release`): diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index d2b8ba52..34700fb3 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -16,4 +16,4 @@ about: Suggest an idea for this project. **Environment:** -- csmctl version: (use `kubectl version`) +- csctl version: (use `csctl version`) diff --git a/.github/renovate.json5 b/.github/renovate.json5 index f6dd553c..056758de 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -7,12 +7,12 @@ ":semanticCommits", "helpers:pinGitHubActionDigests", "github>whitesource/merge-confidence:beta", - "github>SovereignCloudStack/csmctl//.github/renovate/commitMessage.json5", - "github>SovereignCloudStack/csmctl//.github/renovate/approval.json5", - "github>SovereignCloudStack/csmctl//.github/renovate/golang.json5", - "github>SovereignCloudStack/csmctl//.github/renovate/groups.json5", - "github>SovereignCloudStack/csmctl//.github/renovate/labels.json5", - "github>SovereignCloudStack/csmctl//.github/renovate/regexManagers.json5" + "github>SovereignCloudStack/csctl//.github/renovate/commitMessage.json5", + "github>SovereignCloudStack/csctl//.github/renovate/approval.json5", + "github>SovereignCloudStack/csctl//.github/renovate/golang.json5", + "github>SovereignCloudStack/csctl//.github/renovate/groups.json5", + "github>SovereignCloudStack/csctl//.github/renovate/labels.json5", + "github>SovereignCloudStack/csctl//.github/renovate/regexManagers.json5" ], platform: "github", baseBranches: ["main"], @@ -20,7 +20,7 @@ requireConfig: "ignored", timezone: "Europe/Berlin", // repo config - repositories: ["SovereignCloudStack/csmctl"], + repositories: ["SovereignCloudStack/csctl"], ignorePaths: [ "**/vendor/**", "**/test/**", diff --git a/.github/renovate/groups.json5 b/.github/renovate/groups.json5 index cbf1eb57..d2855ff4 100644 --- a/.github/renovate/groups.json5 +++ b/.github/renovate/groups.json5 @@ -3,7 +3,7 @@ { description: "Update Builder Image", groupName: "Builder Image", - groupSlug: "csmctl-builder-image", + groupSlug: "csctl-builder-image", commitMessageTopic: "Builder Image group", matchPaths: ["images/builder/**"], separateMajorMinor: false, @@ -56,10 +56,10 @@ groupSlug: "golang-deps", }, { - description: "disable update of csmctl builder image", + description: "disable update of csctl builder image", matchManagers: ["github-actions"], matchUpdateTypes: ["major", "minor", "patch"], - matchPackageNames: ["ghcr.io/sovereigncloudstack/csmctl-builder"], + matchPackageNames: ["ghcr.io/sovereigncloudstack/csctl-builder"], enabled: false, }, ] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b686adb..e510319d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build csmctl binary +name: Build csctl binary # yamllint disable rule:line-length on: # yamllint disable-line rule:truthy push: @@ -19,4 +19,4 @@ jobs: # Load Golang cache build from GitHub - name: build go binary run: | - go build -o csmctl main.go \ No newline at end of file + go build -o csctl main.go \ No newline at end of file diff --git a/.github/workflows/builder-image.yml b/.github/workflows/builder-image.yml index 9e4bd218..2e2ddfdf 100644 --- a/.github/workflows/builder-image.yml +++ b/.github/workflows/builder-image.yml @@ -32,4 +32,4 @@ jobs: file: ./images/builder/Dockerfile context: ./images/builder push: true - tags: ghcr.io/sovereigncloudstack/csmctl-builder:0.2.0 + tags: ghcr.io/sovereigncloudstack/csctl-builder:0.2.0 diff --git a/.github/workflows/pr-lint.yml b/.github/workflows/pr-lint.yml index 505e808f..f0a3b236 100644 --- a/.github/workflows/pr-lint.yml +++ b/.github/workflows/pr-lint.yml @@ -19,7 +19,7 @@ jobs: if: github.event_name != 'pull_request_target' || !github.event.pull_request.draft runs-on: ubuntu-latest container: - image: ghcr.io/sovereigncloudstack/csmctl-builder:0.2.0 + image: ghcr.io/sovereigncloudstack/csctl-builder:0.2.0 credentials: username: ${{ github.actor }} password: ${{ secrets.github_token }} diff --git a/.github/workflows/schedule-link-checker.yml b/.github/workflows/schedule-link-checker.yml index 8aee4a1b..5e09b3fe 100644 --- a/.github/workflows/schedule-link-checker.yml +++ b/.github/workflows/schedule-link-checker.yml @@ -8,7 +8,7 @@ jobs: link-checker: name: Link Checker runs-on: ubuntu-latest - if: github.repository == 'SovereignCloudStack/csmctl' + if: github.repository == 'SovereignCloudStack/csctl' steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 diff --git a/.github/workflows/schedule-update-bot.yaml b/.github/workflows/schedule-update-bot.yaml index 3e3cf71d..24a87574 100644 --- a/.github/workflows/schedule-update-bot.yaml +++ b/.github/workflows/schedule-update-bot.yaml @@ -25,7 +25,7 @@ env: # yamllint disable rule:line-length jobs: update-bot: - if: github.repository == 'SovereignCloudStack/csmctl' + if: github.repository == 'SovereignCloudStack/csctl' name: Renovate runs-on: ubuntu-latest steps: @@ -49,7 +49,7 @@ jobs: env: RENOVATE_HOST_RULES: '[{"hostType": "docker", "matchHost": "ghcr.io", "username": "${{ github.actor }}", "password": "${{ secrets.GITHUB_TOKEN }}" }]' RENOVATE_ALLOWED_POST_UPGRADE_COMMANDS: '[".*"]' - BUILDER_IMAGE: 'ghcr.io/sovereigncloudstack/csmctl-builder' + BUILDER_IMAGE: 'ghcr.io/sovereigncloudstack/csctl-builder' RENOVATE_POST_UPGRADE_TASKS: '{ commands: ["BUILD_IMAGE_TOKEN=${{ secrets.GITHUB_TOKEN }} BUILD_IMAGE_USER=${{ github.actor }} CI=true ./hack/upgrade-builder-image.sh"], fileFilters: ["Makefile", ".github/**/*.yml", ".builder-image-version.txt", ".github/**/*.yaml"], executionMode: "branch"}' with: configurationFile: ${{ env.RENOVATE_CONFIG_FILE }} diff --git a/.gitignore b/.gitignore index c880f366..7035b917 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,6 @@ temp .reports # build and release dist -csmctl +csctl tmp/ releases/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 200c2bc2..a184e406 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,7 +1,7 @@ -project_name: csmctl +project_name: csctl builds: - - binary: csmctl + - binary: csctl goos: - linux goarch: diff --git a/Makefile b/Makefile index c0638359..08abf7a6 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ TAG ?= dev ARCH ?= amd64 IMAGE_PREFIX ?= ghcr.io/sovereigncloudstack -BUILDER_IMAGE = $(IMAGE_PREFIX)/csmctl-builder +BUILDER_IMAGE = $(IMAGE_PREFIX)/csctl-builder BUILDER_IMAGE_VERSION = $(shell cat .builder-image-version.txt) # Certain aspects of the build are done in containers for consistency (e.g. protobuf generation) @@ -44,8 +44,8 @@ export GOBIN := $(abspath $(TOOLS_BIN_DIR)) # Common # ########## .PHONY: build -build: ## build the csmctl binary - go build -o csmctl main.go +build: ## build the csctl binary + go build -o csctl main.go .PHONY: lint-golang lint-golang: ## Lint Golang codebase diff --git a/README.md b/README.md index 87230931..ad350729 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ -# CSMCTL +# CSCTL ## Table of Contents -- [CSMCTL](#csmctl) +- [CSCTL](#csctl) - [Table of Contents](#table-of-contents) - [Introduction](#introduction) - - [Features of csmctl](#features-of-csmctl) + - [Features of csctl](#features-of-csctl) + - [Docs](#docs) ## Introduction @@ -16,18 +17,18 @@ Users can take existing releases of Cluster Stacks and the operator and will be This project facilitates building node image artifacts and release assets that can be used with the Cluster Stack Operator. -## Features of csmctl +## Features of csctl 1. Testing and quick iterations -csmctl is created with a single focus of building Cluster Stacks and testing them with Cluster Stack Operator quickly. This tool helps in doing quick iterations and facilitates testing Cluster Stacks. +csctl is created with a single focus of building Cluster Stacks and testing them with Cluster Stack Operator quickly. This tool helps in doing quick iterations and facilitates testing Cluster Stacks. 2. Versioning -When configuring Cluster Stacks, it is necessary to put versions in the configuration, e.g. to version a Helm chart or node images. This process is facilitated by the csmctl through its own templating and mechanism to generate the right version, based on the content hash (for testing) or on a previous version (stable or beta channel). Users only have to use the right templating and the csmctl will do all the versioning automatically. +When configuring Cluster Stacks, it is necessary to put versions in the configuration, e.g. to version a Helm chart or node images. This process is facilitated by the csctl through its own templating and mechanism to generate the right version, based on the content hash (for testing) or on a previous version (stable or beta channel). Users only have to use the right templating and the csctl will do all the versioning automatically. 3. Plugin mechanism for providers -The plugin mechanism of csmctl allows providers to implement all provider-specific steps that are needed for this provider. This can contain a fully automated building and uploading process for node images, which can be referenced in the Cluster Stack (using the templating logic for versioning). +The plugin mechanism of csctl allows providers to implement all provider-specific steps that are needed for this provider. This can contain a fully automated building and uploading process for node images, which can be referenced in the Cluster Stack (using the templating logic for versioning). 4. Automated testing of Cluster Stacks -The csmctl enables automated testing of Cluster Stacks if integrated in a CI process that first builds all necessary files as well as node images (if needed) and then uses them to create a workload cluster based on the Cluster Stack. +The csctl enables automated testing of Cluster Stacks if integrated in a CI process that first builds all necessary files as well as node images (if needed) and then uses them to create a workload cluster based on the Cluster Stack. ## Docs diff --git a/docs/README.md b/docs/README.md index 39e66d02..3ada3fa2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,19 +1,19 @@ -# csmctl documentation +# csctl documentation ## Build your own Cluster Stack -Using csmctl to build a Cluster Stack requires a certain directory structure. See [here](./preparing_your_clusterstack_directory.md) for more details. +Using csctl to build a Cluster Stack requires a certain directory structure. See [here](./preparing_your_clusterstack_directory.md) for more details. ## Building your own plugin If you need a plugin for your provider and your Cluster Stack that automates building and uploading of node images. -## Using csmctl +## Using csctl -Do you have your Cluster Stack configured already? Is your plugin ready if you need it? Then check out [how to use](how_to_use_csmctl.md) the CLI tool! +Do you have your Cluster Stack configured already? Is your plugin ready if you need it? Then check out [how to use](how_to_use_csctl.md) the CLI tool! -## Developing and testing csmctl +## Developing and testing csctl -You want to improve or test `csmctl`? +You want to improve or test `csctl`? -You can find the introduction in [developing and testing csmctl](./developing-and-testing-csmctl.md) \ No newline at end of file +You can find the introduction in [developing and testing csctl](./developing-and-testing-csctl.md) \ No newline at end of file diff --git a/docs/design.md b/docs/design.md index d73c288e..7d338bf8 100644 --- a/docs/design.md +++ b/docs/design.md @@ -1,4 +1,4 @@ -# CSMCTL - Design document +# CSCTL - Design document # Introduction @@ -20,7 +20,7 @@ The current process of building cluster stacks is rather cumbersome and error-pr # Proposal -We propose a CLI tool called “csmctl”, which stands for cluster-stack-manager-ctl. This CLI tool should take over all manual work from a developer implementing cluster stacks that can be taken over. The developer should concentrate only on implementing the cluster stacks themselves. +We propose a CLI tool called “csctl”, which stands for cluster-stack-manager-ctl. This CLI tool should take over all manual work from a developer implementing cluster stacks that can be taken over. The developer should concentrate only on implementing the cluster stacks themselves. There will be still a certain way of dealing with “cluster stack-specific” jobs, e.g. following a certain templating pattern. This is necessary, as the configuration and Helm Charts that developers implement are very generic. @@ -40,16 +40,16 @@ A developer who has to think about how to version a cluster stack that was imple If multiple developers work on one cluster stack, they might interfere with each other’s work. Assuming that node images have to be built, then one developer would upload the node images in version “v2”, as the previous version was “v1”. The second developer has the same thought and would either overwrite the already uploaded node images of the colleague or not be able to upload the images since they exist already. -The csmctl allows both developers to have independent versioning based on a git commit hash. +The csctl allows both developers to have independent versioning based on a git commit hash. ### User story 4: Developer updating cluster stack that is used in production -If a developer updates a cluster stack that is used in production, great care is needed. The csmctl allows the developer to safely test cluster stacks, e.g. with a beta channel, without touching cluster stacks that are used in production. -If everything works well, a production release can be generated with csmctl. +If a developer updates a cluster stack that is used in production, great care is needed. The csctl allows the developer to safely test cluster stacks, e.g. with a beta channel, without touching cluster stacks that are used in production. +If everything works well, a production release can be generated with csctl. ### User story 5: Automated testing of cluster stacks -Cluster stacks cannot be tested in the CI and with a normal Git PR flow. The csmctl allows this testing of individual PRs and therefore enables automated testing via CI. +Cluster stacks cannot be tested in the CI and with a normal Git PR flow. The csctl allows this testing of individual PRs and therefore enables automated testing via CI. # Risks & Mitigations @@ -57,7 +57,7 @@ Cluster stacks cannot be tested in the CI and with a normal Git PR flow. The csm Helm charts use Go templating with the notation `{{ .values.myvalue }}`. As a cluster stack consists usually of two Helm charts, this notation will be very common. -However, the csmctl requires a different form of templating, additionally to the one of Helm. This comes from the versioning of the cluster stacks themselves. The Cluster addon version, for example, has to be the version of the respective Helm chart. The same goes for the `ClusterClass` object name. +However, the csctl requires a different form of templating, additionally to the one of Helm. This comes from the versioning of the cluster stacks themselves. The Cluster addon version, for example, has to be the version of the respective Helm chart. The same goes for the `ClusterClass` object name. Users have to use the additional templating notation `<< .ClusterAddonVersion >>` while implementing cluster stacks. @@ -67,42 +67,42 @@ The alternative to using a different notation for cluster stack templating would ## Generic vs provider-specific work -Just like the Cluster Stack Operator, the csmctl also has a generic and a provider-specific part. The provider-specific part is optional. +Just like the Cluster Stack Operator, the csctl also has a generic and a provider-specific part. The provider-specific part is optional. -The generic work is done with a CLI tool that exists in the repository csmctl in SCS. The tool can be initialized with provider-specific binaries, similar to the way [packer](https://github.com/hashicorp/packer) does it. +The generic work is done with a CLI tool that exists in the repository csctl in SCS. The tool can be initialized with provider-specific binaries, similar to the way [packer](https://github.com/hashicorp/packer) does it. ## Generic work -The generic part of the csmctl is +The generic part of the csctl is 1. Calculate the right versions based on git commit hash or previous releases -2. Template everything with csmctl templating (NOT Helm templating!!) +2. Template everything with csctl templating (NOT Helm templating!!) 3. Package the ClusterClass Helm Chart 4. Package the ClusterAddon Helm Chart 5. Generate metadata.yaml ## Provider-specific work -The provider-specific part of csmctl would do anything necessary to provide node images to users. One common task could be to use packer to build images and to upload them somewhere they can be accessed by users. +The provider-specific part of csctl would do anything necessary to provide node images to users. One common task could be to use packer to build images and to upload them somewhere they can be accessed by users. Of course, one task would also be to find the right version for the node images (e.g. v2 if something changed since v1, or simply the git commit hash) ## Configuration -There are multiple ways of configuring the csmctl. They all have specific use cases and will be explained in the following +There are multiple ways of configuring the csctl. They all have specific use cases and will be explained in the following ### Configuration file -There is a configuration file called `csmctl.yaml` which contains all values that will never have to be changed for a specific cluster stack. It follows this pattern: +There is a configuration file called `csctl.yaml` which contains all values that will never have to be changed for a specific cluster stack. It follows this pattern: ```yaml -apiVersion: csmctl.clusterstack.x-k8s.io/v1alpha1 +apiVersion: csctl.clusterstack.x-k8s.io/v1alpha1 config: kubernetesVersion: v1.27.7 clusterStackName: ferrol provider: type: myprovider - apiVersion: myprovider.csmctl.clusterstack.x-k8s.io/v1alpha1 + apiVersion: myprovider.csctl.clusterstack.x-k8s.io/v1alpha1 config: xyz ``` @@ -114,7 +114,7 @@ Via flags the user can specifiy everything that is important but which might cha ### Environment variables -Environment variables can be used, for example, to specify tokens and passwords. csmctl has to validate that all required environment variables have been specified. +Environment variables can be used, for example, to specify tokens and passwords. csctl has to validate that all required environment variables have been specified. ## Commands of CLI tool @@ -143,7 +143,7 @@ There are multiple modes to create release assets following different versioning ### Stable -The stable mode requires the developer to specify an existing GitHub repository (in the future other ways of storing release assets are possible) via environment variables. The csmctl will search for the latest release fitting to the configuration of provider, cluster stack name, and Kubernetes version (e.g. docker-ferrol-1-27-vXXX). Then it will download the required release assets and check whether anything has changed in the cluster addon and node image section. Depending on that information it will calculate the next version, e.g. v2 after v1, or will leave the version the same if nothing changed. +The stable mode requires the developer to specify an existing GitHub repository (in the future other ways of storing release assets are possible) via environment variables. The csctl will search for the latest release fitting to the configuration of provider, cluster stack name, and Kubernetes version (e.g. docker-ferrol-1-27-vXXX). Then it will download the required release assets and check whether anything has changed in the cluster addon and node image section. Depending on that information it will calculate the next version, e.g. v2 after v1, or will leave the version the same if nothing changed. ### Hash @@ -157,4 +157,4 @@ The beta mode is similar to the stable mode, except that it generates releases f ### Custom (e.g. for PRs) -The custom mode is designed for PR purposes and supports automated testing. It accommodates versions formatted as v0.custom-pr123. Crucially, these versions must adhere to semantic versioning standards (semver) and are specifically intended as inputs for the csmctl tool. +The custom mode is designed for PR purposes and supports automated testing. It accommodates versions formatted as v0.custom-pr123. Crucially, these versions must adhere to semantic versioning standards (semver) and are specifically intended as inputs for the csctl tool. diff --git a/docs/developing-and-testing-csmctl.md b/docs/developing-and-testing-csctl.md similarity index 65% rename from docs/developing-and-testing-csmctl.md rename to docs/developing-and-testing-csctl.md index ce506dbf..de66a4e9 100644 --- a/docs/developing-and-testing-csmctl.md +++ b/docs/developing-and-testing-csctl.md @@ -1,15 +1,15 @@ -# Developing and Testing csmctl +# Developing and Testing csctl ## Clone the Repo -Go to [csmctl at Github](https://github.com/SovereignCloudStack/csmctl/) and clone the repository to your local device: +Go to [csctl at Github](https://github.com/SovereignCloudStack/csctl/) and clone the repository to your local device: ```shell -git clone git@github.com:SovereignCloudStack/csmctl.git +git clone git@github.com:SovereignCloudStack/csctl.git ``` ```shell -cd csmctl +cd csctl ``` ## Makefile @@ -22,17 +22,17 @@ You can see the available build targets with `make help`. With `make build` you create the executable. -## csmctl --help +## csctl --help -With `./csmctl --help` you can see the available sub-commands. +With `./csctl --help` you can see the available sub-commands. -BTW: Be sure to use `./`, so that you don't accidentally use a different `csmctl` from your `$PATH`. +BTW: Be sure to use `./`, so that you don't accidentally use a different `csctl` from your `$PATH`. Up to now only `create` is a feasible sub-command. ## go run main.go ... -If you modify the source of `csmctl`, you can skip the build step by using `go run`: +If you modify the source of `csctl`, you can skip the build step by using `go run`: ```shell go run main.go create --help diff --git a/docs/how_to_use_csmctl.md b/docs/how_to_use_csctl.md similarity index 73% rename from docs/how_to_use_csmctl.md rename to docs/how_to_use_csctl.md index d1d91228..1d3f8781 100644 --- a/docs/how_to_use_csmctl.md +++ b/docs/how_to_use_csctl.md @@ -1,7 +1,7 @@ -# Using csmctl +# Using csctl -## What does csmctl do? +## What does csctl do? As a user, you can create clusters based on Cluster Stacks with the help of the Cluster Stack Operator. The operator needs certain files, e.g. to apply the required Helm charts, and to get the necessary information about the versions in the cluster stack. @@ -9,9 +9,9 @@ In order to not generate these files manually, this CLI tool takes a certain pre Therefore, this tool can be used to configure Cluster Stacks and to test them with the Cluster Stack Operator. It can also be used to release stable releases of Cluster Stacks that can be published for a broader community. -## Different modes of csmctl +## Different modes of csctl -The csmctl has multiple modes that can be used for different use cases. +The csctl has multiple modes that can be used for different use cases. ### Hash mode @@ -30,21 +30,21 @@ Similar to stable mode, but for a beta release channel. It versions according to The custom mode can be used to define your own version. You can input any semver version and your cluster stack will be versioned accordingly. -## Installing csmctl -You can click on the respective release of csmctl on GitHub and download the binary. +## Installing csctl +You can click on the respective release of csctl on GitHub and download the binary. -Assuming, you have downloaded the `csmctl_0.0.2_linux_amd64` binary in your Downloads directory, you will need the following commands to rename the binary and to give it executable permissions. +Assuming, you have downloaded the `csctl_0.0.2_linux_amd64` binary in your Downloads directory, you will need the following commands to rename the binary and to give it executable permissions. ```bash -$ sudo chmod u+x ~/Downloads/csmctl_0.0.2_linux_amd64 -$ sudo mv ~/Downloads/csmctl_0.0.2_linux_amd64 /usr/local/bin/csmctl # or use any bin directory from your PATH +$ sudo chmod u+x ~/Downloads/csctl_0.0.2_linux_amd64 +$ sudo mv ~/Downloads/csctl_0.0.2_linux_amd64 /usr/local/bin/csctl # or use any bin directory from your PATH ``` -Then you can check whether everything worked by printing the version of csmctl. +Then you can check whether everything worked by printing the version of csctl. ```bash -$ csmctl version -csmctl version: 0.0.2 +$ csctl version +csctl version: 0.0.2 commit: f252304eb013014b35f8a91abf1f61aff2062601 ``` @@ -53,7 +53,7 @@ If you don't see a version there, then something has gone wrong. Re-check above If you're using `gh` CLI then you can also use the following to download it. ```bash -$ gh release download -p csmctl_0.0.2_linux_amd64 -R SovereignCloudStack/csmctl +$ gh release download -p csctl_0.0.2_linux_amd64 -R SovereignCloudStack/csctl ``` ## Creating Cluster Stacks @@ -61,7 +61,7 @@ $ gh release download -p csmctl_0.0.2_linux_amd64 -R SovereignCloudStack/csmctl The most important subcommand is `create`. This command takes a path to the directory where you configured your Cluster Stack and generates the necessary files in the output directory via the `--output` flag: ```bash -$ csmctl create --output +$ csctl create --output ``` You can specify your node image registry with the flag `--node-image-registry`. The plugin of your provider will update the node images in the respective container registry. @@ -71,7 +71,7 @@ You can use the `--mode` flag to specify the mode you want to use. For example: ```bash -$ csmctl create --output --mode hash --node-image-registry +$ csctl create --output --mode hash --node-image-registry ``` You have to be authenticated to your cloud provider and container registry to which you want to upload the node images. \ No newline at end of file diff --git a/docs/preparing_your_clusterstack_directory.md b/docs/preparing_your_clusterstack_directory.md index 1cc1ca26..cc5ec4ea 100644 --- a/docs/preparing_your_clusterstack_directory.md +++ b/docs/preparing_your_clusterstack_directory.md @@ -4,35 +4,35 @@ A [Cluster Stack](https://github.com/SovereignCloudStack/cluster-stacks) is full The Cluster Stack Operator facilitates using Cluster Stacks by automating all steps that users would have to do manually given they have a Cluster API management cluster. -The csmctl helps to generate all files and build node images based on provided scripts in a format that the Cluster Stack Operator can use. +The csctl helps to generate all files and build node images based on provided scripts in a format that the Cluster Stack Operator can use. -The csmctl requires a certain directory structure and uses a special form of templating to insert the right versions in your configuration files (e.g. Helm charts). +The csctl requires a certain directory structure and uses a special form of templating to insert the right versions in your configuration files (e.g. Helm charts). ## Overview -The directory structure is very important. If the directories are not configured properly, csmctl will not be able to build the cluster-stack for you. +The directory structure is very important. If the directories are not configured properly, csctl will not be able to build the cluster-stack for you. You should must have the following content inside your directory: -- csmctl.yaml: the configuration of csmctl +- csctl.yaml: the configuration of csctl - cluster-addon directory: the directory containing the Helm chart for cluster addons (Chart.yaml, templates and Helm related files if required) - cluster-class directory: the directory containing the Helm chart for Cluster API resources, e.g. ClusterClass (Chart.yaml, templates and Helm related files if required) - node-image directory (optional): the directory containing config and associated scripts to build node images -## Configuring csmctl -The configuration of csmctl has to be specified in the `csmctl.yaml`. It needs to follow this structure: +## Configuring csctl +The configuration of csctl has to be specified in the `csctl.yaml`. It needs to follow this structure: ```yaml -apiVersion: csmctl.clusterstack.x-k8s.io/v1alpha1 +apiVersion: csctl.clusterstack.x-k8s.io/v1alpha1 config: kubernetesVersion: v1.27.7 clusterStackName: ferrol provider: type: - apiVersion: .csmctl.clusterstack.x-k8s.io/v1alpha1 + apiVersion: .csctl.clusterstack.x-k8s.io/v1alpha1 config: ``` -The apiVersion specifies the version of this configuration. Currently, there is only the version `csmctl.clusterstack.x-k8s.io/v1alpha1`. +The apiVersion specifies the version of this configuration. Currently, there is only the version `csctl.clusterstack.x-k8s.io/v1alpha1`. Furthermore, the Kubernetes version in the format "v.." (e.g. 1.27.5) has to be specified as well as the name that should be given to the Cluster Stack. @@ -41,7 +41,7 @@ Depending on your plugin, there might be a provider-specific configuration. ## Templating the versions -There are three different versions in a Cluster Stack that can be templated by `csmctl`: +There are three different versions in a Cluster Stack that can be templated by `csctl`: ```markdown - << .ClusterAddonVersion >> diff --git a/go.mod b/go.mod index d0db30c2..ca1c7985 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/SovereignCloudStack/csmctl +module github.com/SovereignCloudStack/csctl go 1.21 diff --git a/hack/upgrade-builder-image.sh b/hack/upgrade-builder-image.sh index 1a183353..e762dbfb 100755 --- a/hack/upgrade-builder-image.sh +++ b/hack/upgrade-builder-image.sh @@ -25,7 +25,7 @@ set -o errexit set -o nounset set -o pipefail -export BUILDER_IMAGE=ghcr.io/sovereigncloudstack/csmctl-builder +export BUILDER_IMAGE=ghcr.io/sovereigncloudstack/csctl-builder REPO_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}")/..) cd "${REPO_ROOT}" || exit 1 @@ -58,12 +58,12 @@ fi echo "$NEW_VERSION" > .builder-image-version.txt echo "Wrote new version $NEW_VERSION to .builder-image-version.txt" -if docker manifest inspect ghcr.io/sovereigncloudstack/csmctl-builder:${NEW_VERSION} > /dev/null ; echo $?; then +if docker manifest inspect ghcr.io/sovereigncloudstack/csctl-builder:${NEW_VERSION} > /dev/null ; echo $?; then sed -i -e "/^BUILDER_IMAGE_VERSION /s/:=.*$/:= ${NEW_VERSION}/" Makefile - grep -r -E 'ghcr.io/sovereigncloudstack/csmctl-builder:[0-9].*.*' -l | xargs sed -i -e "s/ghcr.io\/sovereigncloudstack\/csmctl-builder:${VERSION}/ghcr.io\/sovereigncloudstack\/csmctl-builder:${NEW_VERSION}/g" - docker build -t ghcr.io/sovereigncloudstack/csmctl-builder:${NEW_VERSION} ./images/builder - docker push ghcr.io/sovereigncloudstack/csmctl-builder:${NEW_VERSION} + grep -r -E 'ghcr.io/sovereigncloudstack/csctl-builder:[0-9].*.*' -l | xargs sed -i -e "s/ghcr.io\/sovereigncloudstack\/csctl-builder:${VERSION}/ghcr.io\/sovereigncloudstack\/csctl-builder:${NEW_VERSION}/g" + docker build -t ghcr.io/sovereigncloudstack/csctl-builder:${NEW_VERSION} ./images/builder + docker push ghcr.io/sovereigncloudstack/csctl-builder:${NEW_VERSION} else exit 1 fi diff --git a/images/builder/Dockerfile b/images/builder/Dockerfile index 23ca81ce..d9f23202 100644 --- a/images/builder/Dockerfile +++ b/images/builder/Dockerfile @@ -43,7 +43,7 @@ FROM docker.io/hadolint/hadolint:v2.12.0-alpine@sha256:7dba9a9f1a0350f6d021fb2f6 FROM docker.io/aquasec/trivy:0.49.0@sha256:c71420cd77f136e8e900f71d272fb89075f6011019bdcb4b5f7c8e4212f9025e as trivy ############################ -# csmctl Build Image Base # +# csctl Build Image Base # ############################ FROM docker.io/library/golang:1.21.6-bullseye@sha256:a8712f27d9ac742e7bded8f81f7547c5635e855e8b80302e8fc0ce424f559295 diff --git a/images/builder/build.sh b/images/builder/build.sh index 94162d56..71868f8e 100755 --- a/images/builder/build.sh +++ b/images/builder/build.sh @@ -20,8 +20,8 @@ SRC_PATH=/src uid=$(stat --format="%u" "${SRC_PATH}") gid=$(stat --format="%g" "${SRC_PATH}") -echo "csmctl:x:${uid}:${gid}::${SRC_PATH}:/bin/bash" >>/etc/passwd -echo "csmctl:*:::::::" >>/etc/shadow -echo "csmctl ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers +echo "csctl:x:${uid}:${gid}::${SRC_PATH}:/bin/bash" >>/etc/passwd +echo "csctl:*:::::::" >>/etc/shadow +echo "csctl ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers -su csmctl -c "PATH=${PATH} make -C ${SRC_PATH} BUILD_IN_CONTAINER=false $*" \ No newline at end of file +su csctl -c "PATH=${PATH} make -C ${SRC_PATH} BUILD_IN_CONTAINER=false $*" \ No newline at end of file diff --git a/main.go b/main.go index 927dfdb5..9eb0fb4b 100644 --- a/main.go +++ b/main.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package main is the entrypoint for csmctl. +// Package main is the entrypoint for csctl. package main -import "github.com/SovereignCloudStack/csmctl/pkg/cmd" +import "github.com/SovereignCloudStack/csctl/pkg/cmd" func main() { cmd.Execute() diff --git a/pkg/clusterstack/config.go b/pkg/clusterstack/config.go index cf69d8c0..e887bf69 100644 --- a/pkg/clusterstack/config.go +++ b/pkg/clusterstack/config.go @@ -30,8 +30,8 @@ import ( "gopkg.in/yaml.v3" ) -// CsmctlConfig contains information of CsmctlConfig yaml. -type CsmctlConfig struct { +// CsctlConfig contains information of CsctlConfig yaml. +type CsctlConfig struct { APIVersion string `yaml:"apiVersion"` Config struct { KubernetesVersion string `yaml:"kubernetesVersion"` @@ -44,53 +44,53 @@ type CsmctlConfig struct { } `yaml:"config"` } -// GetCsmctlConfig returns CsmctlConfig. -func GetCsmctlConfig(path string) (CsmctlConfig, error) { - configPath := filepath.Join(path, "csmctl.yaml") +// GetCsctlConfig returns CsctlConfig. +func GetCsctlConfig(path string) (CsctlConfig, error) { + configPath := filepath.Join(path, "csctl.yaml") configFileData, err := os.ReadFile(filepath.Clean(configPath)) if err != nil { - return CsmctlConfig{}, fmt.Errorf("failed to read csmctl config: %w", err) + return CsctlConfig{}, fmt.Errorf("failed to read csctl config: %w", err) } - cs := CsmctlConfig{} + cs := CsctlConfig{} if err := yaml.Unmarshal(configFileData, &cs); err != nil { - return CsmctlConfig{}, fmt.Errorf("failed to unmarshal csmctl yaml: %w", err) + return CsctlConfig{}, fmt.Errorf("failed to unmarshal csctl yaml: %w", err) } if cs.Config.Provider.Type == "" { - return CsmctlConfig{}, fmt.Errorf("provider type must not be empty") + return CsctlConfig{}, fmt.Errorf("provider type must not be empty") } if len(cs.Config.Provider.Type) > 253 { - return CsmctlConfig{}, fmt.Errorf("provider name must not be greater than 253") + return CsctlConfig{}, fmt.Errorf("provider name must not be greater than 253") } match, err := regexp.MatchString(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`, cs.Config.Provider.Type) if err != nil { - return CsmctlConfig{}, fmt.Errorf("failed to provider name match regex: %w", err) + return CsctlConfig{}, fmt.Errorf("failed to provider name match regex: %w", err) } if !match { - return CsmctlConfig{}, fmt.Errorf("invalid provider type: %q", cs.Config.Provider.Type) + return CsctlConfig{}, fmt.Errorf("invalid provider type: %q", cs.Config.Provider.Type) } if cs.Config.ClusterStackName == "" { - return CsmctlConfig{}, fmt.Errorf("cluster stack name must not be empty") + return CsctlConfig{}, fmt.Errorf("cluster stack name must not be empty") } // Validate kubernetes version matched, err := regexp.MatchString(`^v\d+\.\d+\.\d+$`, cs.Config.KubernetesVersion) if err != nil { - return CsmctlConfig{}, fmt.Errorf("failed to kubernetes match regex: %w", err) + return CsctlConfig{}, fmt.Errorf("failed to kubernetes match regex: %w", err) } if !matched { - return CsmctlConfig{}, fmt.Errorf("invalid kubernetes version: %q", cs.Config.KubernetesVersion) + return CsctlConfig{}, fmt.Errorf("invalid kubernetes version: %q", cs.Config.KubernetesVersion) } return cs, nil } -// ParseKubernetesVersion parse the kubernetes version present in the Csmctl Config. -func (c *CsmctlConfig) ParseKubernetesVersion() (kubernetesversion.KubernetesVersion, error) { +// ParseKubernetesVersion parse the kubernetes version present in the Csctl Config. +func (c *CsctlConfig) ParseKubernetesVersion() (kubernetesversion.KubernetesVersion, error) { splitted := strings.Split(c.Config.KubernetesVersion, ".") if len(splitted) != 3 { @@ -115,7 +115,7 @@ func (c *CsmctlConfig) ParseKubernetesVersion() (kubernetesversion.KubernetesVer // GetClusterStackReleaseDirectoryName returns cluster stack release directory. // e.g. - docker-ferrol-1-27-v1/ . -func GetClusterStackReleaseDirectoryName(metadata *MetaData, config *CsmctlConfig) (string, error) { +func GetClusterStackReleaseDirectoryName(metadata *MetaData, config *CsctlConfig) (string, error) { // Parse the cluster stack version from dot format `v1-alpha.0` to a version way of struct // and parse the kubernetes version from `v1.27.3` to a major minor way // and create the release directory at the end. diff --git a/pkg/clusterstack/mode.go b/pkg/clusterstack/mode.go index 3f1ac147..c0a1fdf9 100644 --- a/pkg/clusterstack/mode.go +++ b/pkg/clusterstack/mode.go @@ -3,8 +3,8 @@ package clusterstack import ( "fmt" - "github.com/SovereignCloudStack/csmctl/pkg/git" - "github.com/SovereignCloudStack/csmctl/pkg/hash" + "github.com/SovereignCloudStack/csctl/pkg/git" + "github.com/SovereignCloudStack/csctl/pkg/hash" ) // HandleStableMode returns metadata for the stable mode. diff --git a/pkg/cmd/create.go b/pkg/cmd/create.go index 74d51a99..d758d47d 100644 --- a/pkg/cmd/create.go +++ b/pkg/cmd/create.go @@ -22,10 +22,10 @@ import ( "os" "path/filepath" - "github.com/SovereignCloudStack/csmctl/pkg/clusterstack" - "github.com/SovereignCloudStack/csmctl/pkg/github" - "github.com/SovereignCloudStack/csmctl/pkg/hash" - "github.com/SovereignCloudStack/csmctl/pkg/template" + "github.com/SovereignCloudStack/csctl/pkg/clusterstack" + "github.com/SovereignCloudStack/csctl/pkg/github" + "github.com/SovereignCloudStack/csctl/pkg/hash" + "github.com/SovereignCloudStack/csctl/pkg/template" "github.com/spf13/cobra" "gopkg.in/yaml.v3" ) @@ -42,9 +42,9 @@ var ( Supported modes are - stable, alpha, beta, hash note - Hash mode takes the last hash of the git commit.` - example = `csmctl create tests/cluster-stacks/docker/ferrol -m hash (for hash mode) + example = `csctl create tests/cluster-stacks/docker/ferrol -m hash (for hash mode) - csmctl create tests/cluster-stacks/docker/ferrol -m hash --github-release github-release/ (for stable mode)` + csctl create tests/cluster-stacks/docker/ferrol -m hash --github-release github-release/ (for stable mode)` ) var ( @@ -58,7 +58,7 @@ var ( type CreateOptions struct { ClusterStackPath string ClusterStackReleaseDir string - Config clusterstack.CsmctlConfig + Config clusterstack.CsctlConfig Metadata clusterstack.MetaData CurrentReleaseHash hash.ReleaseHash LatestReleaseHash hash.ReleaseHash @@ -86,7 +86,7 @@ func GetCreateOptions(clusterStackPath string) (*CreateOptions, error) { createOption := &CreateOptions{} // ClusterAddon config - config, err := clusterstack.GetCsmctlConfig(clusterStackPath) + config, err := clusterstack.GetCsctlConfig(clusterStackPath) if err != nil { return nil, fmt.Errorf("failed to get config: %w", err) } diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index 1fd041bf..95503df4 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -25,7 +25,7 @@ import ( // rootCmd represents the base command when called without any subcommands. var rootCmd = &cobra.Command{ - Use: "csmctl", + Use: "csctl", Short: "It is used to create cluster stack release.", Long: `It is used building release artifacts using cluster stack template and by calculating latest GitHub release hash.`, diff --git a/pkg/github/release.go b/pkg/github/release.go index ce66b154..a96ed86a 100644 --- a/pkg/github/release.go +++ b/pkg/github/release.go @@ -24,7 +24,7 @@ import ( "path/filepath" "strings" - "github.com/SovereignCloudStack/csmctl/pkg/hash" + "github.com/SovereignCloudStack/csctl/pkg/hash" ) // GHRelease contains fields for a release. diff --git a/pkg/template/template.go b/pkg/template/template.go index 0a6f53f0..b185bd89 100644 --- a/pkg/template/template.go +++ b/pkg/template/template.go @@ -22,15 +22,15 @@ import ( "os" "path/filepath" - csmctlclusterstack "github.com/SovereignCloudStack/csmctl/pkg/clusterstack" + csctlclusterstack "github.com/SovereignCloudStack/csctl/pkg/clusterstack" "github.com/valyala/fasttemplate" ) // CustomWalkFunc is the type for the walk function. -type CustomWalkFunc func(src, dst, path string, info os.FileInfo, meta *csmctlclusterstack.MetaData) error +type CustomWalkFunc func(src, dst, path string, info os.FileInfo, meta *csctlclusterstack.MetaData) error // MyWalk is the custom walking function to walk in the cluster stacks. -func MyWalk(src, dst string, walkFn CustomWalkFunc, meta *csmctlclusterstack.MetaData) error { +func MyWalk(src, dst string, walkFn CustomWalkFunc, meta *csctlclusterstack.MetaData) error { if err := filepath.Walk(src, func(path string, info os.FileInfo, err error) error { return walkFn(src, dst, path, info, meta) }); err != nil { @@ -40,7 +40,7 @@ func MyWalk(src, dst string, walkFn CustomWalkFunc, meta *csmctlclusterstack.Met return nil } -func visitFile(src, dst, path string, info os.FileInfo, meta *csmctlclusterstack.MetaData) error { +func visitFile(src, dst, path string, info os.FileInfo, meta *csctlclusterstack.MetaData) error { relativePath, err := filepath.Rel(src, path) if err != nil { return fmt.Errorf("failed to relate directory: %w", err) @@ -78,6 +78,6 @@ func visitFile(src, dst, path string, info os.FileInfo, meta *csmctlclusterstack } // GenerateOutputFromTemplate is used to generate the template with replaced values. -func GenerateOutputFromTemplate(src, dst string, meta *csmctlclusterstack.MetaData) error { +func GenerateOutputFromTemplate(src, dst string, meta *csctlclusterstack.MetaData) error { return MyWalk(src, dst, visitFile, meta) } diff --git a/tests/cluster-stacks/docker/ferrol/csctl.yaml b/tests/cluster-stacks/docker/ferrol/csctl.yaml new file mode 100644 index 00000000..592fd44c --- /dev/null +++ b/tests/cluster-stacks/docker/ferrol/csctl.yaml @@ -0,0 +1,7 @@ +apiVersion: csctl.clusterstack.x-k8s.io/v1alpha1 +config: + kubernetesVersion: v1.27.7 + clusterStackName: ferrol + provider: + type: docker + apiVersion: docker.csctl.clusterstack.x-k8s.io/v1alpha1 diff --git a/tests/cluster-stacks/docker/ferrol/csmctl.yaml b/tests/cluster-stacks/docker/ferrol/csmctl.yaml deleted file mode 100644 index 326cf844..00000000 --- a/tests/cluster-stacks/docker/ferrol/csmctl.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: csmctl.clusterstack.x-k8s.io/v1alpha1 -config: - kubernetesVersion: v1.27.7 - clusterStackName: ferrol - provider: - type: docker - apiVersion: docker.csmctl.clusterstack.x-k8s.io/v1alpha1