Skip to content

Commit eca699f

Browse files
committed
Merge branch 'main' into mwbrooks-lint-st1008
2 parents 8172b27 + 192ab46 commit eca699f

File tree

240 files changed

+2973
-2826
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+2973
-2826
lines changed

.github/workflows/dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
- name: Gather credentials
1414
id: credentials
15-
uses: actions/[email protected].2
15+
uses: actions/[email protected].3
1616
with:
1717
app-id: ${{ secrets.GH_APP_ID_RELEASER }}
1818
private-key: ${{ secrets.GH_APP_PRIVATE_KEY_RELEASER }}

.github/workflows/sync-docs-from-cli-repo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
steps:
2323
- name: Generate a GitHub token
2424
id: ghtoken
25-
uses: actions/[email protected].2
25+
uses: actions/[email protected].3
2626
with:
2727
app-id: ${{ secrets.GH_APP_ID_DOCS }}
2828
owner: slackapi

.golangci.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ linters:
3333
staticcheck:
3434
checks:
3535
- all
36-
- '-ST1003' # disable rule 'Poorly chosen identifier'
3736
- '-ST1005' # disable rule 'Incorrectly formatted error string'
3837
- '-ST1006' # disable rule 'Poorly chosen receiver name'
3938
- '-ST1023' # disable rule 'Redundant type in variable declaration'
@@ -44,6 +43,32 @@ linters:
4443
- '-QF1008' # disable rule 'Omit embedded fields from selector'
4544
- '-QF1011' # disable rule 'Omit redundant type from variable declaration'
4645
- '-ST1016' # disable rule 'Use consistent method receiver names'
46+
# https://golangci-lint.run/usage/linters/#staticcheck
47+
# https://staticcheck.dev/docs/configuration/options/#initialisms
48+
initialisms:
49+
- "ACL"
50+
- "API"
51+
- "CLI"
52+
- "EOF"
53+
- "HTML"
54+
- "HTTP"
55+
- "HTTPS"
56+
- "ID"
57+
- "IP"
58+
- "JSON"
59+
- "SDK"
60+
- "TCP"
61+
- "TLS"
62+
- "TS"
63+
- "TTL"
64+
- "UI"
65+
- "URI"
66+
- "URL"
67+
- "UTF"
68+
- "UTF8"
69+
- "UUID"
70+
- "XML"
71+
4772
formatters:
4873
enable:
4974
- gofmt

