Documentation
¶
Overview ¶
The library for cloud-init User Data. This is licensed under the MIT License.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Header ¶
type Header struct {
textproto.MIMEHeader
}
type MediaType ¶
type MediaType string
const ( MediaTypeCloudBoothook MediaType = "text/cloud-boothook" MediaTypeCloudConfig MediaType = "text/cloud-config" MediaTypeCloudConfigArchive MediaType = "text/cloud-config-archive" MediaTypeCloudConfigJsonp MediaType = "text/cloud-config-jsonp" MediaTypeJinja2 MediaType = "text/jinja2" MediaTypePartHandler MediaType = "text/part-handler" MediaTypeXIncludeOnceUrl MediaType = "text/x-include-once-url" MediaTypeXIncludeUrl MediaType = "text/x-include-url" MediaTypeXShellscript MediaType = "text/x-shellscript" MediaTypeXShellscriptPerBoot MediaType = "text/x-shellscript-per-boot" MediaTypeXShellscriptPerInstance MediaType = "text/x-shellscript-per-instance" MediaTypeXShellscriptPerOnce MediaType = "text/x-shellscript-per-once" )
type Multipart ¶
func NewMultipart ¶
func NewMultipart() *Multipart
func (*Multipart) Render ¶
Example ¶
package main import ( "bytes" "fmt" userdata "github.com/Aton-Kish/gouserdata" ) func main() { d := userdata.NewMultipart() cfg := []byte(`#cloud-config timezone: Europe/London`) d.AddPart(userdata.MediaTypeCloudConfig, cfg) scr := []byte(`#!/bin/bash echo 'Hello World'`) d.AddPart(userdata.MediaTypeXShellscript, scr) buf := new(bytes.Buffer) d.Render(buf) fmt.Println(buf.String()) }
Output:
Example (IncludesUtf8) ¶
package main import ( "bytes" "fmt" userdata "github.com/Aton-Kish/gouserdata" ) func main() { d := userdata.NewMultipart() cfg := []byte(`#cloud-config timezone: Asia/Tokyo`) d.AddPart(userdata.MediaTypeCloudConfig, cfg) scr := []byte(`#!/bin/bash echo 'こんにちは世界'`) d.AddPart(userdata.MediaTypeXShellscript, scr) buf := new(bytes.Buffer) d.Render(buf) fmt.Println(buf.String()) }
Output:
func (*Multipart) SetBoundary ¶
Example ¶
package main import ( "bytes" "fmt" "strings" userdata "github.com/Aton-Kish/gouserdata" ) func main() { d := userdata.NewMultipart() d.SetBoundary("+Custom+User+Data+Boundary+") scr := []byte(`#!/bin/bash echo 'Hello World'`) d.AddPart(userdata.MediaTypeXShellscript, scr) buf := new(bytes.Buffer) d.Render(buf) fmt.Println(strings.ReplaceAll(buf.String(), "\r\n", "\n")) }
Output:
Click to show internal directories.
Click to hide internal directories.