|
| 1 | +/* |
| 2 | +Copyright 2024 The Kubernetes Authors All rights reserved. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package main |
| 18 | + |
| 19 | +import ( |
| 20 | + "context" |
| 21 | + "fmt" |
| 22 | + "time" |
| 23 | + |
| 24 | + "k8s.io/klog/v2" |
| 25 | + "k8s.io/minikube/hack/update" |
| 26 | +) |
| 27 | + |
| 28 | +var schema = map[string]update.Item{ |
| 29 | + "pkg/minikube/assets/addons.go": { |
| 30 | + Replace: map[string]string{ |
| 31 | + `rocm/k8s-device-plugin:.*`: `rocm/k8s-device-plugin:{{.Version}}@{{.SHA}}",`, |
| 32 | + }, |
| 33 | + }, |
| 34 | +} |
| 35 | + |
| 36 | +type Data struct { |
| 37 | + Version string |
| 38 | + SHA string |
| 39 | +} |
| 40 | + |
| 41 | +func main() { |
| 42 | + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) |
| 43 | + defer cancel() |
| 44 | + |
| 45 | + stable, _, _, err := update.GHReleases(ctx, "ROCm", "k8s-device-plugin") |
| 46 | + if err != nil { |
| 47 | + klog.Fatalf("Unable to get stable version: %v", err) |
| 48 | + } |
| 49 | + sha, err := update.GetImageSHA(fmt.Sprintf("rocm/k8s-device-plugin:%s", stable.Tag)) |
| 50 | + if err != nil { |
| 51 | + klog.Fatalf("failed to get image SHA: %v", err) |
| 52 | + } |
| 53 | + |
| 54 | + data := Data{Version: stable.Tag, SHA: sha} |
| 55 | + |
| 56 | + update.Apply(schema, data) |
| 57 | +} |
0 commit comments