-
Notifications
You must be signed in to change notification settings - Fork 24
feat(bolt-install): support using 'run' command with remote manifests #111
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
Changes from all commits
7b2d728
95c3fcf
25ebaad
fc8a40e
690c12d
d8a58c7
ebe7732
7f01038
8861074
8225002
0b29f96
a6eb8f2
3bbec60
1b3238c
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 |
|---|---|---|
|
|
@@ -340,8 +340,11 @@ func InstallLocalApp(ctx context.Context, clients *shared.ClientFactory, orgGran | |
| if err != nil { | ||
| return types.App{}, api.DeveloperAppInstallResult{}, "", err | ||
| } | ||
| if !manifestUpdates && !manifestCreates { | ||
| return app, api.DeveloperAppInstallResult{}, "", nil | ||
|
|
||
| if !clients.Config.WithExperimentOn(experiment.BoltInstall) { | ||
| if !manifestUpdates && !manifestCreates { | ||
| return app, api.DeveloperAppInstallResult{}, "", nil | ||
| } | ||
| } | ||
|
|
||
| apiInterface := clients.API() | ||
|
|
@@ -365,17 +368,42 @@ func InstallLocalApp(ctx context.Context, clients *shared.ClientFactory, orgGran | |
| clients.EventTracker.SetAuthEnterpriseID(*authSession.EnterpriseID) | ||
| } | ||
|
|
||
| slackYaml, err := clients.AppClient().Manifest.GetManifestLocal(ctx, clients.SDKConfig, clients.HookExecutor) | ||
| if err != nil { | ||
| return app, api.DeveloperAppInstallResult{}, "", err | ||
| // When the BoltInstall experiment is enabled, we need to get the manifest from the local file | ||
| // if the manifest source is local or if we are creating a new app. After an app is created, | ||
| // app settings becomes the source of truth for remote manifests, so updates and installs always | ||
| // get the latest manifest from app settings. | ||
| // When the BoltInstall experiment is disabled, we get the manifest from the local file because | ||
| // this is how the original implementation worked. | ||
| var slackManifest types.SlackYaml | ||
| if clients.Config.WithExperimentOn(experiment.BoltInstall) { | ||
| manifestSource, err := clients.Config.ProjectConfig.GetManifestSource(ctx) | ||
| if err != nil { | ||
| return app, api.DeveloperAppInstallResult{}, "", err | ||
| } | ||
| if manifestSource.Equals(config.ManifestSourceLocal) || manifestCreates { | ||
| slackManifest, err = clients.AppClient().Manifest.GetManifestLocal(ctx, clients.SDKConfig, clients.HookExecutor) | ||
| if err != nil { | ||
| return app, api.DeveloperAppInstallResult{}, "", err | ||
| } | ||
| } else { | ||
| slackManifest, err = clients.AppClient().Manifest.GetManifestRemote(ctx, auth.Token, app.AppID) | ||
| if err != nil { | ||
| return app, api.DeveloperAppInstallResult{}, "", err | ||
| } | ||
| } | ||
| } else { | ||
| slackManifest, err = clients.AppClient().Manifest.GetManifestLocal(ctx, clients.SDKConfig, clients.HookExecutor) | ||
| if err != nil { | ||
| return app, api.DeveloperAppInstallResult{}, "", err | ||
| } | ||
| } | ||
|
|
||
| log.Data["appName"] = slackYaml.DisplayInformation.Name | ||
| log.Data["appName"] = slackManifest.DisplayInformation.Name | ||
| log.Data["isUpdate"] = app.AppID != "" | ||
| log.Data["teamName"] = *authSession.TeamName | ||
| log.Log("INFO", "app_install_manifest") | ||
|
|
||
| manifest := slackYaml.AppManifest | ||
| manifest := slackManifest.AppManifest | ||
| appendLocalToDisplayName(&manifest) | ||
| if manifest.IsFunctionRuntimeSlackHosted() { | ||
| configureLocalManifest(ctx, clients, &manifest) | ||
|
|
@@ -468,6 +496,7 @@ func InstallLocalApp(ctx context.Context, clients *shared.ClientFactory, orgGran | |
| log.Info("app_install_start") | ||
| var installState types.InstallState | ||
| result, installState, err := apiInterface.DeveloperAppInstall(ctx, clients.IO, token, app, botScopes, outgoingDomains, orgGrantWorkspaceID, clients.Config.AutoRequestAAAFlag) | ||
|
|
||
| if err != nil { | ||
| err = slackerror.Wrap(err, slackerror.ErrAppInstall) | ||
| return app, api.DeveloperAppInstallResult{}, "", err | ||
|
|
@@ -483,7 +512,7 @@ func InstallLocalApp(ctx context.Context, clients *shared.ClientFactory, orgGran | |
| } | ||
|
|
||
| // | ||
| // TODO(@mbrevoort) - Currently, cannot update the icon if app is not hosted | ||
| // TODO: Currently, cannot update the icon if app is not hosted. | ||
| // | ||
| // upload icon, default to icon.png | ||
| // var iconPath = slackYaml.Icon | ||
|
|
@@ -644,6 +673,12 @@ func shouldCreateManifest(ctx context.Context, clients *shared.ClientFactory, ap | |
| if !clients.Config.WithExperimentOn(experiment.BoltFrameworks) { | ||
| return app.AppID == "", nil | ||
| } | ||
|
|
||
| // When the BoltInstall experiment is enabled, apps can always be created with any manifest source. | ||
| if clients.Config.WithExperimentOn(experiment.BoltInstall) { | ||
| return app.AppID == "", nil | ||
| } | ||
|
Comment on lines
+677
to
+680
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:
Member
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. @mwbrooks This is so good! 🧠 ✨ As later follow up we might want to wrap errors from No blocker for this PR since IMO error handling is another discussion altogether!
Member
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. Edit: This might be best to note for the conclusion of this experiment to let us streamline some of the logic above and make this case more clear 🤔
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. This is a really great suggestion! I think it would help developers move forward who don't have a local manifest file. I've made a note to follow-up on this error suggestion. ✏️ |
||
|
|
||
| manifestSource, err := clients.Config.ProjectConfig.GetManifestSource(ctx) | ||
| if err != nil { | ||
| return false, err | ||
|
|
||
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:
InstallLocalAppnow continues even with there are no manifest updates or creates. This is because it must still install the app in order to get the tokens.