Skip to content

Commit

Permalink
fmt: gofumpt
Browse files Browse the repository at this point in the history
  • Loading branch information
ipmb committed Mar 25, 2023
1 parent a711e55 commit 0b4e844
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 47 deletions.
7 changes: 4 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import (
"github.com/sirupsen/logrus"
)

var maxLifetime = 12 * 60 * 60
var waitForConnect = 60
var (
maxLifetime = 12 * 60 * 60
waitForConnect = 60
)

var ShellBackgroundCommand = []string{
strings.Join([]string{
Expand Down Expand Up @@ -855,7 +857,6 @@ func (a *App) DBDumpLoadFamily() (*string, error) {
}

func (a *App) DBDump() (*ecs.Task, *s3.GetObjectInput, error) {

getObjectInput, err := a.DBDumpLocation("dumps/")
if err != nil {
return nil, nil, err
Expand Down
1 change: 0 additions & 1 deletion app/scheduled_tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,4 @@ func TestScheduledTasksDeleteEmpty(t *testing.T) {
if err == nil {
t.Error("expected error trying to delete from empty list")
}

}
1 change: 0 additions & 1 deletion cmd/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ var accessAddCmd = &cobra.Command{
Example: "apppack -a my-app access add user1@example.com user2@example.com",
Run: func(cmd *cobra.Command, args []string) {
for _, email := range args {

if !validateEmail(email) {
checkErr(fmt.Errorf("%s does not appear to be a valid email address", email))
}
Expand Down
1 change: 0 additions & 1 deletion cmd/admins.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ var adminsAddCmd = &cobra.Command{
Example: "apppack admins add user1@example.com user2@example.com",
Run: func(cmd *cobra.Command, args []string) {
for _, email := range args {

if !validateEmail(email) {
checkErr(fmt.Errorf("%s does not appear to be a valid email address", email))
}
Expand Down
1 change: 0 additions & 1 deletion cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ var appsCmd = &cobra.Command{
}
}
}

},
}

Expand Down
1 change: 0 additions & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ var configImportCmd = &cobra.Command{
}
ui.Spinner.Stop()
printSuccess(msg)

},
}

Expand Down
11 changes: 6 additions & 5 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ import (
"golang.org/x/text/language"
)

var createChangeSet bool
var nonInteractive bool
var region string
var release string
var (
createChangeSet bool
nonInteractive bool
region string
release string
)

func CreateStackCommand(sess *session.Session, stack stacks.Stack, flags *pflag.FlagSet, name string) {
stackName := stack.StackName(&name)
Expand Down Expand Up @@ -303,7 +305,6 @@ var createRegionCmd = &cobra.Command{
}

func init() {

rootCmd.AddCommand(createCmd)
createCmd.PersistentFlags().StringVarP(&AccountIDorAlias, "account", "c", "", "AWS account ID or alias (not needed if you are only the administrator of one account)")
createCmd.PersistentFlags().BoolVar(&UseAWSCredentials, "aws-credentials", false, "use AWS credentials instead of AppPack.io federation")
Expand Down
10 changes: 5 additions & 5 deletions cmd/dash.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ type LegendItem struct {
Color cell.Color
}

const redrawInterval = 250 * time.Millisecond
const buttonWidth = 20
const contentContainerID = "content"
const (
redrawInterval = 250 * time.Millisecond
buttonWidth = 20
contentContainerID = "content"
)

func BuildLineChart(ctx context.Context, appMetrics metrics.AppMetrics) (*linechart.LineChart, *text.Text, error) {
lc, err := linechart.New(
Expand Down Expand Up @@ -83,7 +85,6 @@ func BuildLineChart(ctx context.Context, appMetrics metrics.AppMetrics) (*linech
}
}
return nil

})
return lc, legendText, nil
}
Expand Down Expand Up @@ -405,7 +406,6 @@ var dashCmd = &cobra.Command{
termdash.KeyboardSubscriber(quitter),
termdash.RedrawInterval(redrawInterval),
))

},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var dbDumpCmd = &cobra.Command{
if dbOutputFile != "" {
dir, _ := filepath.Split(dbOutputFile)
if dir != "" {
checkErr(os.MkdirAll(dir, 0750))
checkErr(os.MkdirAll(dir, 0o750))
}
}
task, getObjectInput, err := app.DBDump()
Expand Down
2 changes: 1 addition & 1 deletion cmd/docgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var docgenCmd = &cobra.Command{
Short: "generate command documentation as markdown",
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {
checkErr(os.MkdirAll(directory, os.FileMode(0750)))
checkErr(os.MkdirAll(directory, os.FileMode(0o750)))
identity := func(s string) string { return s }
checkErr(doc.GenMarkdownTreeCustom(rootCmd, directory, filePrepender, identity))
},
Expand Down
10 changes: 6 additions & 4 deletions cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ import (
"github.com/spf13/cobra"
)

var sawConfig sawconfig.Configuration
var sawOutputConfig sawconfig.OutputConfiguration
var logsStart string
var logsEnd string
var (
sawConfig sawconfig.Configuration
sawOutputConfig sawconfig.OutputConfiguration
logsStart string
logsEnd string
)

// newBlade is a hack to get a Blade instance with our AWS session
func newBlade(session *session.Session) *blade.Blade {
Expand Down
6 changes: 4 additions & 2 deletions cmd/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,10 @@ Requires installation of Amazon's SSM Session Manager. https://docs.aws.amazon.c
},
}

var scaleCPU float64
var scaleMemory string
var (
scaleCPU float64
scaleMemory string
)

func init() {
rootCmd.AddCommand(psCmd)
Expand Down
10 changes: 6 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ const (
var AppName string

// AccountIDorAlias is the `--account` flag
var AccountIDorAlias string
var UseAWSCredentials = false
var SessionDurationSeconds = 900
var MaxSessionDurationSeconds = 3600
var (
AccountIDorAlias string
UseAWSCredentials = false
SessionDurationSeconds = 900
MaxSessionDurationSeconds = 3600
)

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Expand Down
10 changes: 6 additions & 4 deletions cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ func StartInteractiveShell(a *app.App, taskFamily, shellCmd *string, taskCommand
checkErr(err)
}

var shellCpu float64
var shellMem string
var shellRoot bool
var shellLive bool
var (
shellCpu float64
shellMem string
shellRoot bool
shellLive bool
)

func humanToECSSizeConfiguration(cpu float64, memory string) (*app.ECSSizeConfiguration, error) {
var memoryInMB int
Expand Down
2 changes: 0 additions & 2 deletions cmd/stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func stackName(stack *cloudformation.Stack) (*stackHumanize, error) {
humanStack.Cluster = strings.Join(stackParts[2:], "-")
}
return &humanStack, nil

}

// stacksCmd represents the stacks command
Expand Down Expand Up @@ -116,5 +115,4 @@ func init() {
rootCmd.AddCommand(stacksCmd)
stacksCmd.PersistentFlags().StringVarP(&AccountIDorAlias, "account", "c", "", "AWS account ID or alias (not needed if you are only the administrator of one account)")
stacksCmd.PersistentFlags().BoolVar(&UseAWSCredentials, "aws-credentials", false, "use AWS credentials instead of AppPack.io federation")

}
1 change: 1 addition & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (m *ServiceUtilizationMetrics) GetService() string { return m.Service }
func (m *ServiceUtilizationMetrics) Title() string {
return fmt.Sprintf("%s utilization (%%)", m.Service)
}

func (m *ServiceUtilizationMetrics) ShortName() string {
return fmt.Sprintf("%s util", m.Service)
}
Expand Down
6 changes: 4 additions & 2 deletions stacks/app_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ func (a *AppStack) AskQuestions(sess *session.Session) error {
Question: &survey.Question{
Prompt: &survey.Multiline{
Message: "Custom Domain(s)",
Default: strings.Join(a.Parameters.Domains, "\n")},
Default: strings.Join(a.Parameters.Domains, "\n"),
},
},
},
}...)
Expand Down Expand Up @@ -553,7 +554,8 @@ func (a *AppStack) AskQuestions(sess *session.Session) error {
Message: "SQS Queue",
Options: []string{"yes", "no"},
FilterMessage: "",
Default: ui.BooleanAsYesNo(a.Parameters.SQSQueueEnabled)},
Default: ui.BooleanAsYesNo(a.Parameters.SQSQueueEnabled),
},
},
},
}...)
Expand Down
2 changes: 1 addition & 1 deletion stacks/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

