Skip to content

Commit

Permalink
Remove the duplicate cockroachdb versions generated by the API respon…
Browse files Browse the repository at this point in the history
…se (#997)
  • Loading branch information
prafull01 authored Jul 21, 2023
1 parent f441d93 commit da60e7b
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 7 deletions.
2 changes: 2 additions & 0 deletions config/manager/patches/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,5 @@ spec:
value: cockroachdb/cockroach:v23.1.3
- name: RELATED_IMAGE_COCKROACH_v23_1_4
value: cockroachdb/cockroach:v23.1.4
- name: RELATED_IMAGE_COCKROACH_v23_1_5
value: cockroachdb/cockroach:v23.1.5
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,5 @@ spec:
image: registry.connect.redhat.com/cockroachdb/cockroach@sha256:40f00476b63cb9e370fe85f01407173693213a9242fc117d28b06378ca0d98e0
- name: RELATED_IMAGE_COCKROACH_v23_1_4
image: registry.connect.redhat.com/cockroachdb/cockroach@sha256:42c9930d6861f6a2147ed6e01827eddd730279966763ec68868567a19cc164ab
- name: RELATED_IMAGE_COCKROACH_v23_1_5
image: registry.connect.redhat.com/cockroachdb/cockroach@sha256:acbfee4492327a720fe7da76929a86192d8af2442bbb76f0a089f6a81a890be3
2 changes: 2 additions & 0 deletions config/manifests/patches/deployment_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,6 @@ spec:
value: registry.connect.redhat.com/cockroachdb/cockroach@sha256:40f00476b63cb9e370fe85f01407173693213a9242fc117d28b06378ca0d98e0
- name: RELATED_IMAGE_COCKROACH_v23_1_4
value: registry.connect.redhat.com/cockroachdb/cockroach@sha256:42c9930d6861f6a2147ed6e01827eddd730279966763ec68868567a19cc164ab
- name: RELATED_IMAGE_COCKROACH_v23_1_5
value: registry.connect.redhat.com/cockroachdb/cockroach@sha256:acbfee4492327a720fe7da76929a86192d8af2442bbb76f0a089f6a81a890be3
image: RH_COCKROACH_OP_IMAGE_PLACEHOLDER
2 changes: 1 addition & 1 deletion config/samples/crdb-tls-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ kind: CrdbCluster
metadata:
name: crdb-tls-example
spec:
cockroachDBVersion: v23.1.4
cockroachDBVersion: v23.1.5
dataStore:
pvc:
spec:
Expand Down
3 changes: 3 additions & 0 deletions crdb-versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,6 @@ CrdbVersions:
- image: cockroachdb/cockroach:v23.1.4
redhatImage: registry.connect.redhat.com/cockroachdb/cockroach@sha256:42c9930d6861f6a2147ed6e01827eddd730279966763ec68868567a19cc164ab
tag: v23.1.4
- image: cockroachdb/cockroach:v23.1.5
redhatImage: registry.connect.redhat.com/cockroachdb/cockroach@sha256:acbfee4492327a720fe7da76929a86192d8af2442bbb76f0a089f6a81a890be3
tag: v23.1.5
2 changes: 1 addition & 1 deletion examples/client-secure-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
serviceAccountName: cockroachdb-sa
containers:
- name: cockroachdb-client-secure
image: cockroachdb/cockroach:v23.1.4
image: cockroachdb/cockroach:v23.1.5
imagePullPolicy: IfNotPresent
volumeMounts:
- name: client-certs
Expand Down
4 changes: 2 additions & 2 deletions examples/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ spec:
memory: 8Gi
tlsEnabled: true
# You can set either a version of the db or a specific image name
# cockroachDBVersion: v23.1.4
# cockroachDBVersion: v23.1.5
image:
name: cockroachdb/cockroach:v23.1.4
name: cockroachdb/cockroach:v23.1.5
# nodes refers to the number of crdb pods that are created
# via the statefulset
nodes: 3
Expand Down
2 changes: 1 addition & 1 deletion examples/smoketest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ spec:
memory: 300Mi
tlsEnabled: true
image:
name: cockroachdb/cockroach:v23.1.4
name: cockroachdb/cockroach:v23.1.5
nodes: 3
12 changes: 11 additions & 1 deletion hack/update_crdb_versions/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,11 @@ func fetchAPIResponse(url string) (*apiResponse, error) {

func generateOutput(resp *apiResponse) *yamlOutput {
output := new(yamlOutput)
usedTags := make(map[string]bool)
for _, data := range resp.Data {
for _, r := range data.Repos {
for _, tag := range r.Tags {
if !isValid(tag.Name) {
if !isValid(tag.Name) || isUsed(usedTags, tag.Name) {
continue
}

Expand Down Expand Up @@ -156,6 +157,15 @@ func isValid(tag string) bool {
return semVerRegex.MatchString(tag)
}

// isUsed returns true if a tag has already been used to generate cockroach image.
func isUsed(usedTags map[string]bool, tag string) bool {
if _, ok := usedTags[tag]; ok {
return true
}
usedTags[tag] = true
return false
}

// apiResponse encapsulates the response from the RH Catalog API.
type apiResponse struct {
Data []struct {
Expand Down
2 changes: 2 additions & 0 deletions install/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ spec:
value: cockroachdb/cockroach:v23.1.3
- name: RELATED_IMAGE_COCKROACH_v23_1_4
value: cockroachdb/cockroach:v23.1.4
- name: RELATED_IMAGE_COCKROACH_v23_1_5
value: cockroachdb/cockroach:v23.1.5
- name: OPERATOR_NAME
value: cockroachdb
- name: POD_NAME
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.11.0
2.11.0

0 comments on commit da60e7b

Please sign in to comment.