Skip to content

Commit d3d5eca

Browse files
committed
fix lint
1 parent 8d5186a commit d3d5eca

File tree

5 files changed

+34
-80
lines changed

5 files changed

+34
-80
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.24.0
44

55
require (
66
github.com/AlecAivazis/survey/v2 v2.3.6
7+
github.com/AlekSi/pointer v1.2.0
78
github.com/aws/aws-sdk-go-v2 v1.27.1
89
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.16.23
910
github.com/charmbracelet/bubbles v0.17.1
@@ -44,7 +45,6 @@ require (
4445

4546
require (
4647
filippo.io/edwards25519 v1.1.0 // indirect
47-
github.com/AlekSi/pointer v1.2.0 // indirect
4848
github.com/alecthomas/chroma v0.10.0 // indirect
4949
github.com/alecthomas/chroma/v2 v2.14.0 // indirect
5050
github.com/alessio/shellescape v1.4.1 // indirect

internal/cli/serverless/migration/create.go

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"strings"
2424
"time"
2525

26+
"github.com/AlekSi/pointer"
2627
aws "github.com/aws/aws-sdk-go-v2/aws"
2728
"github.com/fatih/color"
2829
"github.com/juju/errors"
@@ -56,7 +57,7 @@ func CreateCmd(h *internal.Helper) *cobra.Command {
5657
}
5758
ctx := cmd.Context()
5859

59-
dryRun, err := cmd.Flags().GetBool(flag.MigrationDryRun)
60+
dryRun, err := cmd.Flags().GetBool(flag.DryRun)
6061
if err != nil {
6162
return errors.Trace(err)
6263
}
@@ -121,7 +122,7 @@ func CreateCmd(h *internal.Helper) *cobra.Command {
121122
cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The ID of the target cluster.")
122123
cmd.Flags().StringP(flag.DisplayName, flag.DisplayNameShort, "", "Display name for the migration.")
123124
cmd.Flags().String(flag.MigrationConfigFile, "", "Path to a migration config JSON file. Use \"ticloud serverless migration template --mode <mode>\" to print templates.")
124-
cmd.Flags().Bool(flag.MigrationDryRun, false, "Run a migration precheck (dry run) with the provided inputs without creating a migration.")
125+
cmd.Flags().Bool(flag.DryRun, false, "Run a migration precheck (dry run) with the provided inputs without creating a migration.")
125126

126127
return cmd
127128
}
@@ -216,16 +217,12 @@ func printPrecheckSummary(result *pkgmigration.MigrationPrecheck, h *internal.He
216217
if !shouldPrintPrecheckItem(item.Status) {
217218
continue
218219
}
219-
var status string
220-
if item.Status != nil {
221-
status = string(*item.Status)
222-
}
223220
rows = append(rows, output.Row{
224-
precheckItemType(item.Type),
225-
status,
226-
aws.ToString(item.Description),
227-
aws.ToString(item.Reason),
228-
aws.ToString(item.Solution),
221+
string(pointer.Get(item.Type)),
222+
string(pointer.Get(item.Status)),
223+
pointer.Get(item.Description),
224+
pointer.Get(item.Reason),
225+
pointer.Get(item.Solution),
229226
})
230227
}
231228
if len(rows) == 0 {
@@ -234,13 +231,6 @@ func printPrecheckSummary(result *pkgmigration.MigrationPrecheck, h *internal.He
234231
return true, output.PrintHumanTable(h.IOStreams.Out, columns, rows)
235232
}
236233

237-
func precheckItemType(value *pkgmigration.PrecheckItemType) string {
238-
if value == nil {
239-
return ""
240-
}
241-
return string(*value)
242-
}
243-
244234
// shouldPrintPrecheckItem reports whether a precheck item should be shown to users.
245235
// Currently only WARNING and FAILED statuses surface because SUCCESS does not
246236
// provide actionable information.

internal/cli/serverless/migration/delete.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,16 @@ func DeleteCmd(h *internal.Helper) *cobra.Command {
119119
return errors.New("The terminal doesn't support prompt, please run with --force to delete the migration")
120120
}
121121
prompt := &survey.Input{
122-
Message: fmt.Sprintf("%s %s %s", color.BlueString("Please type"), color.HiBlueString("yes"), color.BlueString("to confirm:")),
122+
Message: fmt.Sprintf("%s %s %s", color.BlueString("Please type"), color.HiBlueString(config.Confirmed), color.BlueString("to confirm:")),
123123
}
124124
var confirmation string
125125
if err := survey.AskOne(prompt, &confirmation); err != nil {
126-
if err == terminal.InterruptErr {
126+
if errors.Is(err, terminal.InterruptErr) {
127127
return util.InterruptError
128128
}
129129
return err
130130
}
131-
if confirmation != "yes" {
131+
if confirmation != config.Confirmed {
132132
return errors.New("Incorrect confirm string entered, skipping migration deletion")
133133
}
134134
}

internal/flag/flag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ const (
129129
MigrationIDShort string = "m"
130130
MigrationConfigFile string = "config-file"
131131
MigrationMode string = "mode"
132-
MigrationDryRun string = "dry-run"
132+
DryRun string = "dry-run"
133133
)
134134

135135
const OutputHelp = "Output format, one of [\"human\" \"json\"]. For the complete result, please use json format."

internal/mock/api_client.go

Lines changed: 21 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)