Skip to content

Commit

Permalink
changed image config file loading to be relative to the config dir (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdob authored Oct 27, 2023
1 parent c486ee2 commit 0d26391
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/eib/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"os"
"path/filepath"

"github.com/suse-edge/edge-image-builder/pkg/build"
"github.com/suse-edge/edge-image-builder/pkg/config"
Expand All @@ -28,7 +29,7 @@ func processArgs() (*config.ImageConfig, *config.BuildConfig, error) {
verbose bool
)

flag.StringVar(&configFile, argConfigFile, "", "full path to the image configuration file")
flag.StringVar(&configFile, argConfigFile, "", "name of the image configuration file")
flag.StringVar(&configDir, argConfigDir, "", "full path to the image configuration directory")
flag.StringVar(&buildDir, argBuildDir, "", "full path to the directory to store build artifacts")
flag.BoolVar(&deleteBuildDir, argDeleteBuild, false,
Expand All @@ -38,7 +39,7 @@ func processArgs() (*config.ImageConfig, *config.BuildConfig, error) {

setupLogging(verbose)

imageConfig, err := parseImageConfig(configFile)
imageConfig, err := parseImageConfig(configFile, configDir)
if err != nil {
return nil, nil, fmt.Errorf("parsing image config file %s: %w", configFile, err)
}
Expand Down Expand Up @@ -83,8 +84,9 @@ func setupLogging(verbose bool) {
zap.ReplaceGlobals(logger)
}

func parseImageConfig(configFile string) (*config.ImageConfig, error) {
configData, err := os.ReadFile(configFile)
func parseImageConfig(configFile string, configDir string) (*config.ImageConfig, error) {
configFilePath := filepath.Join(configDir, configFile)
configData, err := os.ReadFile(configFilePath)
if err != nil {
return nil, fmt.Errorf("image configuration file \"%s\" cannot be read: %s", configFile, err)
}
Expand Down

0 comments on commit 0d26391

Please sign in to comment.