Set default package status to none if deployment exists (#2894)

If package has deployment already, we should set package status to none instead of pending.
If we have package has source, we set status to pending.
If both source and deployment are empty, package marked as failure.

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Sanket Sudake
2024-01-05 18:31:13 +05:30
committed by GitHub
parent 0c1b03b862
commit 82b2848eb7
+10 -1
View File
@@ -47,7 +47,16 @@ var _ webhook.Defaulter = &Package{}
func (r *Package) Default() {
packagelog.Debug("default", zap.String("name", r.Name))
if r.Status.BuildStatus == "" {
r.Status.BuildStatus = BuildStatusPending
if !r.Spec.Deployment.IsEmpty() {
// deployment package exists
r.Status.BuildStatus = BuildStatusNone
} else if !r.Spec.Source.IsEmpty() {
// source package with no deployment is a pending build
r.Status.BuildStatus = BuildStatusPending
} else {
r.Status.BuildStatus = BuildStatusFailed // empty package
r.Status.BuildLog = "Both source and deployment are empty"
}
}
}