INNER CODE UNIT · Go

getGolangImageHash

projectcontour/contour · hack/actions/bump-go-version/main.go:118

func getGolangImageHash(version string) string {
	tag := strings.TrimPrefix(version, "go")
	url := fmt.Sprintf("https://registry.hub.docker.com/v2/repositories/library/golang/tags/%s", tag)

	resp, err := http.Get(url) // #nosec G107: Potential HTTP request made with variable url
	if err != nil {
		log.WithError(err).Fatal("Failed to fetch image hash from Docker Hub")
	}
	defer resp.Body.Close()

	var info struct{ Digest string }
	if err := json.NewDecoder(resp.Body).Decode(&info); err != nil {
		log.WithError(err).Fatal("Failed to parse tag info from Docker Hub API response")
	}

	if info.Digest == "" {
		log.WithField("version", version).Fatal("No image found for version")
	}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…