Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Added changes suggested by goimports #509

Merged
merged 1 commit into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/cmd/add_repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ func Test_addRepoCmd_runPrompt(t *testing.T) {
wantErr: true,
},
{
name:
"Fail when repo.List return err",
name: "Fail when repo.List return err",
fields: fields{
repo: repoListerAdderCustomMock{
list: func() (formula.Repos, error) {
Expand Down
4 changes: 0 additions & 4 deletions pkg/cmd/create_formula_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ func TestCreateFormulaCmd(t *testing.T) {
LanguagesMock: func() ([]string, error) {
return []string{}, errors.New("error on language func")
},

},

},
wantErr: true,
},
Expand All @@ -119,10 +117,8 @@ func TestCreateFormulaCmd(t *testing.T) {
LanguagesMock: func() ([]string, error) {
return []string{}, nil
},

},
inList: inputListErrorMock{},

},
wantErr: true,
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/set_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewSetContextCmd(
Use: "context",
Short: "Set context",
Example: "rit set context",
RunE: RunFuncE(s.runStdin(), s.runPrompt()),
RunE: RunFuncE(s.runStdin(), s.runPrompt()),
}

cmd.LocalFlags()
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/set_formula_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func Test_setFormulaRunnerCmd(t *testing.T) {
},
config: ConfigRunnerMock{},
},
wantErr: false,
wantErr: false,
inputStdin: "{\"runType\": \"local\"}\n",
},
{
Expand All @@ -61,7 +61,7 @@ func Test_setFormulaRunnerCmd(t *testing.T) {
createErr: errors.New("error to create config"),
},
},
wantErr: true,
wantErr: true,
inputStdin: "{\"runType\": \"local\"}\n",
},
{
Expand All @@ -86,7 +86,7 @@ func Test_setFormulaRunnerCmd(t *testing.T) {
},
config: ConfigRunnerMock{},
},
wantErr: true,
wantErr: true,
inputStdin: "{\"runType\": \"invalid\"}\n",
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (u UpgradeCmd) runFunc() CommandRunnerFunc {

upgradeUrl := u.Url(runtime.GOOS)
if err := u.Run(upgradeUrl); err != nil {
return prompt.NewError(err.Error()+"\n")
return prompt.NewError(err.Error() + "\n")
}

prompt.Success("Rit upgraded with success")
Expand Down
4 changes: 2 additions & 2 deletions pkg/credential/credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ type Field struct {
type ListCredDatas []ListCredData

type ListCredData struct {
Provider string
Provider string
Credential string
Context string
Context string
}

// Fields are used to represents providers.json
Expand Down
12 changes: 6 additions & 6 deletions pkg/env/envcredential/env_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ func TestCredentialResolver(t *testing.T) {
output string
}{
{
name: "Test resolve new provider",
name: "Test resolve new provider",
credentialField: "CREDENTIAL_PROVIDER_KEY",
output: "key",
output: "key",
},
{
name: "Test resolve new key",
name: "Test resolve new key",
credentialField: "CREDENTIAL_PROVIDER_KEY2",
output: "key2",
output: "key2",
},
{
name: "Test resolve existing key",
name: "Test resolve existing key",
credentialField: "CREDENTIAL_PROVIDER_KEY2",
output: "key2",
output: "key2",
},
}

Expand Down
1 change: 0 additions & 1 deletion pkg/file/fileutil/file_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func ReadFile(path string) ([]byte, error) {
return f, err
}


// WriteFilePerm wrapper for ioutil.WriteFile
// Deprecated: use the stream package to work with files and directories
func WriteFilePerm(path string, content []byte, perm int32) error {
Expand Down
4 changes: 2 additions & 2 deletions pkg/formula/builder/bat.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import (
)

const (
buildFile = "build.bat"
buildFile = "build.bat"
msgBatBuildErr = "failed building formula with build.bat, verify your repository"
errMsgFmt = `%s
errMsgFmt = `%s
More about error: %s`
)

Expand Down
20 changes: 10 additions & 10 deletions pkg/formula/formula.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ const (

type (
Input struct {
Name string `json:"name"`
Type string `json:"type"`
Default string `json:"default"`
Label string `json:"label"`
Items []string `json:"items"`
Cache Cache `json:"cache"`
Condition Condition `json:"condition"`
Name string `json:"name"`
Type string `json:"type"`
Default string `json:"default"`
Label string `json:"label"`
Items []string `json:"items"`
Cache Cache `json:"cache"`
Condition Condition `json:"condition"`
}

Cache struct {
Expand All @@ -57,9 +57,9 @@ type (
NewLabel string `json:"newLabel"`
}
Condition struct {
Variable string `json:"variable"`
Operator string `json:"operator"`
Value string `json:"value"`
Variable string `json:"variable"`
Operator string `json:"operator"`
Value string `json:"value"`
}
Create struct {
FormulaCmd string `json:"formulaCmd"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/formula/formula_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestBinFilePath(t *testing.T) {
os := runtime.GOOS
run := "run.sh"
if os == osutil.Windows {
run = "run.bat"
run = "run.bat"
}
want := filepath.Join(home, "repos", "commons", "scaffold", "coffee-java", "bin", run)

Expand Down Expand Up @@ -110,7 +110,7 @@ func TestPkgName(t *testing.T) {
}

func TestConfigPath(t *testing.T) {
want := filepath.Join(home, "repos", "commons", "scaffold", "coffee-java", "config.json")
want := filepath.Join(home, "repos", "commons", "scaffold", "coffee-java", "config.json")

got := def.ConfigPath(def.FormulaPath(home))

Expand Down
18 changes: 12 additions & 6 deletions pkg/formula/runner/inputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,18 @@ func (in InputManager) verifyConditional(cmd *exec.Cmd, input formula.Input) (bo
// the code to the risks of running an eval function on a user-defined variable
// optimizations are welcome, being mindful of the points above
switch input.Condition.Operator {
case "==": return value == input.Condition.Value, nil
case "!=": return value != input.Condition.Value, nil
case ">": return value > input.Condition.Value, nil
case ">=": return value >= input.Condition.Value, nil
case "<": return value < input.Condition.Value, nil
case "<=": return value <= input.Condition.Value, nil
case "==":
return value == input.Condition.Value, nil
case "!=":
return value != input.Condition.Value, nil
case ">":
return value > input.Condition.Value, nil
case ">=":
return value >= input.Condition.Value, nil
case "<":
return value < input.Condition.Value, nil
case "<=":
return value <= input.Condition.Value, nil
default:
return false, fmt.Errorf(
"config.json: conditional operator %s not valid. Use any of (==, !=, >, >=, <, <=)",
Expand Down
36 changes: 18 additions & 18 deletions pkg/formula/runner/inputs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ func TestInputManager_ConditionalInputs(t *testing.T) {
fileManager := stream.NewFileManager()

type in struct {
variable string
operator string
variable string
operator string
}

tests := []struct {
Expand All @@ -335,64 +335,64 @@ func TestInputManager_ConditionalInputs(t *testing.T) {
{
name: "equal conditional",
in: in{
variable: "sample_list",
operator: "==",
variable: "sample_list",
operator: "==",
},
want: nil,
},
{
name: "not equal conditional",
in: in{
variable: "sample_list",
operator: "!=",
variable: "sample_list",
operator: "!=",
},
want: nil,
},
{
name: "greater than conditional",
in: in{
variable: "sample_list",
operator: ">",
variable: "sample_list",
operator: ">",
},
want: nil,
},
{
name: "greater than or equal to conditional",
in: in{
variable: "sample_list",
operator: ">=",
variable: "sample_list",
operator: ">=",
},
want: nil,
},
{
name: "less than conditional",
in: in{
variable: "sample_list",
operator: "<",
variable: "sample_list",
operator: "<",
},
want: nil,
},
{
name: "less than or equal to conditional",
in: in{
variable: "sample_list",
operator: "<=",
variable: "sample_list",
operator: "<=",
},
want: nil,
},
{
name: "wrong operator conditional",
in: in{
variable: "sample_list",
operator: "eq",
variable: "sample_list",
operator: "eq",
},
want: errors.New("config.json: conditional operator eq not valid. Use any of (==, !=, >, >=, <, <=)"),
},
{
name: "non-existing variable conditional",
in: in{
variable: "non_existing",
operator: "==",
variable: "non_existing",
operator: "==",
},
want: errors.New("config.json: conditional variable non_existing not found"),
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ type Repositories interface {
Zipball(info RepoInfo, version string) (io.ReadCloser, error)
Tags(info RepoInfo) (Tags, error)
LatestTag(info RepoInfo) (Tag, error)
}
}
2 changes: 1 addition & 1 deletion pkg/metric/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ func (c CheckManager) Check() bool {
}

return true
}
}
1 change: 0 additions & 1 deletion pkg/metric/checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,3 @@ func Test_Check(t *testing.T) {
})
}
}

2 changes: 1 addition & 1 deletion pkg/metric/user_id_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (us UserIdManager) Generate() (UserId, error) {
if _, err := us.hash.Write([]byte(id)); err != nil {
return "", err
}

userId := hex.EncodeToString(us.hash.Sum(nil))

return UserId(userId), nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/prompt/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ func Warning(text string) {

func Cyan(text string) string {
return color.Cyan.Render(text)
}
}
2 changes: 1 addition & 1 deletion pkg/prompt/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (SurveyInt) Int(name string, helper ...string) (int64, error) {

validationQs := []*survey.Question{
{
Name: "name",
Name: "name",
Validate: validateSurveyIntIn,
},
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/prompt/multiline.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,15 @@ func (SurveyMultiline) MultiLineText(name string, required bool) (string, error)

var validationQs []*survey.Question


if required{
if required {
validationQs = []*survey.Question{
{
Name: "name",
Prompt: &survey.Multiline{Message: name},
Validate: survey.Required,
},
}
}else {
} else {
validationQs = []*survey.Question{
{
Name: "name",
Expand All @@ -51,4 +50,3 @@ func (SurveyMultiline) MultiLineText(name string, required bool) (string, error)
}
return value, survey.Ask(validationQs, &value)
}

1 change: 0 additions & 1 deletion pkg/prompt/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ func (SurveyText) Text(name string, required bool, helper ...string) (string, er

return value, survey.Ask(validationQs, &value)
}

3 changes: 2 additions & 1 deletion pkg/rcontext/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ package rcontext

import (
"fmt"
"github.com/ZupIT/ritchie-cli/pkg/file/fileutil"
"os"
"testing"

"github.com/ZupIT/ritchie-cli/pkg/file/fileutil"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/rcontext/finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ func TestFind(t *testing.T) {
}
})
}
}
}
Loading