cmd/app/add.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func preRunAddCommand(ctx context.Context, clients *shared.ClientFactory) error
8989
if err != nil {
9090
return err
9191
}
92-
if manifestSource.Equals(config.MANIFEST_SOURCE_REMOTE) {
92+
if manifestSource.Equals(config.ManifestSourceRemote) {
9393
return slackerror.New(slackerror.ErrAppInstall).
9494
WithMessage("Apps cannot be installed due to project configurations").
9595
WithRemediation(

cmd/app/add_test.go

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func TestAppAddCommandPreRun(t *testing.T) {
106106
cm.Config.ExperimentsFlag = append(cm.Config.ExperimentsFlag, experiment.BoltFrameworks)
107107
cm.Config.LoadExperiments(ctx, cm.IO.PrintDebug)
108108
mockProjectConfig := config.NewProjectConfigMock()
109-
mockProjectConfig.On("GetManifestSource", mock.Anything).Return(config.MANIFEST_SOURCE_REMOTE, nil)
109+
mockProjectConfig.On("GetManifestSource", mock.Anything).Return(config.ManifestSourceRemote, nil)
110110
cm.Config.ProjectConfig = mockProjectConfig
111111
},
112112
},
@@ -118,7 +118,7 @@ func TestAppAddCommandPreRun(t *testing.T) {
118118
cm.Config.ExperimentsFlag = append(cm.Config.ExperimentsFlag, experiment.BoltFrameworks)
119119
cm.Config.LoadExperiments(ctx, cm.IO.PrintDebug)
120120
mockProjectConfig := config.NewProjectConfigMock()
121-
mockProjectConfig.On("GetManifestSource", mock.Anything).Return(config.MANIFEST_SOURCE_LOCAL, nil)
121+
mockProjectConfig.On("GetManifestSource", mock.Anything).Return(config.ManifestSourceLocal, nil)
122122
cm.Config.ProjectConfig = mockProjectConfig
123123
},
124124
},
@@ -144,32 +144,32 @@ func TestAppAddCommand(t *testing.T) {
144144
appSelectMock.On("TeamAppSelectPrompt").Return(prompts.SelectedApp{Auth: mockAuthTeam1}, nil)
145145

146146
// Mock valid session for team1
147-
cm.ApiInterface.On("ValidateSession", mock.Anything, mock.Anything).Return(api.AuthSession{
147+
cm.APIInterface.On("ValidateSession", mock.Anything, mock.Anything).Return(api.AuthSession{
148148
UserID: &mockAuthTeam1.UserID,
149149
TeamID: &mockAuthTeam1.TeamID,
150150
TeamName: &mockAuthTeam1.TeamDomain,
151151
}, nil)
152152

153153
// Mock a clean ValidateAppManifest result
154-
cm.ApiInterface.On("ValidateAppManifest", mock.Anything, mockAuthTeam1.Token, mock.Anything, mock.Anything).Return(
154+
cm.APIInterface.On("ValidateAppManifest", mock.Anything, mockAuthTeam1.Token, mock.Anything, mock.Anything).Return(
155155
api.ValidateAppManifestResult{
156156
Warnings: slackerror.Warnings{},
157157
}, nil,
158158
)
159159

160160
// Mock Host
161-
cm.ApiInterface.On("Host").Return("")
161+
cm.APIInterface.On("Host").Return("")
162162

163163
// Mock a successful CreateApp call and return our mocked AppID
164-
cm.ApiInterface.On("CreateApp", mock.Anything, mockAuthTeam1.Token, mock.Anything, mock.Anything).Return(
164+
cm.APIInterface.On("CreateApp", mock.Anything, mockAuthTeam1.Token, mock.Anything, mock.Anything).Return(
165165
api.CreateAppResult{
166166
AppID: mockAppTeam1.AppID,
167167
},
168168
nil,
169169
)
170170

171171
// Mock a successful DeveloperAppInstall
172-
cm.ApiInterface.On("DeveloperAppInstall", mock.Anything, mock.Anything, mockAuthTeam1.Token, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(
172+
cm.APIInterface.On("DeveloperAppInstall", mock.Anything, mock.Anything, mockAuthTeam1.Token, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(
173173
api.DeveloperAppInstallResult{
174174
AppID: mockAppTeam1.AppID,
175175
APIAccessTokens: struct {
@@ -178,12 +178,12 @@ func TestAppAddCommand(t *testing.T) {
178178
User string "json:\"user,omitempty\""
179179
}{},
180180
},
181-
types.SUCCESS,
181+
types.InstallSuccess,
182182
nil,
183183
)
184184

185185
// Mock existing and updated cache
186-
cm.ApiInterface.On(
186+
cm.APIInterface.On(
187187
"ExportAppManifest",
188188
mock.Anything,
189189
mock.Anything,
@@ -216,21 +216,21 @@ func TestAppAddCommand(t *testing.T) {
216216
appSelectMock.On("TeamAppSelectPrompt").Return(prompts.SelectedApp{App: mockAppTeam1, Auth: mockAuthTeam1}, nil)
217217

218218
// Mock valid session for team1
219-
cm.ApiInterface.On("ValidateSession", mock.Anything, mock.Anything).Return(api.AuthSession{
219+
cm.APIInterface.On("ValidateSession", mock.Anything, mock.Anything).Return(api.AuthSession{
220220
UserID: &mockAuthTeam1.UserID,
221221
TeamID: &mockAuthTeam1.TeamID,
222222
TeamName: &mockAuthTeam1.TeamDomain,
223223
}, nil)
224224

225225
// Mock a clean ValidateAppManifest result
226-
cm.ApiInterface.On("ValidateAppManifest", mock.Anything, mockAuthTeam1.Token, mock.Anything, mock.Anything).Return(
226+
cm.APIInterface.On("ValidateAppManifest", mock.Anything, mockAuthTeam1.Token, mock.Anything, mock.Anything).Return(
227227
api.ValidateAppManifestResult{
228228
Warnings: slackerror.Warnings{},
229229
}, nil,
230230
)
231231

232232
// Mock Host
233-
cm.ApiInterface.On("Host").Return("")
233+
cm.APIInterface.On("Host").Return("")
234234

235235
// Mock to ensure that an existing deployed app is found
236236
appClientMock := &app.AppClientMock{}
@@ -241,7 +241,7 @@ func TestAppAddCommand(t *testing.T) {
241241
cf.AppClient().AppClientInterface = appClientMock
242242

243243
// Mock to ensure that the existing deployed app is updated successfully
244-
cm.ApiInterface.On("UpdateApp", mock.Anything, mockAuthTeam1.Token, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(
244+
cm.APIInterface.On("UpdateApp", mock.Anything, mockAuthTeam1.Token, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(
245245
api.UpdateAppResult{
246246
AppID: mockAppTeam1.AppID,
247247
Credentials: api.Credentials{},
@@ -251,7 +251,7 @@ func TestAppAddCommand(t *testing.T) {
251251
)
252252

253253
// Mock a successful DeveloperAppInstall
254-
cm.ApiInterface.On("DeveloperAppInstall", mock.Anything, mock.Anything, mockAuthTeam1.Token, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(
254+
cm.APIInterface.On("DeveloperAppInstall", mock.Anything, mock.Anything, mockAuthTeam1.Token, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(
255255
api.DeveloperAppInstallResult{
256256
AppID: mockAppTeam1.AppID,
257257
APIAccessTokens: struct {
@@ -260,12 +260,12 @@ func TestAppAddCommand(t *testing.T) {
260260
User string "json:\"user,omitempty\""
261261
}{},
262262
},
263-
types.SUCCESS,
263+
types.InstallSuccess,
264264
nil,
265265
)
266266

267267
// Mock existing and updated cache
268-
cm.ApiInterface.On(
268+
cm.APIInterface.On(
269269
"ExportAppManifest",
270270
mock.Anything,
271271
mock.Anything,
@@ -306,33 +306,33 @@ func TestAppAddCommand(t *testing.T) {
306306
teamAppSelectPromptFunc = appSelectMock.TeamAppSelectPrompt
307307
appSelectMock.On("TeamAppSelectPrompt").Return(prompts.SelectedApp{App: types.NewApp(), Auth: mockOrgAuth}, nil)
308308
// Mock calls
309-
cm.ApiInterface.On("ValidateSession", mock.Anything, mock.Anything).Return(api.AuthSession{
309+
cm.APIInterface.On("ValidateSession", mock.Anything, mock.Anything).Return(api.AuthSession{
310310
UserID: &mockOrgAuth.UserID,
311311
TeamID: &mockOrgAuth.TeamID,
312312
TeamName: &mockOrgAuth.TeamDomain,
313313
}, nil)
314-
cm.ApiInterface.On("ValidateAppManifest", mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything).Return(
314+
cm.APIInterface.On("ValidateAppManifest", mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything).Return(
315315
api.ValidateAppManifestResult{}, nil,
316316
)
317-
cm.ApiInterface.On("Host").Return("")
317+
cm.APIInterface.On("Host").Return("")
318318
// Return mocked AppID
319-
cm.ApiInterface.On("CreateApp", mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything).Return(
319+
cm.APIInterface.On("CreateApp", mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything).Return(
320320
api.CreateAppResult{
321321
AppID: mockOrgApp.AppID,
322322
},
323323
nil,
324324
)
325325
// Mock call to apps.developerInstall
326-
cm.ApiInterface.On("DeveloperAppInstall", mock.Anything, mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(
326+
cm.APIInterface.On("DeveloperAppInstall", mock.Anything, mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(
327327
api.DeveloperAppInstallResult{
328328
AppID: mockOrgApp.AppID,
329329
},
330-
types.SUCCESS,
330+
types.InstallSuccess,
331331
nil,
332332
)
333333

334334
// Mock existing and updated cache
335-
cm.ApiInterface.On(
335+
cm.APIInterface.On(
336336
"ExportAppManifest",
337337
mock.Anything,
338338
mock.Anything,
@@ -353,7 +353,7 @@ func TestAppAddCommand(t *testing.T) {
353353
cm.Config.ProjectConfig = mockProjectConfig
354354
},
355355
ExpectedAsserts: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock) {
356-
cm.ApiInterface.AssertCalled(t, "DeveloperAppInstall", mock.Anything, mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything, mock.Anything, "T123", mock.Anything)
356+
cm.APIInterface.AssertCalled(t, "DeveloperAppInstall", mock.Anything, mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything, mock.Anything, "T123", mock.Anything)
357357
},
358358
},
359359
"When admin approval request is pending, outputs instructions": {
@@ -366,32 +366,32 @@ func TestAppAddCommand(t *testing.T) {
366366
teamAppSelectPromptFunc = appSelectMock.TeamAppSelectPrompt
367367
appSelectMock.On("TeamAppSelectPrompt").Return(prompts.SelectedApp{App: types.NewApp(), Auth: mockOrgAuth}, nil)
368368
// Mock calls
369-
cm.ApiInterface.On("ValidateSession", mock.Anything, mock.Anything).Return(api.AuthSession{
369+
cm.APIInterface.On("ValidateSession", mock.Anything, mock.Anything).Return(api.AuthSession{
370370
UserID: &mockOrgAuth.UserID,
371371
TeamID: &mockOrgAuth.TeamID,
372372
TeamName: &mockOrgAuth.TeamDomain,
373373
}, nil)
374-
cm.ApiInterface.On("ValidateAppManifest", mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything).Return(
374+
cm.APIInterface.On("ValidateAppManifest", mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything).Return(
375375
api.ValidateAppManifestResult{}, nil,
376376
)
377-
cm.ApiInterface.On("Host").Return("")
377+
cm.APIInterface.On("Host").Return("")
378378
// Return mocked AppID
379-
cm.ApiInterface.On("CreateApp", mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything).Return(
379+
cm.APIInterface.On("CreateApp", mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything).Return(
380380
api.CreateAppResult{
381381
AppID: mockOrgApp.AppID,
382382
},
383383
nil,
384384
)
385385
// Mock call to apps.developerInstall
386-
cm.ApiInterface.On("DeveloperAppInstall", mock.Anything, mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(
386+
cm.APIInterface.On("DeveloperAppInstall", mock.Anything, mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(
387387
api.DeveloperAppInstallResult{
388388
AppID: mockOrgApp.AppID,
389389
},
390-
types.REQUEST_PENDING,
390+
types.InstallRequestPending,
391391
nil,
392392
)
393393
// Mock existing and updated cache
394-
cm.ApiInterface.On(
394+
cm.APIInterface.On(
395395
"ExportAppManifest",
396396
mock.Anything,
397397
mock.Anything,
@@ -422,32 +422,32 @@ func TestAppAddCommand(t *testing.T) {
422422
teamAppSelectPromptFunc = appSelectMock.TeamAppSelectPrompt
423423
appSelectMock.On("TeamAppSelectPrompt").Return(prompts.SelectedApp{App: types.NewApp(), Auth: mockOrgAuth}, nil)
424424
// Mock calls
425-
cm.ApiInterface.On("ValidateSession", mock.Anything, mock.Anything).Return(api.AuthSession{
425+
cm.APIInterface.On("ValidateSession", mock.Anything, mock.Anything).Return(api.AuthSession{
426426
UserID: &mockOrgAuth.UserID,
427427
TeamID: &mockOrgAuth.TeamID,
428428
TeamName: &mockOrgAuth.TeamDomain,
429429
}, nil)
430-
cm.ApiInterface.On("ValidateAppManifest", mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything).Return(
430+
cm.APIInterface.On("ValidateAppManifest", mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything).Return(
431431
api.ValidateAppManifestResult{}, nil,
432432
)
433-
cm.ApiInterface.On("Host").Return("")
433+
cm.APIInterface.On("Host").Return("")
434434
// Return mocked AppID
435-
cm.ApiInterface.On("CreateApp", mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything).Return(
435+
cm.APIInterface.On("CreateApp", mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything).Return(
436436
api.CreateAppResult{
437437
AppID: mockOrgApp.AppID,
438438
},
439439
nil,
440440
)
441441
// Mock call to apps.developerInstall
442-
cm.ApiInterface.On("DeveloperAppInstall", mock.Anything, mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(
442+
cm.APIInterface.On("DeveloperAppInstall", mock.Anything, mock.Anything, mockOrgAuth.Token, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(
443443
api.DeveloperAppInstallResult{
444444
AppID: mockOrgApp.AppID,
445445
},
446-
types.REQUEST_CANCELLED,
446+
types.InstallRequestCancelled,
447447
nil,
448448
)
449449
// Mock existing and updated cache
450-
cm.ApiInterface.On(
450+
cm.APIInterface.On(
451451
"ExportAppManifest",
452452
mock.Anything,
453453
mock.Anything,
@@ -478,7 +478,7 @@ func TestAppAddCommand(t *testing.T) {
478478
func prepareAddMocks(t *testing.T, clients *shared.ClientFactory, clientsMock *shared.ClientsMock) {
479479
clientsMock.AddDefaultMocks()
480480

481-
clientsMock.AuthInterface.On("ResolveApiHost", mock.Anything, mock.Anything, mock.Anything).
481+
clientsMock.AuthInterface.On("ResolveAPIHost", mock.Anything, mock.Anything, mock.Anything).
482482
Return("api host")
483483
clientsMock.AuthInterface.On("ResolveLogstashHost", mock.Anything, mock.Anything, mock.Anything).
484484
Return("logstash host")
@@ -489,7 +489,7 @@ func prepareAddMocks(t *testing.T, clients *shared.ClientFactory, clientsMock *s
489489
DisplayInformation: types.DisplayInformation{
490490
Name: team1TeamDomain,
491491
},
492-
Workflows: map[string]types.Workflow{"test_workflow": {Title: "test workflow", InputParameters: types.ToRawJson(`{}`)}},
492+
Workflows: map[string]types.Workflow{"test_workflow": {Title: "test workflow", InputParameters: types.ToRawJSON(`{}`)}},
493493
},
494494
}, nil)
495495
clients.AppClient().Manifest = manifestMock

0 commit comments

Comments
 (0)