-
Notifications
You must be signed in to change notification settings - Fork 29
refactor: remove logger from install command #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,35 +19,31 @@ import ( | |
| "strings" | ||
|
|
||
| "github.com/opentracing/opentracing-go" | ||
| "github.com/slackapi/slack-cli/internal/logger" | ||
| "github.com/slackapi/slack-cli/internal/shared" | ||
| "github.com/slackapi/slack-cli/internal/shared/types" | ||
| "github.com/slackapi/slack-cli/internal/slackerror" | ||
| ) | ||
|
|
||
| // Add will add an app | ||
| func Add(ctx context.Context, clients *shared.ClientFactory, log *logger.Logger, auth types.SlackAuth, app types.App, orgGrantWorkspaceID string) (types.InstallState, types.App, error) { | ||
| func Add(ctx context.Context, clients *shared.ClientFactory, auth types.SlackAuth, app types.App, orgGrantWorkspaceID string) (types.InstallState, types.App, error) { | ||
| span, _ := opentracing.StartSpanFromContext(ctx, "pkg.apps.add") | ||
| defer span.Finish() | ||
|
|
||
| // Validate the auth | ||
| ctx, authSession, err := getAuthSession(ctx, clients, auth) | ||
| ctx, _, err := getAuthSession(ctx, clients, auth) | ||
| if err != nil { | ||
| return "", types.App{}, slackerror.Wrap(err, slackerror.ErrAddAppToProject) | ||
| } | ||
| log.Data["teamName"] = *authSession.TeamName | ||
|
|
||
| log.Info("on_apps_add_init") | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: This event name was broadcast but never subscribed anywhere 🤦🏻 |
||
|
|
||
| // Add app remotely via Slack API | ||
| installState, app, err := addAppRemotely(ctx, clients, log, auth, app, orgGrantWorkspaceID) | ||
| installState, app, err := addAppRemotely(ctx, clients, auth, app, orgGrantWorkspaceID) | ||
| if err != nil { | ||
| return "", types.App{}, slackerror.Wrap(err, slackerror.ErrAddAppToProject) | ||
| } | ||
|
|
||
| // Add app to apps.json | ||
| if !clients.Config.SkipLocalFs() { | ||
| if _, err := addAppLocally(ctx, clients, log, app); err != nil { | ||
| if _, err := addAppLocally(ctx, clients, app); err != nil { | ||
| return installState, types.App{}, slackerror.Wrap(err, slackerror.ErrAddAppToProject) | ||
| } | ||
| } | ||
|
|
@@ -56,9 +52,7 @@ func Add(ctx context.Context, clients *shared.ClientFactory, log *logger.Logger, | |
| } | ||
|
|
||
| // addAppLocally will add the app to the project's apps file with an empty AppID, TeamID, etc | ||
| func addAppLocally(ctx context.Context, clients *shared.ClientFactory, log *logger.Logger, app types.App) (types.App, error) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: diff doesn't show that |
||
| log.Info("on_apps_add_local") | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: Another event that was broadcast with no subscribers. |
||
|
|
||
| func addAppLocally(ctx context.Context, clients *shared.ClientFactory, app types.App) (types.App, error) { | ||
| app, err := clients.AppClient().NewDeployed(ctx, app.TeamID) | ||
| if err != nil { | ||
| if !strings.Contains(err.Error(), slackerror.ErrAppFound) { // Ignore the error when the app already exists | ||
|
|
@@ -69,22 +63,18 @@ func addAppLocally(ctx context.Context, clients *shared.ClientFactory, log *logg | |
| } | ||
|
|
||
| // addAppRemotely will create the app manifest using the current auth account's team | ||
| func addAppRemotely(ctx context.Context, clients *shared.ClientFactory, log *logger.Logger, auth types.SlackAuth, app types.App, orgGrantWorkspaceID string) (types.InstallState, types.App, error) { | ||
| log.Info("on_apps_add_remote_init") | ||
|
|
||
| func addAppRemotely(ctx context.Context, clients *shared.ClientFactory, auth types.SlackAuth, app types.App, orgGrantWorkspaceID string) (types.InstallState, types.App, error) { | ||
| if app.TeamID == "" { | ||
| // App hasn't been created yet and | ||
| // so the target team ID set by the auth | ||
| app.TeamID = auth.TeamID | ||
| } | ||
|
|
||
| app, installState, err := Install(ctx, clients, log, auth, CreateAppManifestAndInstall, app, orgGrantWorkspaceID) | ||
| app, installState, err := Install(ctx, clients, auth, CreateAppManifestAndInstall, app, orgGrantWorkspaceID) | ||
| if err != nil { | ||
| return installState, types.App{}, slackerror.Wrap(err, slackerror.ErrAppAdd) | ||
| } | ||
|
|
||
| log.Info("on_apps_add_remote_success") | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: another event that was broadcast with no subscribers 😿 |
||
|
|
||
| if !clients.Config.SkipLocalFs() { | ||
| app, err = clients.AppClient().GetDeployed(ctx, app.TeamID) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: You can search for any of the following event names to see that the output is now display where the event was previous broadcast:
app_install_manifest_createapp_install_manifest_updateapp_install_startapp_install_icon_successapp_install_icon_errorapp_install_complete