Skip to content

Commit

Permalink
feat: [sc-117029] Add keep annotation to KOTS (#5037)
Browse files Browse the repository at this point in the history
feat: [sc-117029] Add keep annotation to KOTS
  • Loading branch information
nvanthao authored Dec 10, 2024
1 parent d39bb2b commit 53df28f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ debug-build:

.PHONY: debug
debug: debug-build
LOG_LEVEL=$(LOG_LEVEL) dlv --listen=:2345 --headless=true --api-version=2 exec ./bin/kotsadm-debug api
LOG_LEVEL=$(LOG_LEVEL) /dlv --listen=:30001 --headless=true --api-version=2 exec ./bin/kotsadm-debug api

.PHONY: web
web:
Expand Down
2 changes: 1 addition & 1 deletion dev/dockerfiles/kotsadm/Dockerfile.local
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.23-alpine AS dlv-builder

RUN go install github.com/go-delve/delve/cmd/dlv@v1.22.1
RUN go install github.com/go-delve/delve/cmd/dlv@v1.23.1

FROM golang:1.23-alpine

Expand Down
1 change: 0 additions & 1 deletion dev/manifests/kotsadm/minio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ spec:
volumeMounts:
- mountPath: /data
name: miniodata # this is where the data is stored

volumeClaimTemplates:
- metadata:
name: miniodata
Expand Down
7 changes: 7 additions & 0 deletions pkg/operator/client/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ func (c *Client) diffAndDeleteManifests(opts DiffAndDeleteOptions) error {
}
}

// if this is a keep resource, don't delete it
// e.g. for migration to Helm v1beta2
if keep, ok := o.Metadata.Annotations["kots.io/keep"]; ok && keep == "true" {
logger.Infof("skipping deletion of resource %s/%s", o.Kind, o.Metadata.Name)
delete = false
}

decodedPreviousMap[k] = previousObject{
spec: string(decodedPreviousDoc),
delete: delete,
Expand Down
7 changes: 4 additions & 3 deletions pkg/operator/client/gvkn.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ type OverlySimpleGVKWithName struct {
}

type OverlySimpleMetadata struct {
Name string `yaml:"name"`
Namespace string `yaml:"namespace"`
Labels map[string]string `yaml:"labels,omitempty"`
Name string `yaml:"name"`
Namespace string `yaml:"namespace"`
Labels map[string]string `yaml:"labels,omitempty"`
Annotations map[string]string `yaml:"annotations,omitempty"`
}

func GetGVKWithNameAndNs(content []byte, baseNS string) (string, OverlySimpleGVKWithName) {
Expand Down

0 comments on commit 53df28f

Please sign in to comment.