Files
kata-containers/tools/packaging/cmd/kata-pkgsync/cli/utils.go
bin 03546f75a6 runtime: change io/ioutil to io/os packages
Change io/ioutil to io/os packages because io/ioutil package
is deprecated from 1.16:

Discard => io.Discard
NopCloser => io.NopCloser
ReadAll => io.ReadAll
ReadDir => os.ReadDir
ReadFile => os.ReadFile
TempDir => os.MkdirTemp
TempFile => os.CreateTemp
WriteFile => os.WriteFile

Details: https://go.dev/doc/go1.16#ioutil

Fixes: #3265

Signed-off-by: bin <bin@hyper.sh>
2021-12-15 07:31:48 +08:00

27 lines
436 B
Go

// Copyright (c) 2019 SUSE LLC
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"fmt"
"os"
"github.com/pkg/errors"
"gopkg.in/yaml.v2"
)
func yamlUnmarshal(yamlFile string, cfg interface{}) error {
source, err := os.ReadFile(yamlFile)
if err != nil {
return err
}
err = yaml.Unmarshal(source, cfg)
if err != nil {
return errors.Wrapf(err, fmt.Sprintf("cannot unmarshal %s", yamlFile))
}
return nil
}