GetEffectiveExternalURL returns the external URL to use, preferring the command-line flag over the database setting. This ensures that when the --external-url flag is set, it takes precedence over any value stored in the database.
(ctx context.Context, stores *store.Store, profile *config.Profile, workspaceID string)
| 15 | // GetEffectiveExternalURL returns the external URL to use, preferring the command-line flag over the database setting. |
| 16 | // This ensures that when the --external-url flag is set, it takes precedence over any value stored in the database. |
| 17 | func GetEffectiveExternalURL(ctx context.Context, stores *store.Store, profile *config.Profile, workspaceID string) (string, error) { |
| 18 | // Use command-line flag value if set, otherwise use database value |
| 19 | externalURL := profile.ExternalURL |
| 20 | if externalURL == "" { |
| 21 | setting, err := stores.GetWorkspaceProfileSetting(ctx, workspaceID) |
| 22 | if err != nil { |
| 23 | return "", connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get workspace setting")) |
| 24 | } |
| 25 | externalURL = setting.ExternalUrl |
| 26 | } |
| 27 | |
| 28 | if externalURL == "" { |
| 29 | return "", connect.NewError(connect.CodeFailedPrecondition, errors.Errorf(setupExternalURLError)) |
| 30 | } |
| 31 | return externalURL, nil |
| 32 | } |
no test coverage detected