Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions mantle/cmd/kola/qemuexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"fmt"
"io/ioutil"
"os/exec"
"path/filepath"
"strings"

Expand All @@ -30,6 +29,7 @@ import (
"github.com/coreos/mantle/kola"
"github.com/coreos/mantle/platform"
"github.com/coreos/mantle/platform/conf"
"github.com/coreos/mantle/util"
)

var (
Expand Down Expand Up @@ -205,11 +205,15 @@ func runQemuExec(cmd *cobra.Command, args []string) error {
return err
}
defer tmpf.Close()
cmd := exec.Command("fcct", butane)
cmd.Stdout = tmpf
if err = cmd.Run(); err != nil {

out, err := util.ButaneFileToIgnition(butane)
if err != nil {
return err
}
if _, err := tmpf.Write(out); err != nil {
return err
}

ignition = tmpf.Name()
}

Expand Down
3 changes: 2 additions & 1 deletion mantle/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190929091402-5711055976b5
github.com/aliyun/aliyun-oss-go-sdk v2.0.3+incompatible
github.com/aws/aws-sdk-go v1.34.28
github.com/coreos/butane v0.12.1
github.com/coreos/go-semver v0.3.0
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
github.com/coreos/go-systemd/v22 v22.0.0
Expand All @@ -32,7 +33,7 @@ require (
github.com/pin/tftp v2.1.0+incompatible
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v0.0.6
github.com/spf13/pflag v1.0.3
github.com/spf13/pflag v1.0.5
github.com/ulikunitz/xz v0.5.4
github.com/vincent-petithory/dataurl v0.0.0-20191104211930-d1553a71de50
github.com/vishvananda/netlink v0.0.0-20150710184826-9cff81214893
Expand Down
77 changes: 18 additions & 59 deletions mantle/go.sum

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions mantle/util/butane.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2021 Red Hat, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package util

import (
"bufio"
"io"
"io/ioutil"
"os"
"strings"

"github.com/coreos/butane/config"
"github.com/coreos/butane/config/common"
)

// ButaneStringToIgniton takes a string and translates it into Ignition data.
func ButaneStringToIgnition(s string) ([]byte, error) {
r := strings.NewReader(s)
return ButaneReaderToIgnition(r)
}

// ButaneFileToIgnition reads a file and translates it into Ignition data.
func ButaneFileToIgnition(fname string) ([]byte, error) {
in, err := os.Open(fname)
if err != nil {
return nil, err
}
defer in.Close()
b := bufio.NewReader(in)

return ButaneReaderToIgnition(b)
}

// ButaneReaderToIgnition takes an io.Reader and translates it into Ignition.
func ButaneReaderToIgnition(r io.Reader) ([]byte, error) {
data, err := ioutil.ReadAll(r)
if err != nil {
return nil, err
}
out, _, err := config.TranslateBytes(data,
common.TranslateBytesOptions{
Pretty: true,
Strict: true,
})
return out, err
}
27 changes: 27 additions & 0 deletions mantle/vendor/github.com/clarketm/json/LICENSE

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

19 changes: 19 additions & 0 deletions mantle/vendor/github.com/clarketm/json/README.md

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

Loading