Skip to content

Commit

Permalink
Feat: add buildModuleConfig and add Module type
Browse files Browse the repository at this point in the history
  • Loading branch information
yasminvalim committed Oct 12, 2023
1 parent 2a7e202 commit 429a18b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/fcos/v1_6_exp/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Config struct {
base.Config `yaml:",inline"`
BootDevice BootDevice `yaml:"boot_device"`
Grub Grub `yaml:"grub"`
Selinux []Selinux `yaml:"selinux"`
Selinux Selinux `yaml:"selinux"`
}

type BootDevice struct {
Expand Down
48 changes: 48 additions & 0 deletions config/fcos/v1_6_exp/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,51 @@ func buildGrubConfig(gb Grub) string {
superUserCmd := fmt.Sprintf("set superusers=\"%s\"\n", strings.Join(allUsers, " "))
return "# Generated by Butane\n\n" + superUserCmd + strings.Join(cmds, "\n") + "\n"
}

func (c Config) handleSelinux(se Selinux, options common.TranslateOptions) (types.Config, translate.TranslationSet, report.Report) {

Check failure on line 371 in config/fcos/v1_6_exp/translate.go

View workflow job for this annotation

GitHub Actions / Test (1.18.x, ubuntu-latest)

func `Config.handleSelinux` is unused (unused)

Check failure on line 371 in config/fcos/v1_6_exp/translate.go

View workflow job for this annotation

GitHub Actions / Test (1.19.x, ubuntu-latest)

func `Config.handleSelinux` is unused (unused)
rendered := types.Config{}
ts := translate.NewTranslationSet("yaml", "json")
var r report.Report
yamlPath := path.New("yaml", "selinux", "content", "name")

// create boot filesystem
rendered.Storage.Filesystems = append(rendered.Storage.Filesystems,
types.Filesystem{
Device: "/dev/disk/by-label/boot",
Format: util.StrToPtr("ext4"),
Path: util.StrToPtr("/boot"),
})

selinuxModule := []byte(buildModuleConfig(c.Selinux))
src, compression, err := baseutil.MakeDataURL(selinuxModule, nil, !options.NoResourceAutoCompression)
if err != nil {
r.AddOnError(yamlPath, err)
return rendered, ts, r
}

rendered.Storage.Files = append(rendered.Storage.Files,
types.File{
Node: types.Node{
Path: "/etc/selinux/targeted/modules/active/extra/",
},
FileEmbedded1: types.FileEmbedded1{
Append: []types.Resource{
{
Source: util.StrToPtr(src),
Compression: compression,
},
},
},
})

ts.AddFromCommonSource(yamlPath, path.New("json", "storage"), rendered.Storage)
return rendered, ts, r
}

func buildModuleConfig(selinux Selinux) string {

Check failure on line 411 in config/fcos/v1_6_exp/translate.go

View workflow job for this annotation

GitHub Actions / Test (1.18.x, ubuntu-latest)

func `buildModuleConfig` is unused (unused)

Check failure on line 411 in config/fcos/v1_6_exp/translate.go

View workflow job for this annotation

GitHub Actions / Test (1.19.x, ubuntu-latest)

func `buildModuleConfig` is unused (unused)
for _, module := range selinux.Module {
return module.Content
}

return ""
}

0 comments on commit 429a18b

Please sign in to comment.