Skip to content

Commit b75d03b

Browse files
mvo5achilleas-k
authored andcommitted
bib: use the new github.com/osbuild/blueprint
This commit converts bib to use the new blueprint package from github.com/osbuild/blueprint for better compatibility with composer and our documentation. It also bumps the version of the TOML library so that we get PR#440.
1 parent 805abea commit b75d03b

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

bib/go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ module github.com/osbuild/bootc-image-builder/bib
33
go 1.22.8
44

55
require (
6-
github.com/BurntSushi/toml v1.5.0
6+
github.com/BurntSushi/toml v1.5.1-0.20250403130103-3d3abc24416a
77
github.com/cheggaaa/pb/v3 v3.1.7
88
github.com/hashicorp/go-version v1.7.0
9+
github.com/osbuild/blueprint v1.5.0
910
github.com/osbuild/image-builder-cli v0.0.0-20250331194259-63bb56e12db3
10-
github.com/osbuild/images v0.132.0
11+
github.com/osbuild/images v0.133.0
1112
github.com/sirupsen/logrus v1.9.3
1213
github.com/spf13/cobra v1.9.1
1314
github.com/spf13/pflag v1.0.6
@@ -34,6 +35,7 @@ require (
3435
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect
3536
github.com/containers/ocicrypt v1.2.1 // indirect
3637
github.com/containers/storage v1.57.1 // indirect
38+
github.com/coreos/go-semver v0.3.1 // indirect
3739
github.com/cyberphone/json-canonicalization v0.0.0-20231217050601-ba74d44ecf5f // indirect
3840
github.com/cyphar/filepath-securejoin v0.3.6 // indirect
3941
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect

bib/go.sum

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ github.com/14rcole/gopopulate v0.0.0-20180821133914-b175b219e774/go.mod h1:6/0dY
66
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
77
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
88
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
9-
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
10-
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
9+
github.com/BurntSushi/toml v1.5.1-0.20250403130103-3d3abc24416a h1:pRZNZLyCUkX30uKttIh5ihOtsqCgugM+a4WTxUULiMw=
10+
github.com/BurntSushi/toml v1.5.1-0.20250403130103-3d3abc24416a/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
1111
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
1212
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
1313
github.com/Microsoft/hcsshim v0.12.9 h1:2zJy5KA+l0loz1HzEGqyNnjd3fyZA31ZBCGKacp6lLg=
@@ -53,6 +53,8 @@ github.com/containers/ocicrypt v1.2.1 h1:0qIOTT9DoYwcKmxSt8QJt+VzMY18onl9jUXsxpV
5353
github.com/containers/ocicrypt v1.2.1/go.mod h1:aD0AAqfMp0MtwqWgHM1bUwe1anx0VazI108CRrSKINQ=
5454
github.com/containers/storage v1.57.1 h1:hKPoFsuBcB3qTzBxa4IFpZMRzUuL5Xhv/BE44W0XHx8=
5555
github.com/containers/storage v1.57.1/go.mod h1:i/Hb4lu7YgFr9G0K6BMjqW0BLJO1sFsnWQwj2UoWCUM=
56+
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
57+
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
5658
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
5759
github.com/cyberphone/json-canonicalization v0.0.0-20231217050601-ba74d44ecf5f h1:eHnXnuK47UlSTOQexbzxAZfekVz6i+LKRdj1CU5DPaM=
5860
github.com/cyberphone/json-canonicalization v0.0.0-20231217050601-ba74d44ecf5f/go.mod h1:uzvlm1mxhHkdfqitSA92i7Se+S9ksOn3a3qmv/kyOCw=
@@ -232,10 +234,12 @@ github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE
232234
github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
233235
github.com/opencontainers/selinux v1.11.1 h1:nHFvthhM0qY8/m+vfhJylliSshm8G1jJ2jDMcgULaH8=
234236
github.com/opencontainers/selinux v1.11.1/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec=
237+
github.com/osbuild/blueprint v1.5.0 h1:ca3C32Ltx+2P2eEZrI1fyutAInpwojl+NdQZKOrIR+Q=
238+
github.com/osbuild/blueprint v1.5.0/go.mod h1:0d3dlY8aSJ6jM6NHwBmJFF1VIySsp/GsDpcJQ0yrOqM=
235239
github.com/osbuild/image-builder-cli v0.0.0-20250331194259-63bb56e12db3 h1:M3yYunKH4quwJLQrnFo7dEwCTKorafNC+AUqAo7m5Yo=
236240
github.com/osbuild/image-builder-cli v0.0.0-20250331194259-63bb56e12db3/go.mod h1:0sEmiQiMo1ChSuOoeONN0RmsoZbQEvj2mlO2448gC5w=
237-
github.com/osbuild/images v0.132.0 h1:0QlLw+hymhlao8f3V2Y/Mb15dK4vKBfja0dxxT8zwqA=
238-
github.com/osbuild/images v0.132.0/go.mod h1:Ag87vmyxooiPQBJEDILbypG8/SRIear75YA78NwLix0=
241+
github.com/osbuild/images v0.133.0 h1:JS23Q2OtS9ktGyLXchsT3gCcD5wXhu/JohPWYilSGTw=
242+
github.com/osbuild/images v0.133.0/go.mod h1:Ag87vmyxooiPQBJEDILbypG8/SRIear75YA78NwLix0=
239243
github.com/ostreedev/ostree-go v0.0.0-20210805093236-719684c64e4f h1:/UDgs8FGMqwnHagNDPGOlts35QkhAZ8by3DR7nMih7M=
240244
github.com/ostreedev/ostree-go v0.0.0-20210805093236-719684c64e4f/go.mod h1:J6OG6YJVEWopen4avK3VNQSnALmmjvniMmni/YFYAwc=
241245
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=

bib/internal/buildconfig/config.go

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import (
1111
"github.com/BurntSushi/toml"
1212
"github.com/sirupsen/logrus"
1313

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"
1518
)
1619

1720
// legacyBuildConfig is the json based configuration that was used in
@@ -22,12 +25,12 @@ type legacyBuildConfig struct {
2225
Blueprint *json.RawMessage `json:"blueprint"`
2326
}
2427

25-
type BuildConfig blueprint.Blueprint
28+
type BuildConfig imagesBlueprint.Blueprint
2629

2730
// configRootDir is only overriden in tests
2831
var configRootDir = "/"
2932

30-
func decodeJsonBuildConfig(r io.Reader, what string) (*BuildConfig, error) {
33+
func decodeJsonBuildConfig(r io.Reader, what string) (*externalBlueprint.Blueprint, error) {
3134
content, err := io.ReadAll(r)
3235
if err != nil && err != io.EOF {
3336
return nil, fmt.Errorf("cannot read %q: %w", what, err)
@@ -45,7 +48,7 @@ func decodeJsonBuildConfig(r io.Reader, what string) (*BuildConfig, error) {
4548
dec := json.NewDecoder(bytes.NewBuffer(content))
4649
dec.DisallowUnknownFields()
4750

48-
var conf BuildConfig
51+
var conf externalBlueprint.Blueprint
4952
if err := dec.Decode(&conf); err != nil {
5053
return nil, fmt.Errorf("cannot decode %q: %w", what, err)
5154
}
@@ -55,10 +58,10 @@ func decodeJsonBuildConfig(r io.Reader, what string) (*BuildConfig, error) {
5558
return &conf, nil
5659
}
5760

58-
func decodeTomlBuildConfig(r io.Reader, what string) (*BuildConfig, error) {
61+
func decodeTomlBuildConfig(r io.Reader, what string) (*externalBlueprint.Blueprint, error) {
5962
dec := toml.NewDecoder(r)
6063

61-
var conf BuildConfig
64+
var conf externalBlueprint.Blueprint
6265
_, err := dec.Decode(&conf)
6366
if err != nil {
6467
return nil, fmt.Errorf("cannot decode %q: %w", what, err)
@@ -69,7 +72,7 @@ func decodeTomlBuildConfig(r io.Reader, what string) (*BuildConfig, error) {
6972

7073
var osStdin = os.Stdin
7174

72-
func loadConfig(path string) (*BuildConfig, error) {
75+
func loadConfig(path string) (*externalBlueprint.Blueprint, error) {
7376
var fp *os.File
7477
var err error
7578

@@ -93,7 +96,7 @@ func loadConfig(path string) (*BuildConfig, error) {
9396
}
9497
}
9598

96-
func ReadWithFallback(userConfig string) (*BuildConfig, error) {
99+
func readWithFallback(userConfig string) (*externalBlueprint.Blueprint, error) {
97100
// user asked for an explicit config
98101
if userConfig != "" {
99102
return loadConfig(userConfig)
@@ -111,8 +114,17 @@ func ReadWithFallback(userConfig string) (*BuildConfig, error) {
111114
}
112115
}
113116
if foundConfig == "" {
114-
return &BuildConfig{}, nil
117+
return &externalBlueprint.Blueprint{}, nil
115118
}
116119

117120
return loadConfig(foundConfig)
118121
}
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

Comments
 (0)