func getBase64EncodedGzippedCustomScript()

in pkg/agent/utils.go [176:199]


func getBase64EncodedGzippedCustomScript(csFilename string, config *datamodel.NodeBootstrappingConfiguration) string {
	b, err := parts.Templates.ReadFile(csFilename)
	if err != nil {
		// this should never happen and this is a bug.
		panic(fmt.Sprintf("BUG: %s", err.Error()))
	}
	// translate the parameters.
	b = removeComments(b)
	templ := template.New("ContainerService template").Option("missingkey=error").Funcs(getContainerServiceFuncMap(config))
	_, err = templ.Parse(string(b))
	if err != nil {
		// this should never happen and this is a bug.
		panic(fmt.Sprintf("BUG: %s", err.Error()))
	}
	var buffer bytes.Buffer
	err = templ.Execute(&buffer, config.ContainerService)
	if err != nil {
		// this should never happen and this is a bug.
		panic(fmt.Sprintf("BUG: %s", err.Error()))
	}
	csStr := buffer.String()
	csStr = strings.ReplaceAll(csStr, "\r\n", "\n")
	return getBase64EncodedGzippedCustomScriptFromStr(csStr)
}