Skip to content

Commit

Permalink
all: replace 'interface{}' with 'any' (#1453)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear authored Nov 29, 2023
1 parent f73aff9 commit 516b893
Show file tree
Hide file tree
Showing 95 changed files with 600 additions and 600 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DOCS_OUT = $(shell echo $${DOCS_OUT:-$(my_d)/builds/docs/yaml})
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)

GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
GOFILES_NOVENDOR_NOMOCK = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "*_mock.go")

GOOS = linux
ifeq ($(UNAME_S),Darwin)
Expand Down Expand Up @@ -113,7 +113,7 @@ shellcheck:
gofmt_check:
@echo "==> ensure code adheres to gofmt (with vendor directory excluded)"
@echo ""
@GOFMT=$$(gofmt -l ${GOFILES_NOVENDOR}); \
@GOFMT=$$(gofmt -w -r 'interface{} -> any' -l ${GOFILES_NOVENDOR_NOMOCK}); \
if [ -n "$${GOFMT}" ]; then \
echo "gofmt checking failed:\n"; echo "$${GOFMT} \n"; exit 1; \
fi
Expand Down
18 changes: 9 additions & 9 deletions commands/activations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ func TestActivationsCommand(t *testing.T) {
assert.ElementsMatch(t, expected, names)
}

