Skip to content

Commit

Permalink
Add multipart mime as a config type
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Adrian Samfira <[email protected]>
  • Loading branch information
gabriel-samfira committed Jun 2, 2023
1 parent 7a19a2b commit 50b74b5
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 13 deletions.
2 changes: 1 addition & 1 deletion kola/tests/misc/cloudinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ chmod 600 ~core/.ssh/authorized_keys`),
Run: CloudInitMultipartMime,
ClusterSize: 1,
Name: "cl.cloudinit.multipart-mime",
UserData: conf.CloudConfig(multipartMimeUserdata),
UserData: conf.MultipartMimeConfig(multipartMimeUserdata),
Distros: []string{"cl"},
Platforms: []string{"qemu", "qemu-unpriv"},
})
Expand Down
39 changes: 27 additions & 12 deletions platform/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const (
kindContainerLinuxConfig
kindScript
kindButane
kindMultipartMime
)

var plog = capnslog.NewPackageLogger("github.com/flatcar/mantle", "platform/conf")
Expand All @@ -80,18 +81,19 @@ type UserData struct {
// Conf is a configuration for a Container Linux machine. It may be either a
// coreos-cloudconfig or an ignition configuration.
type Conf struct {
ignitionV1 *v1types.Config
ignitionV2 *v2types.Config
ignitionV21 *v21types.Config
ignitionV22 *v22types.Config
ignitionV23 *v23types.Config
ignitionV3 *v3types.Config
ignitionV31 *v31types.Config
ignitionV32 *v32types.Config
ignitionV33 *v33types.Config
cloudconfig *cci.CloudConfig
script string
user string
ignitionV1 *v1types.Config
ignitionV2 *v2types.Config
ignitionV21 *v21types.Config
ignitionV22 *v22types.Config
ignitionV23 *v23types.Config
ignitionV3 *v3types.Config
ignitionV31 *v31types.Config
ignitionV32 *v32types.Config
ignitionV33 *v33types.Config
cloudconfig *cci.CloudConfig
script string
multipartMime string
user string
}

func Empty() *UserData {
Expand All @@ -100,6 +102,13 @@ func Empty() *UserData {
}
}

func MultipartMimeConfig(data string) *UserData {
return &UserData{
kind: kindMultipartMime,
data: data,
}
}

func ContainerLinuxConfig(data string) *UserData {
return &UserData{
kind: kindContainerLinuxConfig,
Expand Down Expand Up @@ -148,6 +157,8 @@ func Unknown(data string) *UserData {
u.kind = kindCloudConfig
case ignerr.ErrScript:
u.kind = kindScript
case ignerr.ErrMultipartMime:
u.kind = kindMultipartMime
default:
// Guess whether this is an Ignition config or a CLC.
// This treats an invalid Ignition config as a CLC, and a
Expand Down Expand Up @@ -291,6 +302,8 @@ func (u *UserData) Render(ctPlatform string) (*Conf, error) {
case kindScript:
// pass through scripts unmodified, you are on your own.
c.script = u.data
case kindMultipartMime:
c.multipartMime = u.data
case kindIgnition:
err := renderIgnition()
if err != nil {
Expand Down Expand Up @@ -388,6 +401,8 @@ func (c *Conf) String() string {
return c.cloudconfig.String()
} else if c.script != "" {
return c.script
} else if c.multipartMime != "" {
return c.multipartMime
}

return ""
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions vendor/github.com/flatcar/ignition/config/v2_2/cloudinit.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/flatcar/ignition/config/v2_2/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 50b74b5

Please sign in to comment.