func()

in k8s/go/pkg/resolver/resolver.go [72:111]


func (r *Resolver) Resolve() (resolvedTemplate string, err error) {
	stamper, err := compat.NewStamper(r.flags.StampInfoFile)
	if err != nil {
		return "", fmt.Errorf("Failed to initialize the stamper: %w", err)
	}

	specs := []imageSpec{}
	for _, s := range r.flags.ImgSpecs {
		spec, err := parseImageSpec(s)
		if err != nil {
			return "", fmt.Errorf("Unable to parse image spec %q: %s", s, err)
		}
		specs = append(specs, spec)
	}

	substitutions := map[string]string{}
	if r.flags.SubstitutionsFile != "" {
		substitutions, err = parseSubstitutions(r.flags.SubstitutionsFile, stamper)
		if err != nil {
			return "", fmt.Errorf("Unable to parse substitutions file %s: %w", r.flags.SubstitutionsFile, err)
		}
	}

	resolvedImages, unseen, err := r.publish(specs, stamper)
	if err != nil {
		return "", fmt.Errorf("Unable to publish images: %w", err)
	}
	resolvedTemplate, err = resolveTemplate(r.flags.K8sTemplate, resolvedImages, unseen, substitutions)
	if err != nil {
		return resolvedTemplate, fmt.Errorf("Unable to resolve template file %q: %w", r.flags.K8sTemplate, err)
	}
	if len(unseen) > 0 && !r.flags.AllowUnusedImages {
		log.Printf("The following images given as --image_spec were not found in the template:")
		for i := range unseen {
			log.Printf("%s", i)
		}
		return resolvedTemplate, fmt.Errorf("--allow_unused_images can be specified to ignore this error.")
	}
	return
}