@@ -11,7 +11,10 @@ import (
11
11
"github.com/BurntSushi/toml"
12
12
"github.com/sirupsen/logrus"
13
13
14
- "github.com/osbuild/images/pkg/blueprint"
14
+ // XXX: eventually there will be only be one importable blueprint, i.e.
15
+ // see https://github.com/osbuild/blueprint/issues/3
16
+ externalBlueprint "github.com/osbuild/blueprint/pkg/blueprint"
17
+ imagesBlueprint "github.com/osbuild/images/pkg/blueprint"
15
18
)
16
19
17
20
// legacyBuildConfig is the json based configuration that was used in
@@ -22,12 +25,12 @@ type legacyBuildConfig struct {
22
25
Blueprint * json.RawMessage `json:"blueprint"`
23
26
}
24
27
25
- type BuildConfig blueprint .Blueprint
28
+ type BuildConfig imagesBlueprint .Blueprint
26
29
27
30
// configRootDir is only overriden in tests
28
31
var configRootDir = "/"
29
32
30
- func decodeJsonBuildConfig (r io.Reader , what string ) (* BuildConfig , error ) {
33
+ func decodeJsonBuildConfig (r io.Reader , what string ) (* externalBlueprint. Blueprint , error ) {
31
34
content , err := io .ReadAll (r )
32
35
if err != nil && err != io .EOF {
33
36
return nil , fmt .Errorf ("cannot read %q: %w" , what , err )
@@ -45,7 +48,7 @@ func decodeJsonBuildConfig(r io.Reader, what string) (*BuildConfig, error) {
45
48
dec := json .NewDecoder (bytes .NewBuffer (content ))
46
49
dec .DisallowUnknownFields ()
47
50
48
- var conf BuildConfig
51
+ var conf externalBlueprint. Blueprint
49
52
if err := dec .Decode (& conf ); err != nil {
50
53
return nil , fmt .Errorf ("cannot decode %q: %w" , what , err )
51
54
}
@@ -55,10 +58,10 @@ func decodeJsonBuildConfig(r io.Reader, what string) (*BuildConfig, error) {
55
58
return & conf , nil
56
59
}
57
60
58
- func decodeTomlBuildConfig (r io.Reader , what string ) (* BuildConfig , error ) {
61
+ func decodeTomlBuildConfig (r io.Reader , what string ) (* externalBlueprint. Blueprint , error ) {
59
62
dec := toml .NewDecoder (r )
60
63
61
- var conf BuildConfig
64
+ var conf externalBlueprint. Blueprint
62
65
_ , err := dec .Decode (& conf )
63
66
if err != nil {
64
67
return nil , fmt .Errorf ("cannot decode %q: %w" , what , err )
@@ -69,7 +72,7 @@ func decodeTomlBuildConfig(r io.Reader, what string) (*BuildConfig, error) {
69
72
70
73
var osStdin = os .Stdin
71
74
72
- func loadConfig (path string ) (* BuildConfig , error ) {
75
+ func loadConfig (path string ) (* externalBlueprint. Blueprint , error ) {
73
76
var fp * os.File
74
77
var err error
75
78
@@ -93,7 +96,7 @@ func loadConfig(path string) (*BuildConfig, error) {
93
96
}
94
97
}
95
98
96
- func ReadWithFallback (userConfig string ) (* BuildConfig , error ) {
99
+ func readWithFallback (userConfig string ) (* externalBlueprint. Blueprint , error ) {
97
100
// user asked for an explicit config
98
101
if userConfig != "" {
99
102
return loadConfig (userConfig )
@@ -111,8 +114,17 @@ func ReadWithFallback(userConfig string) (*BuildConfig, error) {
111
114
}
112
115
}
113
116
if foundConfig == "" {
114
- return & BuildConfig {}, nil
117
+ return & externalBlueprint. Blueprint {}, nil
115
118
}
116
119
117
120
return loadConfig (foundConfig )
118
121
}
122
+
123
+ func ReadWithFallback (userConfig string ) (* BuildConfig , error ) {
124
+ externalBp , err := readWithFallback (userConfig )
125
+ if err != nil {
126
+ return nil , err
127
+ }
128
+ internalBp := BuildConfig (externalBlueprint .Convert (* externalBp ))
129
+ return & internalBp , nil
130
+ }
0 commit comments