-
Notifications
You must be signed in to change notification settings - Fork 31
feat: support SLACK_CLI_APP_ICON_PATH env var for icon override #519
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
b626cec
95ded37
d7e7ccd
d599052
87a4646
061e54f
2778c01
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 |
|---|---|---|
|
|
@@ -218,13 +218,7 @@ func Install(ctx context.Context, clients *shared.ClientFactory, auth types.Slac | |
| } | ||
| } | ||
|
|
||
| // upload icon, default to icon.png | ||
| var iconPath = slackManifest.Icon | ||
| if iconPath == "" { | ||
| if _, err := os.Stat("icon.png"); !os.IsNotExist(err) { | ||
| iconPath = "icon.png" | ||
| } | ||
| } | ||
|
Comment on lines
-221
to
-227
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. 📸 thought: Keeping this inline might be alright to avoided redirected logic? ⛈️ ramble: I might suggest we instead also extract the "upload" logic that follows this since it's duplicated too, but I'd much prefer the |
||
| iconPath := resolveIconPath(ctx, clients, slackManifest.Icon) | ||
| if iconPath != "" { | ||
| err = updateIcon(ctx, clients, iconPath, app.AppID, token, manifest.IsFunctionRuntimeSlackHosted()) | ||
| if err != nil { | ||
|
|
@@ -524,12 +518,7 @@ func InstallLocalApp(ctx context.Context, clients *shared.ClientFactory, orgGran | |
|
|
||
| // upload icon for non-hosted apps (gated behind set-icon experiment) | ||
| if clients.Config.WithExperimentOn(experiment.SetIcon) { | ||
| var iconPath = slackManifest.Icon | ||
| if iconPath == "" { | ||
| if _, err := os.Stat("icon.png"); !os.IsNotExist(err) { | ||
| iconPath = "icon.png" | ||
| } | ||
| } | ||
| iconPath := resolveIconPath(ctx, clients, slackManifest.Icon) | ||
| if iconPath != "" { | ||
| _, iconErr := clients.API().IconSet(ctx, clients.Fs, token, app.AppID, iconPath) | ||
| if iconErr != nil { | ||
|
|
@@ -649,6 +638,31 @@ func appendLocalToDisplayName(manifest *types.AppManifest) { | |
| } | ||
| } | ||
|
|
||
| // resolveIconPath determines the icon file path using the priority chain: | ||
| // SLACK_CLI_APP_ICON_PATH env var > manifest icon field > icon.png in project root | ||
| func resolveIconPath(ctx context.Context, clients *shared.ClientFactory, manifestIcon string) string { | ||
| if envIconPath := clients.Config.AppIconPathFlag; envIconPath != "" { | ||
| if _, err := os.Stat(envIconPath); !os.IsNotExist(err) { | ||
| return envIconPath | ||
| } | ||
|
Comment on lines
+645
to
+647
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. 🪬 question: Is this a check we should also include for |
||
| clients.IO.PrintDebug(ctx, "SLACK_CLI_APP_ICON_PATH file not found: %s", envIconPath) | ||
| _, _ = clients.IO.WriteOut().Write([]byte(style.SectionSecondaryf("Warning: icon path from SLACK_CLI_APP_ICON_PATH not found: %s", envIconPath))) | ||
|
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.
|
||
| return "" | ||
| } | ||
| if manifestIcon != "" { | ||
| if _, err := os.Stat(manifestIcon); !os.IsNotExist(err) { | ||
| return manifestIcon | ||
| } | ||
|
srtaalej marked this conversation as resolved.
|
||
| clients.IO.PrintDebug(ctx, "manifest icon file not found: %s", manifestIcon) | ||
| _, _ = clients.IO.WriteOut().Write([]byte(style.SectionSecondaryf("Warning: icon path from manifest not found: %s", manifestIcon))) | ||
| return "" | ||
| } | ||
| if _, err := os.Stat("icon.png"); !os.IsNotExist(err) { | ||
| return "icon.png" | ||
| } | ||
| return "" | ||
| } | ||
|
|
||
| // updateIcon will upload the new icon to the Slack API | ||
| func updateIcon(ctx context.Context, clients *shared.ClientFactory, iconPath, appID string, token string, isHosted bool) error { | ||
| var span opentracing.Span | ||
|
|
||
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.
👾 thought: Interesting to find "app icon path" reads more clear than "CLI app icon path" but this ought not block decision on:
🌲 ramble: I'm curious now again if "file" path needs to be specified in these values? Curious if path is clear enough on it's own...
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.
i can change it to CLIAppIconPath! i was matching it to the other vars here but it doesnt have to