Skip to content

Commit

Permalink
bug: use SHA256 in alm-example (#1249)
Browse files Browse the repository at this point in the history
Except for DOCA driver for now
  • Loading branch information
rollandf authored Jan 21, 2025
2 parents 3a57814 + 79fe8fb commit d76d4c6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ generate: $(CONTROLLER_GEN) ## Generate code
.PHONY: bundle
bundle: $(OPERATOR_SDK) $(KUSTOMIZE) manifests ## Generate bundle manifests and metadata, then validate generated files.
cd hack && $(GO) run release.go --with-sha256 --templateDir ./templates/config/manager --outputDir ../config/manager/
cd hack && $(GO) run release.go --with-sha256 --templateDir ./templates/samples/ --outputDir ../config/samples/
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(TAG)
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
Expand All @@ -410,7 +411,6 @@ bundle-push: ## Push the bundle image.
.PHONY: release-build
release-build:
yq '.[].version' hack/release.yaml | grep 'latest' && exit 1 || true
cd hack && $(GO) run release.go --templateDir ./templates/samples/ --outputDir ../config/samples/
cd hack && $(GO) run release.go --templateDir ./templates/crs/ --outputDir ../example/crs
cd hack && $(GO) run release.go --templateDir ./templates/values/ --outputDir ../deployment/network-operator/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ metadata:
"config": "{\n \"configList\": [\n {\n \"resourceName\": \"rdma_shared_device_a\",\n \"rdmaHcaMax\": 63,\n \"selectors\": {\n \"vendors\": [\"15b3\"]\n }\n }\n ]\n}\n",
"image": "k8s-rdma-shared-dev-plugin",
"repository": "ghcr.io/mellanox",
"version": "v1.5.2"
"version": "sha256:9f468fdc4449e65e4772575f83aa85840a00f97165f9a00ba34695c91d610fbd"
}
}
}
]
capabilities: Basic Install
createdAt: "2025-01-07T13:49:14Z"
createdAt: "2025-01-09T07:57:44Z"
description: Deploy and manage NVIDIA networking resources in Kubernetes
features.operators.openshift.io/cnf: "false"
features.operators.openshift.io/cni: "true"
Expand Down
2 changes: 1 addition & 1 deletion config/samples/mellanox.com_v1alpha1_nicclusterpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
rdmaSharedDevicePlugin:
image: k8s-rdma-shared-dev-plugin
repository: ghcr.io/mellanox
version: v1.5.2
version: sha256:9f468fdc4449e65e4772575f83aa85840a00f97165f9a00ba34695c91d610fbd
# The config below directly propagates to k8s-rdma-shared-device-plugin configuration.
# Replace 'devices' with your (RDMA capable) netdevice name.
config: |
Expand Down
10 changes: 8 additions & 2 deletions hack/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type ReleaseImageSpec struct {
type SHA256ImageRef struct {
// ImageRef is the image reference in "sha format" e.g repo/project/image-repo@sha256:abcdef
ImageRef string
// SHA256 is the SHA256 of the image reference e.g sha256:abcdef
SHA256 string
// Name is a description of the image reference
Name string
}
Expand Down Expand Up @@ -177,6 +179,10 @@ func main() {
imageSpec := obj.(*ReleaseImageSpec)
return imageSpec.Shas[0].ImageRef
},
"Sha256": func(obj interface{}) string {
imageSpec := obj.(*ReleaseImageSpec)
return imageSpec.Shas[0].SHA256
},
}).ParseFiles(file)
if err != nil {
fmt.Printf("Error: %v\n", err)
Expand Down Expand Up @@ -221,7 +227,7 @@ func resolveImagesSha(release *Release) error {
releaseImageSpec.Shas = make([]SHA256ImageRef, len(digests))
for i, digest := range digests {
sha := fmt.Sprintf("%s/%s@%s", releaseImageSpec.Repository, releaseImageSpec.Image, digest)
releaseImageSpec.Shas[i] = SHA256ImageRef{ImageRef: sha, Name: fmt.Sprintf("doca-driver-%d", i)}
releaseImageSpec.Shas[i] = SHA256ImageRef{ImageRef: sha, Name: fmt.Sprintf("doca-driver-%d", i), SHA256: digest}
}
} else {
digest, err := resolveImageSha(releaseImageSpec.Repository, releaseImageSpec.Image,
Expand All @@ -231,7 +237,7 @@ func resolveImagesSha(release *Release) error {
}
releaseImageSpec.Shas = make([]SHA256ImageRef, 1)
sha := fmt.Sprintf("%s/%s@%s", releaseImageSpec.Repository, releaseImageSpec.Image, digest)
releaseImageSpec.Shas[0] = SHA256ImageRef{ImageRef: sha}
releaseImageSpec.Shas[0] = SHA256ImageRef{ImageRef: sha, SHA256: digest}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
rdmaSharedDevicePlugin:
image: {{ .RdmaSharedDevicePlugin.Image }}
repository: {{ .RdmaSharedDevicePlugin.Repository }}
version: {{ .RdmaSharedDevicePlugin.Version }}
version: {{ Sha256 .RdmaSharedDevicePlugin }}
# The config below directly propagates to k8s-rdma-shared-device-plugin configuration.
# Replace 'devices' with your (RDMA capable) netdevice name.
config: |
Expand Down

0 comments on commit d76d4c6

Please sign in to comment.