fix: let scheduler-k3s:preview tolerate a missing image
`common.GetDeployingAppImageName` runs `VerifyImage` and errors out when
no image has been built for the app. A freshly-created app has no image
yet, so the preview could never render for never-deployed apps. Add an
`AllowMissingImage` flag to `BuildOptions` that lets BuildAppChart
substitute a placeholder image string in that case; CommandPreview sets
it. The deploy path still passes `BuildOptions{}`, so missing-image
remains a hard error there.
This commit is contained in:
@@ -40,6 +40,12 @@ type BuildOptions struct {
|
|||||||
// release's id so app.kubernetes.io/version annotation churn does not
|
// release's id so app.kubernetes.io/version annotation churn does not
|
||||||
// appear in the diff.
|
// appear in the diff.
|
||||||
OverrideDeploymentID int64
|
OverrideDeploymentID int64
|
||||||
|
|
||||||
|
// AllowMissingImage, when true, lets BuildAppChart substitute a
|
||||||
|
// placeholder image string when no real image is available for the app
|
||||||
|
// yet (e.g. a never-deployed app being previewed). The deploy path
|
||||||
|
// leaves this false so a missing image still errors.
|
||||||
|
AllowMissingImage bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildAppChart constructs a Helm chart on disk that reflects dokku's configured
|
// BuildAppChart constructs a Helm chart on disk that reflects dokku's configured
|
||||||
@@ -71,7 +77,10 @@ func BuildAppChart(ctx context.Context, appName, imageTag string, opts BuildOpti
|
|||||||
|
|
||||||
image, err := common.GetDeployingAppImageName(appName, imageTag, "")
|
image, err := common.GetDeployingAppImageName(appName, imageTag, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, fmt.Errorf("Error getting deploying app image name: %w", err)
|
if !opts.AllowMissingImage {
|
||||||
|
return result, fmt.Errorf("Error getting deploying app image name: %w", err)
|
||||||
|
}
|
||||||
|
image = fmt.Sprintf("dokku/%s:not-yet-deployed", appName)
|
||||||
}
|
}
|
||||||
|
|
||||||
deployTimeout := getComputedDeployTimeout(appName)
|
deployTimeout := getComputedDeployTimeout(appName)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func CommandPreview(appName string, diffContext int, showSecrets bool, showSecre
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
buildOpts := BuildOptions{}
|
buildOpts := BuildOptions{AllowMissingImage: true}
|
||||||
if currentRelease != nil {
|
if currentRelease != nil {
|
||||||
buildOpts.OverrideDeploymentID = deploymentIDFromRelease(currentRelease)
|
buildOpts.OverrideDeploymentID = deploymentIDFromRelease(currentRelease)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user