diff --git a/.github/workflows/doc-generate.yml b/.github/workflows/doc-generate.yml new file mode 100644 index 0000000..05b2914 --- /dev/null +++ b/.github/workflows/doc-generate.yml @@ -0,0 +1,49 @@ +name: Generate commands documentation + +on: + push: + branches: + - develop + - hotfix/* + - feature/* + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.21 + + - name: Run GoReleaser artifact build + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: v1.23.0 + args: build --clean --skip=validate + + - name: Generate and commit new commands documentation + run: | + # constants for selecting branches + readonly GIT_BRANCH="${GITHUB_REF_NAME}" + readonly GITHUB_ORG="${GITHUB_REPOSITORY_OWNER}" + + echo "Configure Git user.name and user.email." + git config user.name github-actions + git config user.email github-actions@github.com + + echo "Generate new commands documentation." + ./dist/rmk_linux_amd64_v1/rmk doc generate > ./docs/commands.md + + if (git commit --all --message="Update commands documentation"); then + echo "The new commands documentation was committed." + fi diff --git a/commands/container_registry_category.go b/commands/container_registry_category.go index a73a260..7e93127 100644 --- a/commands/container_registry_category.go +++ b/commands/container_registry_category.go @@ -42,7 +42,7 @@ func (cr *CRCommands) dockerLogin() error { } if token, ok := credentials[cr.Conf.AWSECRUserName]; !ok { - return fmt.Errorf("failed to get token") + return fmt.Errorf("failed to get ECR token") } else { if cr.Ctx.Bool("get-token") { fmt.Println(token) diff --git a/commands/flags.go b/commands/flags.go index d828be0..e875706 100644 --- a/commands/flags.go +++ b/commands/flags.go @@ -190,11 +190,11 @@ func flagsConfigList() []cli.Flag { func flagsClusterK3DCreate() []cli.Flag { return append(flagsHidden(), &cli.StringFlag{ - Name: "k3d-volume-host-path", - Usage: "host local directory path for mount into K3D cluster", - Aliases: []string{"kv"}, - EnvVars: []string{"RMK_K3D_VOLUME_HOST_PATH"}, - Value: system.GetPwdPath(""), + Name: "k3d-volume-host-path", + Usage: "host local directory path for mount into K3D cluster", + Aliases: []string{"kv"}, + EnvVars: []string{"RMK_K3D_VOLUME_HOST_PATH"}, + DefaultText: "present working directory", }, ) } diff --git a/commands/k3d_category.go b/commands/k3d_category.go index 6e74beb..10a67ee 100644 --- a/commands/k3d_category.go +++ b/commands/k3d_category.go @@ -46,15 +46,21 @@ func (k *K3DCommands) prepareK3D(args ...string) error { return err } - for key, val := range credentials { - k.SpecCMD.Envs = append(k.SpecCMD.Envs, - "K3D_NAME="+k.Conf.Name, - "K3D_VOLUME_HOST_PATH="+k.Ctx.String("k3d-volume-host-path"), - "K3D_AWS_ECR_USER="+key, - "K3D_AWS_ECR_PASSWORD="+val, - ) + k.SpecCMD.Envs = append(k.SpecCMD.Envs, "K3D_NAME="+k.Conf.Name) + + if token, ok := credentials[k.Conf.AWSECRUserName]; !ok { + return fmt.Errorf("failed to get ECR token") + } else { + k.SpecCMD.Envs = append(k.SpecCMD.Envs, "K3D_AWS_ECR_USER="+k.Conf.AWSECRUserName, "K3D_AWS_ECR_PASSWORD="+token) + } + + if len(k.Ctx.String("k3d-volume-host-path")) > 0 { + k.SpecCMD.Envs = append(k.SpecCMD.Envs, "K3D_VOLUME_HOST_PATH="+k.Ctx.String("k3d-volume-host-path")) + return nil } + k.SpecCMD.Envs = append(k.SpecCMD.Envs, "K3D_VOLUME_HOST_PATH="+system.GetPwdPath("")) + return nil }