github.com/openshift/installer@v1.4.17/pkg/asset/machines/userdata.go (about) 1 package machines 2 3 import ( 4 "bytes" 5 "encoding/base64" 6 "text/template" 7 8 "github.com/pkg/errors" 9 ) 10 11 var userDataTmpl = template.Must(template.New("user-data").Parse(`apiVersion: v1 12 kind: Secret 13 metadata: 14 name: {{.name}} 15 namespace: openshift-machine-api 16 type: Opaque 17 data: 18 disableTemplating: "dHJ1ZQo=" 19 userData: {{.content}} 20 `)) 21 22 func userDataSecret(name string, content []byte) ([]byte, error) { 23 encodedData := map[string]string{ 24 "name": name, 25 "content": base64.StdEncoding.EncodeToString(content), 26 } 27 buf := &bytes.Buffer{} 28 if err := userDataTmpl.Execute(buf, encodedData); err != nil { 29 return nil, errors.Wrap(err, "failed to execute user-data template") 30 } 31 return buf.Bytes(), nil 32 }