Skip to content
Snippets Groups Projects
Commit 59ab80a0 authored by Jonas Leder's avatar Jonas Leder
Browse files

Merge branch 'develop/kaniko' into 'master'

write image-hash.txt containing digest of manifest

See merge request !2
parents a026001a 5f379cbb
No related branches found
No related tags found
1 merge request!2write image-hash.txt containing digest of manifest
Pipeline #53326 passed
......@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"regexp"
"strings"
)
......@@ -65,3 +66,21 @@ func getImageDigest() (string, error) {
return strings.TrimSpace(string(content)), nil
}
func getManifestDigest() (string, error) {
filePath := "./manifest-digest.txt"
content, err := os.ReadFile(filePath)
if err != nil {
return "", fmt.Errorf("failed to read file: %w", err)
}
err = os.Remove(filePath)
if err != nil {
return "", fmt.Errorf("failed to delete file: %w", err)
}
re := regexp.MustCompile(`sha256:[a-f0-9]{64}`)
match := re.FindString(string(content))
return match, nil
}
......@@ -84,5 +84,11 @@ func buildManifest() {
os.Exit(1)
}
fmt.Println("Generating and uploading manifest")
executeCmd("manifest-tool push from-spec ./imagemanifest.yaml")
executeCmd("manifest-tool push from-spec ./imagemanifest.yaml | tee manifest-digest.txt")
manifest, err := getManifestDigest()
if err != nil {
fmt.Println("Failed retreiving image manifest: ", err.Error())
}
os.WriteFile("./image-hash.txt", []byte(manifest), 0777)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment