Skip to content
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

add release old tag #5053

Merged
merged 4 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions controllers/devbox/api/v1alpha1/devboxrelease_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ const (
DevboxReleasePhaseFailed DevboxReleasePhase = "Failed"
)

// +kubebuilder:printcolumn:name="DevboxName",type="string",JSONPath=".spec.devboxName"
// +kubebuilder:printcolumn:name="NewTag",type="string",JSONPath=".spec.newTag"
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"

// DevBoxReleaseStatus defines the observed state of DevBoxRelease
type DevBoxReleaseStatus struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default=Pending
Phase DevboxReleasePhase `json:"phase"`
// +kubebuilder:validation:Optional
lingdie marked this conversation as resolved.
Show resolved Hide resolved
OriginalImage string `json:"originalImage"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="DevboxName",type="string",JSONPath=".spec.devboxName"
// +kubebuilder:printcolumn:name="NewTag",type="string",JSONPath=".spec.newTag"
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"
// +kubebuilder:printcolumn:name="OriginalImage",type="string",JSONPath=".status.originalImage"

// DevBoxRelease is the Schema for the devboxreleases API
type DevBoxRelease struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ spec:
singular: devboxrelease
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- jsonPath: .spec.devboxName
name: DevboxName
type: string
- jsonPath: .spec.newTag
name: NewTag
type: string
- jsonPath: .status.phase
name: Phase
type: string
- jsonPath: .status.originalImage
name: OriginalImage
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: DevBoxRelease is the Schema for the devboxreleases API
Expand Down Expand Up @@ -66,6 +79,8 @@ spec:
status:
description: DevBoxReleaseStatus defines the observed state of DevBoxRelease
properties:
originalImage:
type: string
phase:
default: Pending
type: string
Expand Down
17 changes: 16 additions & 1 deletion controllers/devbox/deploy/manifests/deploy.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2807,7 +2807,20 @@ spec:
singular: devboxrelease
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- jsonPath: .spec.devboxNamåe
name: DevboxName
type: string
- jsonPath: .spec.newTag
name: NewTag
type: string
- jsonPath: .status.phase
name: Phase
type: string
- jsonPath: .status.originalImage
name: OriginalImage
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: DevBoxRelease is the Schema for the devboxreleases API
Expand Down Expand Up @@ -2845,6 +2858,8 @@ spec:
status:
description: DevBoxReleaseStatus defines the observed state of DevBoxRelease
properties:
originalImage:
type: string
phase:
default: Pending
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,16 @@ func (r *DevBoxReleaseReconciler) CreateReleaseTag(ctx context.Context, devboxRe
if err := r.Get(ctx, devboxInfo, devbox); err != nil {
return err
}
hostName, imageName, oldTag, err := r.GetHostAndImageAndTag(devbox)
hostName, imageName, oldTag, err := r.GetRegistryInfo(devbox)
if err != nil {
return err
}
logger.Info("Tagging image", "host", hostName, "image", imageName, "oldTag", oldTag, "newTag", devboxRelease.Spec.NewTag)
devboxRelease.Status.OriginalImage = imageName + ":" + oldTag
if err = r.Status().Update(ctx, devboxRelease); err != nil {
logger.Error(err, "Failed to update status", "devbox", devboxRelease.Spec.DevboxName, "newTag", devboxRelease.Spec.NewTag)
return err
}
return r.Registry.TagImage(hostName, imageName, oldTag, devboxRelease.Spec.NewTag)
}

Expand All @@ -126,7 +131,7 @@ func (r *DevBoxReleaseReconciler) DeleteReleaseTag(_ context.Context, _ *devboxv
return nil
}

func (r *DevBoxReleaseReconciler) GetHostAndImageAndTag(devbox *devboxv1alpha1.Devbox) (string, string, string, error) {
func (r *DevBoxReleaseReconciler) GetRegistryInfo(devbox *devboxv1alpha1.Devbox) (string, string, string, error) {
if len(devbox.Status.CommitHistory) == 0 {
return "", "", "", fmt.Errorf("commit history is empty")
}
Expand Down
Loading