var hello1Result = whisk.Result(map[string]interface{}{
var hello1Result = whisk.Result(map[string]any{
"body": "Hello stranger!",
})

var hello2Result = whisk.Result(map[string]interface{}{
var hello2Result = whisk.Result(map[string]any{
"body": "Hello Archie!",
})

var hello3Result = whisk.Result(map[string]interface{}{
var hello3Result = whisk.Result(map[string]any{
"error": "Missing main/no code to execute.",
})

Expand Down Expand Up @@ -354,10 +354,10 @@ func TestActivationsList(t *testing.T) {
}

count := false
var limit interface{}
var since interface{}
var upto interface{}
var skip interface{}
var limit any
var since any
var upto any
var skip any

if tt.doctlFlags != nil {
for k, v := range tt.doctlFlags {
Expand Down Expand Up @@ -466,8 +466,8 @@ func TestActivationsLogs(t *testing.T) {
activationId = config.Args[0]
}

var limit interface{}
var funcName interface{}
var limit any
var funcName any

if tt.doctlFlags != nil {
for k, v := range tt.doctlFlags {
Expand Down
2 changes: 1 addition & 1 deletion commands/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func RunAuthList(c *CmdConfig) error {
return nil
}

func displayAuthContexts(out io.Writer, currentContext string, contexts map[string]interface{}) {
func displayAuthContexts(out io.Writer, currentContext string, contexts map[string]any) {
// Because the default context isn't present on the auth-contexts field,
// we add it manually so that it's always included in the output, and so
// we can check if it's the current context.
Expand Down
26 changes: 13 additions & 13 deletions commands/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ func TestAuthInitConfig(t *testing.T) {
// Ensure that the dev.config.set.dev-config setting is correct to prevent
// a conflict with the base config setting.
devConfig := configFile["dev"]
devConfigSetting := devConfig.(map[interface{}]interface{})["config"]
expectedConfigSetting := map[interface{}]interface{}(
map[interface{}]interface{}{
"set": map[interface{}]interface{}{"dev-config": ""},
"unset": map[interface{}]interface{}{"dev-config": ""},
devConfigSetting := devConfig.(map[any]any)["config"]
expectedConfigSetting := map[any]any(
map[any]any{
"set": map[any]any{"dev-config": ""},
"unset": map[any]any{"dev-config": ""},
},
)
assert.Equal(t, expectedConfigSetting, devConfigSetting, "unexpected setting for 'dev.config'")
Expand Down Expand Up @@ -140,15 +140,15 @@ func TestAuthForcesLowercase(t *testing.T) {
withTestClient(t, func(config *CmdConfig, tm *tcMocks) {
tm.oauth.EXPECT().TokenInfo(gomock.Any()).Return(&do.OAuthTokenInfo{}, nil)

contexts := map[string]interface{}{doctl.ArgDefaultContext: true, "TestCapitalCase": true}
contexts := map[string]any{doctl.ArgDefaultContext: true, "TestCapitalCase": true}
context := "TestCapitalCase"
viper.Set("auth-contexts", contexts)
viper.Set("context", context)

err := RunAuthInit(retrieveUserTokenFunc)(config)
assert.NoError(t, err)

contexts = map[string]interface{}{doctl.ArgDefaultContext: true, "TestCapitalCase": true}
contexts = map[string]any{doctl.ArgDefaultContext: true, "TestCapitalCase": true}
viper.Set("auth-contexts", contexts)
viper.Set("context", "contextDoesntExist")
err = RunAuthSwitch(config)
Expand All @@ -175,14 +175,14 @@ func Test_displayAuthContexts(t *testing.T) {
Name string
Out *bytes.Buffer
Context string
Contexts map[string]interface{}
Contexts map[string]any
Expected string
}{
{
Name: "default context only",
Out: &bytes.Buffer{},
Context: doctl.ArgDefaultContext,
Contexts: map[string]interface{}{
Contexts: map[string]any{
doctl.ArgDefaultContext: true,
},
Expected: "default (current)\n",
Expand All @@ -191,7 +191,7 @@ func Test_displayAuthContexts(t *testing.T) {
Name: "default context and additional context",
Out: &bytes.Buffer{},
Context: doctl.ArgDefaultContext,
Contexts: map[string]interface{}{
Contexts: map[string]any{
doctl.ArgDefaultContext: true,
"test": true,
},
Expand All @@ -201,7 +201,7 @@ func Test_displayAuthContexts(t *testing.T) {
Name: "default context and additional context set to additional context",
Out: &bytes.Buffer{},
Context: "test",
Contexts: map[string]interface{}{
Contexts: map[string]any{
doctl.ArgDefaultContext: true,
"test": true,
},
Expand All @@ -211,7 +211,7 @@ func Test_displayAuthContexts(t *testing.T) {
Name: "unset context",
Out: &bytes.Buffer{},
Context: "missing",
Contexts: map[string]interface{}{
Contexts: map[string]any{
doctl.ArgDefaultContext: true,
"test": true,
},
Expand Down Expand Up @@ -284,7 +284,7 @@ func TestTokenInputValidator(t *testing.T) {
}
}

type testConfig map[string]interface{}
type testConfig map[string]any

type nopWriteCloser struct {
io.Writer
Expand Down
2 changes: 1 addition & 1 deletion commands/databases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ func TestDatabaseGetSQLModes(t *testing.T) {
}

func TestDatabaseSetSQLModes(t *testing.T) {
testSQLModesInterface := make([]interface{}, 0, len(testSQLModes))
testSQLModesInterface := make([]any, 0, len(testSQLModes))
for _, sqlMode := range testSQLModes {
testSQLModesInterface = append(testSQLModesInterface, sqlMode)
}
Expand Down
6 changes: 3 additions & 3 deletions commands/displayers/1_click.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ func (oc *OneClick) ColMap() map[string]string {
}

// KV maps the values of a 1-click to an output
func (oc *OneClick) KV() []map[string]interface{} {
out := make([]map[string]interface{}, 0, len(oc.OneClicks))
func (oc *OneClick) KV() []map[string]any {
out := make([]map[string]any, 0, len(oc.OneClicks))

for _, oneClick := range oc.OneClicks {
o := map[string]interface{}{
o := map[string]any{
"SLUG": oneClick.Slug,
"TYPE": oneClick.Type,
}
Expand Down
6 changes: 3 additions & 3 deletions commands/displayers/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func (a *Account) ColMap() map[string]string {
}
}

func (a *Account) KV() []map[string]interface{} {
x := map[string]interface{}{
func (a *Account) KV() []map[string]any {
x := map[string]any{
"Email": a.Email, "DropletLimit": a.DropletLimit,
"EmailVerified": a.EmailVerified, "UUID": a.UUID,
"Status": a.Status,
Expand All @@ -53,5 +53,5 @@ func (a *Account) KV() []map[string]interface{} {
x["TeamUUID"] = a.Team.UUID
}

return []map[string]interface{}{x}
return []map[string]any{x}
}
6 changes: 3 additions & 3 deletions commands/displayers/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ func (a *Action) ColMap() map[string]string {
}
}

func (a *Action) KV() []map[string]interface{} {
out := make([]map[string]interface{}, 0, len(a.Actions))
func (a *Action) KV() []map[string]any {
out := make([]map[string]any, 0, len(a.Actions))

for _, x := range a.Actions {
region := ""
if x.Region != nil {
region = x.Region.Slug
}
o := map[string]interface{}{
o := map[string]any{
"ID": x.ID, "Status": x.Status, "Type": x.Type,
"StartedAt": x.StartedAt, "CompletedAt": x.CompletedAt,
"ResourceID": x.ResourceID, "ResourceType": x.ResourceType,
Expand Down
8 changes: 4 additions & 4 deletions commands/displayers/activations.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ func (a *Activation) JSON(out io.Writer) error {
}

// KV implements Displayable
func (a *Activation) KV() []map[string]interface{} {
out := make([]map[string]interface{}, 0, len(a.Activations))
func (a *Activation) KV() []map[string]any {
out := make([]map[string]any, 0, len(a.Activations))

for _, actv := range a.Activations {
o := map[string]interface{}{
o := map[string]any{
"Datetime": time.UnixMilli(actv.Start).Format("01/02 03:04:05"),
"Status": GetActivationStatus(actv.StatusCode),
"Kind": getActivationAnnotationValue(actv, "kind"),
Expand Down Expand Up @@ -117,7 +117,7 @@ func GetActivationPackageName(a whisk.Activation) string {

return ""
}
func getActivationAnnotationValue(a whisk.Activation, key string) interface{} {
func getActivationAnnotationValue(a whisk.Activation, key string) any {
if a.Annotations == nil {
return nil
}
Expand Down
48 changes: 24 additions & 24 deletions commands/displayers/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func (a Apps) ColMap() map[string]string {
}
}

func (a Apps) KV() []map[string]interface{} {
out := make([]map[string]interface{}, len(a))
func (a Apps) KV() []map[string]any {
out := make([]map[string]any, len(a))

for i, app := range a {
var (
Expand All @@ -55,7 +55,7 @@ func (a Apps) KV() []map[string]interface{} {
inProgressDeploymentID = app.InProgressDeployment.ID
}

out[i] = map[string]interface{}{
out[i] = map[string]any{
"ID": app.ID,
"Spec.Name": app.Spec.Name,
"DefaultIngress": app.DefaultIngress,
Expand Down Expand Up @@ -98,8 +98,8 @@ func (d Deployments) ColMap() map[string]string {
}
}

func (d Deployments) KV() []map[string]interface{} {
out := make([]map[string]interface{}, len(d))
func (d Deployments) KV() []map[string]any {
out := make([]map[string]any, len(d))

for i, deployment := range d {
var progress string
Expand All @@ -111,7 +111,7 @@ func (d Deployments) KV() []map[string]interface{} {
}
}

out[i] = map[string]interface{}{
out[i] = map[string]any{
"ID": deployment.ID,
"Cause": deployment.Cause,
"Progress": progress,
Expand Down Expand Up @@ -156,11 +156,11 @@ func (r AppRegions) ColMap() map[string]string {
}
}

func (r AppRegions) KV() []map[string]interface{} {
out := make([]map[string]interface{}, len(r))
func (r AppRegions) KV() []map[string]any {
out := make([]map[string]any, len(r))

for i, region := range r {
out[i] = map[string]interface{}{
out[i] = map[string]any{
"Slug": region.Slug,
"Label": region.Label,
"Continent": region.Continent,
Expand Down Expand Up @@ -201,12 +201,12 @@ func (t AppTiers) ColMap() map[string]string {
}
}

func (t AppTiers) KV() []map[string]interface{} {
out := make([]map[string]interface{}, len(t))
func (t AppTiers) KV() []map[string]any {
out := make([]map[string]any, len(t))

for i, tier := range t {
egressBandwidth, _ := strconv.ParseUint(tier.EgressBandwidthBytes, 10, 64)
out[i] = map[string]interface{}{
out[i] = map[string]any{
"Name": tier.Name,
"Slug": tier.Slug,
"EgressBandwidthBytes": BytesToHumanReadableUnitBinary(egressBandwidth),
Expand Down Expand Up @@ -252,8 +252,8 @@ func (is AppInstanceSizes) ColMap() map[string]string {
}
}

func (is AppInstanceSizes) KV() []map[string]interface{} {
out := make([]map[string]interface{}, len(is))
func (is AppInstanceSizes) KV() []map[string]any {
out := make([]map[string]any, len(is))

for i, instanceSize := range is {
memory, _ := strconv.ParseUint(instanceSize.MemoryBytes, 10, 64)
Expand All @@ -269,7 +269,7 @@ func (is AppInstanceSizes) KV() []map[string]interface{} {
upgradeDowngradePath = upgradeDowngradePath + " -> " + instanceSize.TierUpgradeTo
}

out[i] = map[string]interface{}{
out[i] = map[string]any{
"Name": instanceSize.Name,
"Slug": instanceSize.Slug,
"CPUs": cpus,
Expand Down Expand Up @@ -327,7 +327,7 @@ func (r AppProposeResponse) ColMap() map[string]string {
}
}

func (r AppProposeResponse) KV() []map[string]interface{} {
func (r AppProposeResponse) KV() []map[string]any {
existingStatic, _ := strconv.ParseInt(r.Res.ExistingStaticApps, 10, 64)
maxFreeStatic, _ := strconv.ParseInt(r.Res.MaxFreeStaticApps, 10, 64)
var paidStatic int64
Expand All @@ -352,7 +352,7 @@ func (r AppProposeResponse) KV() []map[string]interface{} {
upgradeCost = fmt.Sprintf("%0.2f", r.Res.AppTierUpgradeCost)
}

out := map[string]interface{}{
out := map[string]any{
"AppNameAvailable": boolToYesNo(r.Res.AppNameAvailable),
"AppIsStatic": boolToYesNo(r.Res.AppIsStatic),
"StaticApps": staticApps,
Expand All @@ -365,7 +365,7 @@ func (r AppProposeResponse) KV() []map[string]interface{} {
out["AppNameSuggestion"] = r.Res.AppNameSuggestion
}

return []map[string]interface{}{out}
return []map[string]any{out}
}

func (r AppProposeResponse) JSON(w io.Writer) error {
Expand Down Expand Up @@ -402,8 +402,8 @@ func (a AppAlerts) ColMap() map[string]string {
}
}

func (a AppAlerts) KV() []map[string]interface{} {
out := make([]map[string]interface{}, len(a))
func (a AppAlerts) KV() []map[string]any {
out := make([]map[string]any, len(a))

for i, alert := range a {
var trigger string
Expand Down Expand Up @@ -439,7 +439,7 @@ func (a AppAlerts) KV() []map[string]interface{} {
trigger = "Unknown"
}

out[i] = map[string]interface{}{
out[i] = map[string]any{
"ID": alert.ID,
"Spec.Rule": alert.Spec.Rule,
"Trigger": trigger,
Expand Down Expand Up @@ -480,11 +480,11 @@ func (b Buildpacks) ColMap() map[string]string {
}
}

func (b Buildpacks) KV() []map[string]interface{} {
out := make([]map[string]interface{}, len(b))
func (b Buildpacks) KV() []map[string]any {
out := make([]map[string]any, len(b))

for i, bp := range b {
out[i] = map[string]interface{}{
out[i] = map[string]any{
"Name": bp.Name,
"ID": bp.ID,
"Version": bp.Version,
Expand Down
Loading

0 comments on commit 516b893

Please sign in to comment.