From 0268ec9df6b286def79fa062625b24d4dbe7615b Mon Sep 17 00:00:00 2001 From: Akshay Patidar Date: Wed, 20 Mar 2024 19:14:21 +0530 Subject: [PATCH] Develop to Main (#219) * fix: update go version (#212) Signed-off-by: Akshay Patidar * no hyphen at the end of env name (#216) * fix: make options optional (#218) Signed-off-by: Akshay Patidar --------- Signed-off-by: Akshay Patidar Co-authored-by: Susanth <110461367+boppanasusanth@users.noreply.github.com> --- .github/workflows/go-lint.yaml | 4 ++-- .github/workflows/release.yaml | 4 ++-- app/app.go | 2 +- internal/command/commands/component.go | 11 +++-------- internal/command/commands/env.go | 4 ++-- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/go-lint.yaml b/.github/workflows/go-lint.yaml index a3e69c44..4963a961 100644 --- a/.github/workflows/go-lint.yaml +++ b/.github/workflows/go-lint.yaml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v4 with: - version: v1.51.1 + version: v1.54 args: -E gofmt -E gci diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b0180b5a..9de3ec02 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -25,9 +25,9 @@ jobs: version: ${{ steps.commit.outputs.version }} message: ${{ steps.commit.outputs.version }} token: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/setup-go@v2 + - uses: actions/setup-go@v4 with: - go-version: '1.17.1' + go-version: "1.20.2" - name: Create Release Asset run: | make compressed-builds diff --git a/app/app.go b/app/app.go index f3e0a569..69fde420 100644 --- a/app/app.go +++ b/app/app.go @@ -8,5 +8,5 @@ type application struct { // App (Application) interface var App application = application{ Name: "odin", - Version: "1.3.2", + Version: "1.3.3", } diff --git a/internal/command/commands/component.go b/internal/command/commands/component.go index fa6febef..4e63a254 100644 --- a/internal/command/commands/component.go +++ b/internal/command/commands/component.go @@ -25,7 +25,7 @@ func (c *Component) Run(args []string) int { serviceName := flagSet.String("service", "", "name of the service in which the component is deployed") envName := flagSet.String("env", "", "name of the environment in which the service is deployed") operation := flagSet.String("operation", "", "name of the operation to performed on the component") - options := flagSet.String("options", "", "options of the operation in JSON format") + options := flagSet.String("options", "{}", "options of the operation in JSON format") filePath := flagSet.String("file", "", "file to provide options for component operations") err := flagSet.Parse(args) @@ -40,7 +40,7 @@ func (c *Component) Run(args []string) int { } emptyParameters := emptyParameters(map[string]string{"--name": *name, "--service": *serviceName, "--env": *envName, "--operation": *operation}) if len(emptyParameters) == 0 { - isOptionsPresent := len(*options) > 0 + isOptionsPresent := *options != "{}" isFilePresent := len(*filePath) > 0 if isOptionsPresent && isFilePresent { @@ -48,11 +48,6 @@ func (c *Component) Run(args []string) int { return 1 } - if !isOptionsPresent && !isFilePresent { - c.Logger.Error("You should provide either --options or --file") - return 1 - } - var optionsData map[string]interface{} if isFilePresent { @@ -62,7 +57,7 @@ func (c *Component) Run(args []string) int { return 1 } optionsData = parsedConfig.(map[string]interface{}) - } else if isOptionsPresent { + } else { err = json.Unmarshal([]byte(*options), &optionsData) if err != nil { c.Logger.Error("Unable to parse JSON data " + err.Error()) diff --git a/internal/command/commands/env.go b/internal/command/commands/env.go index b273a922..2f7ac2f0 100644 --- a/internal/command/commands/env.go +++ b/internal/command/commands/env.go @@ -63,8 +63,8 @@ func (e *Env) Run(args []string) int { e.Logger.Error("Env Name should not be of length more than 9") return 1 } - if (utils.SearchString(*name, "^[a-z][a-z0-9-]*$")) == "nil" { - e.Logger.Error("Env name only allows lower case alphabets, numbers and '-'. And should start with an alphabet.") + if (utils.SearchString(*name, "^[a-z]([a-z0-9-]*[a-z0-9])?$")) == "nil" { + e.Logger.Error("Env name only allows lower case alphabets, numbers and '-'. Should start with an alphabet and not end with a hyphen.") return 1 } envConfig := environment.Env{