func GeneratePassword() (string, error) {
// generate a random alpha numeric string using crypto/rand
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
letters := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
b := make([]rune, 30)
for i := range b {
n, err := rand.Int(rand.Reader, big.NewInt(int64(len(letters))))
Expand Down
4 changes: 2 additions & 2 deletions state/user_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func WriteToCache(name string, data []byte) error {
if err != nil {
return err
}
err = os.Mkdir(path, os.FileMode(0700))
err = os.Mkdir(path, os.FileMode(0o700))
if err != nil {
if !os.IsExist(err) {
return err
Expand All @@ -28,7 +28,7 @@ func WriteToCache(name string, data []byte) error {
return err
}
defer file.Close()
err = file.Chmod(os.FileMode(0600))
err = file.Chmod(os.FileMode(0o600))
if err != nil {
return err
}
Expand Down
14 changes: 8 additions & 6 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ import (
"github.com/hashicorp/go-version"
)

var BuildDate = time.Now().String()
var Version = "<version>"
var Commit = "<commit>"
var Environment = "development"
var (
BuildDate = time.Now().String()
Version = "<version>"
Commit = "<commit>"
Environment = "development"
)

// This code is largely cherry-picked from https://github.com/cli/cli/blob/82927b0cc2a831adda22b0a7bf43938bd15e1126/internal/update/update.go
// It is licensed under the MIT license https://github.com/cli/cli/blob/82927b0cc2a831adda22b0a7bf43938bd15e1126/LICENSE
Expand Down Expand Up @@ -107,12 +109,12 @@ func setStateEntry(stateFilePath string, t time.Time, r ReleaseInfo) error {
return err
}

err = os.MkdirAll(filepath.Dir(stateFilePath), 0755)
err = os.MkdirAll(filepath.Dir(stateFilePath), 0o755)
if err != nil {
return err
}

err = os.WriteFile(stateFilePath, content, 0600)
err = os.WriteFile(stateFilePath, content, 0o600)
return err
}

Expand Down

0 comments on commit 0b4e844

Please sign in to comment.