-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
23afd93
fix: add assets/icon.png fallback for icon auto-detection
srtaalej 5176129
feat: support png, jpg, jpeg, gif for icon auto-detection
srtaalej c9abb30
refactor: extract icon resolution to internal/icon package
srtaalej 14c811f
Merge branch 'main' into ale-icon-assets-fallback
srtaalej b626cec
feat: support SLACK_CLI_APP_ICON_PATH env var for icon override
srtaalej 95ded37
merge: resolve conflict with main in install_test.go
srtaalej d7e7ccd
Update internal/config/config.go
srtaalej d599052
fix: address review feedback for icon path resolution
srtaalej 8df3140
Merge branch 'main' into ale-icon-assets-fallback
srtaalej 87a4646
Update internal/pkg/apps/install.go
srtaalej 061e54f
fix: update test to match manifest icon early-return behavior
srtaalej 2778c01
Merge branch 'main' into ale-icon-env-var
srtaalej 3a8c3e5
merge: integrate icon assets fallback from #509
srtaalej 805fdaf
merge: resolve conflicts with main after #509 squash merge
srtaalej ac8245a
Merge branch 'main' into ale-icon-env-var
srtaalej f57be2f
Update internal/pkg/apps/install.go
srtaalej f498dc2
refactor: remove manifestIcon param from icon.ResolveIconPath
srtaalej ed4c940
Merge branch 'main' into ale-icon-env-var
srtaalej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -218,8 +218,7 @@ func Install(ctx context.Context, clients *shared.ClientFactory, auth types.Slac | |
| } | ||
| } | ||
|
|
||
| // upload icon, default to assets/icon.{png,jpg,jpeg,gif} or icon.{png,jpg,jpeg,gif} | ||
| iconPath := icon.ResolveIconPath(clients.Fs, slackManifest.Icon) | ||
| iconPath := resolveIconPath(ctx, clients, slackManifest.Icon) | ||
| if iconPath != "" { | ||
| err = updateIcon(ctx, clients, iconPath, app.AppID, token, manifest.IsFunctionRuntimeSlackHosted()) | ||
| if err != nil { | ||
|
|
@@ -519,7 +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) { | ||
| iconPath := icon.ResolveIconPath(clients.Fs, slackManifest.Icon) | ||
| iconPath := resolveIconPath(ctx, clients, slackManifest.Icon) | ||
| if iconPath != "" { | ||
| _, iconErr := clients.API().IconSet(ctx, clients.Fs, token, app.AppID, iconPath) | ||
| if iconErr != nil { | ||
|
|
@@ -639,6 +638,28 @@ 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 > assets/ and root fallback | ||
| func resolveIconPath(ctx context.Context, clients *shared.ClientFactory, manifestIcon string) string { | ||
| if envIconPath := clients.Config.AppIconPathFlag; envIconPath != "" { | ||
| if _, err := clients.Fs.Stat(envIconPath); err == nil { | ||
| return envIconPath | ||
| } | ||
| 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 := clients.Fs.Stat(manifestIcon); err == nil { | ||
| 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 "" | ||
| } | ||
| return icon.ResolveIconPath(clients.Fs) | ||
| } | ||
|
|
||
| // 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 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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