Skip to content

Commit

Permalink
Develop to Main (#219)
Browse files Browse the repository at this point in the history
* fix: update go version (#212)

Signed-off-by: Akshay Patidar <[email protected]>

* no hyphen at the end of env name (#216)

* fix: make options optional (#218)

Signed-off-by: Akshay Patidar <[email protected]>

---------

Signed-off-by: Akshay Patidar <[email protected]>
Co-authored-by: Susanth <[email protected]>
  • Loading branch information
akshaypatidar1999 and boppanasusanth authored Mar 20, 2024
1 parent ab15025 commit 0268ec9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ type application struct {
// App (Application) interface
var App application = application{
Name: "odin",
Version: "1.3.2",
Version: "1.3.3",
}
11 changes: 3 additions & 8 deletions internal/command/commands/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -40,19 +40,14 @@ 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 {
c.Logger.Error("You can provide either --options or --file but not both")
return 1
}

if !isOptionsPresent && !isFilePresent {
c.Logger.Error("You should provide either --options or --file")
return 1
}

var optionsData map[string]interface{}

if isFilePresent {
Expand All @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions internal/command/commands/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 0268ec9

Please sign in to comment.