Skip to content

Commit

Permalink
update linter && fix violations
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-hajek committed Jan 21, 2024
1 parent 624c541 commit 6ed51d8
Show file tree
Hide file tree
Showing 40 changed files with 102 additions and 74 deletions.
2 changes: 1 addition & 1 deletion src/cmd/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func bucketCmd() *cmdBuilder.Cmd {
AddChildrenCmd(bucketS3Cmd())
}

// FIXME - janhajek better place?
// TODO - janhajek better place?
const (
xAmzAclName = "x-amz-acl"
)
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/bucketS3.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func bucketS3Cmd() *cmdBuilder.Cmd {
AddChildrenCmd(bucketS3DeleteCmd())
}

// FIXME - janhajek better place?
// TODO - janhajek better place?
const (
s3ServerRegion = "us-east-1"
accessKeyIdName = "accessKeyId"
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/bucketS3Delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func bucketS3DeleteCmd() *cmdBuilder.Cmd {
}

if !confirm {
// FIXME - janhajek message
// TODO - janhajek message
fmt.Println("you have to confirm it")
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/bucketZeropsDelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func bucketZeropsDeleteCmd() *cmdBuilder.Cmd {
}

serviceId := cmdData.Service.ID
// FIXME - janhajek duplicate
// TODO - janhajek duplicate
bucketName := fmt.Sprintf("%s.%s", strings.ToLower(serviceId.Native()), cmdData.Args["bucketName"][0])

confirm, err := YesNoPromptDestructive(ctx, cmdData, i18n.T(i18n.BucketDeleteConfirm, bucketName))
Expand All @@ -36,7 +36,7 @@ func bucketZeropsDeleteCmd() *cmdBuilder.Cmd {
}

if !confirm {
// FIXME - janhajek message
// TODO - janhajek message
fmt.Println("you have to confirm it")
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func getLoginRegion(
}
}

// FIXME - janhajek translation
// TODO - janhajek translation
header := (&uxBlock.TableRow{}).AddStringCells("Name")

tableBody := &uxBlock.TableBody{}
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/projectDelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func projectDeleteCmd() *cmdBuilder.Cmd {
}

if !confirm {
// FIXME - janhajek message
// TODO - janhajek message
fmt.Println("you have to confirm it")
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions src/cmd/projectImport.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func projectImportCmd() *cmdBuilder.Cmd {
LoggedUserRunFunc(func(ctx context.Context, cmdData *cmdBuilder.LoggedUserCmdData) error {
uxBlocks := cmdData.UxBlocks

// FIXME - janhajek client via flag
// FIXME - janhajek interactive selector of clients
// TODO - janhajek client via flag
// TODO - janhajek interactive selector of clients

// FIXME - janhajek config
// TODO - janhajek config
yamlContent, err := yamlReader.ReadContent(uxBlocks, cmdData.Args[projectImportArgName][0], "./")
if err != nil {
return err
Expand All @@ -35,7 +35,7 @@ func projectImportCmd() *cmdBuilder.Cmd {
importProjectResponse, err := cmdData.RestApiClient.PostProjectImport(
ctx,
body.ProjectImport{
// FIXME - janhajek client id
// TODO - janhajek client id
ClientId: uuid.ClientId(cmdData.Args[projectImportArgName][0]),
Yaml: types.Text(yamlContent),
},
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/scopeProject.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func scopeProjectCmd() *cmdBuilder.Cmd {
}
cmdData.UxBlocks.PrintWarningLine(i18n.T(i18n.ScopedProjectNotFound))
} else {
// FIXME - janhajek message
// TODO - janhajek message
cmdData.UxBlocks.PrintInfoLine("previously scoped project: " + project.Name.String())
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/scopeReset.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func scopeResetCmd() *cmdBuilder.Cmd {
return err
}

// FIXME - janhajek message
// TODO - janhajek message
cmdData.UxBlocks.PrintInfoLine("scope reset")

return nil
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/serviceDelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func serviceDeleteCmd() *cmdBuilder.Cmd {
}

if !confirm {
// FIXME - janhajek message
// TODO - janhajek message
fmt.Println("you have to confirm it")
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/serviceDeploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ func serviceDeployCmd() *cmdBuilder.Cmd {
return err
}

// FIXME - janhajek merge with sdk client?
// TODO - janhajek merge with sdk client?
httpClient := httpClient.New(ctx, httpClient.Config{
HttpTimeout: time.Minute * 15,
})

// FIXME - janhajek spinner?
// TODO - janhajek spinner?
uxBlocks.PrintInfoLine(i18n.T(i18n.BuildDeployUploadingPackageStart))
if err := packageUpload(httpClient, appVersion.UploadUrl.String(), r); err != nil {
// if an error occurred while packing the app, return that error
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/serviceLog.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func serviceLogCmd() *cmdBuilder.Cmd {
Format: cmdData.Params.GetString("format"),
FormatTemplate: cmdData.Params.GetString("formatTemplate"),
Follow: cmdData.Params.GetBool("follow"),
// FIXME - janhajek better place?
// TODO - janhajek better place?
Levels: serviceLogs.Levels{
{"EMERGENCY", "0"},
{"ALERT", "1"},
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/servicePush.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/zeropsio/zerops-go/types"
)

// FIXME - janhajek shared
// TODO - janhajek shared
const ZeropsYamlFileName = "zerops.yaml"

func servicePushCmd() *cmdBuilder.Cmd {
Expand Down Expand Up @@ -78,12 +78,12 @@ func servicePushCmd() *cmdBuilder.Cmd {
return err
}

// FIXME - janhajek merge with sdk client
// TODO - janhajek merge with sdk client
HttpClient := httpClient.New(ctx, httpClient.Config{
HttpTimeout: time.Minute * 15,
})

// FIXME - janhajek spinner?
// TODO - janhajek spinner?
uxBlocks.PrintInfoLine(i18n.T(i18n.BuildDeployUploadingPackageStart))
if err := packageUpload(HttpClient, appVersion.UploadUrl.String(), r); err != nil {
// if an error occurred while packing the app, return that error
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/statusShowDebugLogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func statusShowDebugLogsCmd() *cmdBuilder.Cmd {
filesize := stat.Size()

if filesize == 0 {
// FIXME - janhajek translate
// TODO - janhajek translate
fmt.Println("No logs found")
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/uxHelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func YesNoPromptDestructive(ctx context.Context, cmdData *cmdBuilder.LoggedUserC
return true, nil
}

// FIXME - janhajek translate
// TODO - janhajek translate
choices := []string{"no", "yes"}
choice, err := cmdData.UxBlocks.Prompt(ctx, message, choices)
if err != nil {
Expand All @@ -26,7 +26,7 @@ func YesNoPromptNonDestructive(ctx context.Context, cmdData *cmdBuilder.LoggedUs
return true, nil
}

// FIXME - janhajek translate
// TODO - janhajek translate
choices := []string{"no", "yes"}
choice, err := cmdData.UxBlocks.Prompt(ctx, message, choices)
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions src/cmdBuilder/cmdBuilderCreateRunFunc.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,16 @@ func (b *CmdBuilder) createCmdRunFunc(cmd *Cmd, params *params.Handler) func(*co
cmdData.RestApiClient = zeropsRestApiClient.NewAuthorizedClient(token, storedData.RegionData.RestApiAddress)

for _, dep := range getDependencyListFromRoot(cmd.scopeLevel) {
err := dep.LoadSelectedScope(cobraCmd.Context(), cmd, cmdData)
err := dep.LoadSelectedScope(ctx, cmd, cmdData)
if err != nil {
return err
}
}
return cmd.loggedUserRunFunc(cobraCmd.Context(), cmdData)
return cmd.loggedUserRunFunc(ctx, cmdData)

}

return cmd.guestRunFunc(cobraCmd.Context(), guestCmdData)
return cmd.guestRunFunc(ctx, guestCmdData)
}
}

Expand All @@ -175,13 +175,13 @@ func convertArgs(cmd *Cmd, args []string) (map[string][]string, error) {
}

if len(args) < requiredArgsCount {
// FIXME - janhajek message
// TODO - janhajek message
return nil, errors.Errorf("expected at least %d arg(s), got %d", requiredArgsCount, len(args))
}

// the last arg is not an array, max number of given args can't be greater than the number of registered args
if !isArray && len(args) > len(cmd.args) {
// FIXME - janhajek message
// TODO - janhajek message
return nil, errors.Errorf("expected no more than %d arg(s), got %d", len(cmd.args), len(args))
}

Expand Down Expand Up @@ -233,7 +233,7 @@ func getQuietMode(isTerminal bool) (QuietMode, error) {
case QuietModeConfirmNothing, QuietModeConfirmAll, QuietModeConfirmOnlyDestructive:
return QuietMode(QuietModeFlag), nil
default:
// FIXME - janhajek message
// TODO - janhajek message
return 0, errors.New("unknown quiet mode")
}
}
Expand All @@ -247,7 +247,7 @@ func isTerminal() (bool, error) {
case TerminalModeEnabled:
return true, nil
default:
// FIXME - janhajek message
// TODO - janhajek message
return false, errors.New("unknown terminal mode")
}
}
Expand Down
1 change: 1 addition & 0 deletions src/cmdBuilder/cmdBuilderCreateRunFunc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func TestConvertArgs(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
got, err := convertArgs(tt.args.cmd, tt.args.args)
if tt.wantErr != "" {
Expand Down
6 changes: 3 additions & 3 deletions src/cmdBuilder/cmdBuilderExecuteRootCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type TerminalMode string

const (
TerminalModeAuto TerminalMode = "auto"
TerminalModeDisabled = "disabled"
TerminalModeEnabled = "enabled"
TerminalModeDisabled TerminalMode = "disabled"
TerminalModeEnabled TerminalMode = "enabled"
)

var TerminalFlag string
Expand Down Expand Up @@ -71,7 +71,7 @@ func createRootCommand() *cobra.Command {
SilenceErrors: true,
}

// FIXME - janhajek add a dynamic help for subcommands
// TODO - janhajek add a dynamic help for subcommands
rootCmd.Flags().BoolP("help", "h", false, i18n.T(i18n.DisplayHelp)+i18n.T(i18n.GroupHelp))

rootCmd.PersistentFlags().IntVar(&QuietModeFlag, "quiet", int(QuietModeConfirmAll), i18n.T(i18n.QuietModeFlag))
Expand Down
4 changes: 2 additions & 2 deletions src/cmdBuilder/dependencyTree.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"slices"
)

// FIXME - janhajek do we need interface?
// TODO - janhajek do we need interface?
type Dependency interface {
AddCommandFlags(*Cmd)
LoadSelectedScope(ctx context.Context, cmd *Cmd, cmdData *LoggedUserCmdData) error
Expand All @@ -20,7 +20,7 @@ func (c *commonDependency) GetParent() Dependency {
return c.parent
}

// FIXME - janhajek move back cmd?
// TODO - janhajek move back cmd?
var Project *project
var Service *service

Expand Down
2 changes: 1 addition & 1 deletion src/cmdBuilder/dependencyTreeProject.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type project struct {
const ProjectArgName = "projectId"

func (p *project) AddCommandFlags(cmd *Cmd) {
// FIXME - janhajek translation
// TODO - janhajek translation
cmd.StringFlag(ProjectArgName, "", "Project id")
}

Expand Down
2 changes: 1 addition & 1 deletion src/cmdBuilder/dependencyTreeService.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ServiceArgName = "serviceIdOrName"
const ServiceFlagName = "serviceId"

func (s *service) AddCommandFlags(cmd *Cmd) {
// FIXME - janhajek translation
// TODO - janhajek translation
cmd.StringFlag(ServiceFlagName, "", "Service id")
}

Expand Down
7 changes: 7 additions & 0 deletions src/constants/darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ func getDataFilePaths() []pathReceiver {

func getLogFilePath() []pathReceiver {
return []pathReceiver{
func() (string, error) {
env := os.Getenv(cliLogFilePathEnvVar)
if env != "" {
return env, nil
}
return "", errors.New("env is empty")
},
func() (string, error) {
return path.Join("/usr/local/var/log/", zeropsLogFile), nil
},
Expand Down
16 changes: 16 additions & 0 deletions src/constants/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,33 @@ package constants
import (
"os"
"path"

"github.com/pkg/errors"
)

func getDataFilePaths() []pathReceiver {
return []pathReceiver{
func() (string, error) {
env := os.Getenv(cliDataFilePathEnvVar)
if env != "" {
return env, nil
}
return "", errors.New("env is empty")
},
receiverWithPath(os.UserConfigDir, zeropsDir, cliDataFileName),
receiverWithPath(os.UserHomeDir, zeropsDir, cliDataFileName),
}
}

func getLogFilePath() []pathReceiver {
return []pathReceiver{
func() (string, error) {
env := os.Getenv(cliLogFilePathEnvVar)
if env != "" {
return env, nil
}
return "", errors.New("env is empty")
},
func() (string, error) {
return path.Join("/var/log/", zeropsDir, zeropsLogFile), nil
},
Expand Down
19 changes: 17 additions & 2 deletions src/constants/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,22 @@ package constants

import (
"os"
"path"

"github.com/pkg/errors"
)

// this line is here to make linter happy
var _ = zeropsDir

func getDataFilePaths() []pathReceiver {
return []pathReceiver{
func() (string, error) {
env := os.Getenv(cliDataFilePathEnvVar)
if env != "" {
return env, nil
}
return "", errors.New("env is empty")
},
receiverWithPath(os.UserConfigDir, "Zerops", cliDataFileName),
receiverWithPath(os.UserHomeDir, "Zerops", cliDataFileName),
}
Expand All @@ -18,7 +29,11 @@ func getDataFilePaths() []pathReceiver {
func getLogFilePath() []pathReceiver {
return []pathReceiver{
func() (string, error) {
return path.Join("/usr/local/var/log/", zeropsLogFile), nil
env := os.Getenv(cliLogFilePathEnvVar)
if env != "" {
return env, nil
}
return "", errors.New("env is empty")
},
receiverWithPath(os.UserConfigDir, "Zerops", zeropsLogFile),
receiverWithPath(os.UserHomeDir, "Zerops", zeropsLogFile),
Expand Down
2 changes: 1 addition & 1 deletion src/constants/zerops.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func findFirstWritablePath(paths []pathReceiver) (string, error) {
}
}

// FIXME - janhajek translate
// TODO - janhajek translate
return "", errors.Errorf("Unable to find writable path from %v", checkedPaths)
}

Expand Down
Loading

0 comments on commit 6ed51d8

Please sign in to comment.