-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from dream11/development
Release odin version 1.2.0-beta.2
- Loading branch information
Showing
10 changed files
with
116 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package envtype | ||
|
||
// ListResponse interface | ||
type ListTypeResponse struct { | ||
Response []string `yaml:"resp,omitempty" json:"resp,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package backend | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/dream11/odin/api/envtype" | ||
) | ||
|
||
// Env entity | ||
type EnvType struct{} | ||
|
||
// root entity | ||
var envEntityType = "envtypes" | ||
|
||
// ListEnv : list all environment(s) with filters | ||
func (e *EnvType) ListEnvType() ([]string, error) { | ||
client := newApiClient() | ||
response := client.actionWithRetry(envEntityType+"/", "GET", nil) | ||
response.Process(true) // process response and exit if error | ||
|
||
var envTypeResponse envtype.ListTypeResponse | ||
err := json.Unmarshal(response.Body, &envTypeResponse) | ||
|
||
return envTypeResponse.Response, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package commands | ||
|
||
import ( | ||
"github.com/dream11/odin/internal/backend" | ||
"github.com/dream11/odin/pkg/table" | ||
) | ||
|
||
// initiate backend client for environment type | ||
var envTypeClient backend.EnvType | ||
|
||
// Env : command declaration | ||
type EnvType command | ||
|
||
// Run : implements the actual functionality of the command | ||
func (e *EnvType) Run(args []string) int { | ||
|
||
if e.List { | ||
e.Logger.Info("Listing all env type\n") | ||
envTypeList, err := envTypeClient.ListEnvType() | ||
if err != nil { | ||
e.Logger.Error(err.Error()) | ||
return 1 | ||
} | ||
var tableHeaders []string | ||
var tableData [][]interface{} | ||
tableHeaders = []string{"Env Type"} | ||
for _, envType := range envTypeList { | ||
tableData = append(tableData, []interface{}{ | ||
envType, | ||
}) | ||
} | ||
table.Write(tableHeaders, tableData) | ||
|
||
return 0 | ||
} | ||
|
||
e.Logger.Error("Not a valid command") | ||
return 127 | ||
} | ||
|
||
// Help : returns an explanatory string | ||
func (e *EnvType) Help() string { | ||
|
||
if e.List { | ||
return commandHelper("list env-type", "env type", "", []Options{}) | ||
} | ||
|
||
return defaultHelper() | ||
} | ||
|
||
// Synopsis : returns a brief helper text for the command's verbs | ||
func (e *EnvType) Synopsis() string { | ||
|
||
if e.List { | ||
return "List env types" | ||
} | ||
return defaultHelper() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters