Skip to content

Commit

Permalink
works
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrero committed Jan 20, 2022
1 parent 3d4e672 commit 4f2c5dd
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions config/fcos/v1_5_exp/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package v1_5_exp

import (
"fmt"
"path/filepath"

baseutil "github.com/coreos/butane/base/util"
"github.com/coreos/butane/config/common"
Expand Down Expand Up @@ -85,7 +86,9 @@ func (c Config) ToIgn3_4Unvalidated(options common.TranslateOptions) (types.Conf
}
}

c.processPackages(&ts)
ret1, _, _ := c.processPackages(options)

ret.Storage.Files = append(ret.Storage.Files, ret1.Storage.Files...)

return ret, ts, r
}
Expand Down Expand Up @@ -302,10 +305,14 @@ func translateBootDeviceLuks(from BootDeviceLuks, options common.TranslateOption
return
}

func (c Config) processPackages(ts *translate.TranslationSet) {
func (c Config) processPackages(options common.TranslateOptions) (types.Config, report.Report, translate.TranslationSet) {
yamlPath := path.New("yaml", "inline")
ret := types.Config{}
ts := translate.NewTranslationSet("yaml", "json")
var r report.Report

if len(c.Extentions) == 0 {
fmt.Println("No Packages found: ", c.Extentions)
return
return ret, r, ts
}

fmt.Println("Packages: ", c.Extentions) // debug must delete
Expand All @@ -321,22 +328,32 @@ func (c Config) processPackages(ts *translate.TranslationSet) {
marshalledYAML, err := yaml.Marshal(&p)

if err != nil {
fmt.Printf("Error attempting to marshall the TreeFile. %v", err)
r.AddOnError(yamlPath, err)
return ret, r, ts
}

fmt.Println(string(marshalledYAML)) // debug must delete
//
//src, gzipped, err := baseutil.MakeDataURL([]byte(*from.Inline), options, nil)

/* var rendered types.Config
renderedTranslations := translate.NewTranslationSet("yaml", "json")
treeFilePath := filepath.Join("/etc", "rpm-ostree-layer.yaml")

fromPath := path.New("yaml", "storage", "filesystems", "/etc/blah?", "with_mount_unit")
file := types.File{
Node: types.Node{
Path: treeFilePath,
},
}

src, gzipped, err := baseutil.MakeDataURL([]byte(marshalledYAML), nil, options.NoResourceAutoCompression)
if err != nil || gzipped { //TODO: check for gziped somewhere else.
r.AddOnError(yamlPath, err)
return ret, r, ts
}
file.Contents.Source = util.StrToPtr(src)
mode := 0644
file.Mode = &mode

file := createTreeFileUnit
renderedTranslations.AddFromCommonSource(fromPath, path.New("json", "storage", "files", "/etc/blah"), file)
ts.AddTranslation(yamlPath, path.New("json", "storage", "files", 0, "contents", "source"))
ret.Storage.Files = append(ret.Storage.Files, file)

retConfig, retTranslations := baseutil.MergeTranslatedConfigs(rendered, renderedTranslations, *config, *ts)
*config = retConfig.(types.Config)
*ts = retTranslations */
return ret, r, ts
}

0 comments on commit 4f2c5dd

Please sign in to comment.