Skip to content

Commit f873b26

Browse files
authored
Make installer a bit more extensible (#18937)
* Support transitive version manifest merging * Add subassembly bucket to config * Add ng components to version manifest
1 parent 35d47fe commit f873b26

File tree

4 files changed

+64
-31
lines changed

4 files changed

+64
-31
lines changed

dev/version-manifest/main.go

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"io"
1010
"io/fs"
11+
"log"
1112
"os"
1213
"path/filepath"
1314
"sort"
@@ -22,7 +23,10 @@ type MD struct {
2223
}
2324

2425
func main() {
25-
produceManifest(os.Stdout, os.DirFS("."))
26+
err := produceManifest(os.Stdout, os.DirFS("."))
27+
if err != nil {
28+
log.Fatal(err)
29+
}
2630
}
2731

2832
func produceManifest(out io.Writer, dir fs.FS) error {
@@ -82,38 +86,62 @@ func produceManifest(out io.Writer, dir fs.FS) error {
8286
}
8387
}
8488

85-
// It's not clear how to maintain a stable order of keys using the YAML serializer.
86-
// If it were, we could just through this map at the YAML serializer and call it a day.
87-
// Right now, we have to produce the YAML ourselves.
88-
var print func(m map[string]interface{}, indent int) error
89-
print = func(m map[string]interface{}, indent int) error {
90-
keys := make([]string, 0, len(m))
91-
for v := range m {
92-
keys = append(keys, v)
89+
vers, err := fs.Glob(dir, "**/versions.yaml")
90+
if err != nil {
91+
return err
92+
}
93+
for _, md := range vers {
94+
b, err := fs.ReadFile(dir, md)
95+
if err != nil {
96+
return err
97+
}
98+
var versions struct {
99+
Commit string `yaml:"commit"`
100+
Version string `yaml:"version"`
101+
Components map[string]interface{} `yaml:"components"`
102+
}
103+
err = yaml.Unmarshal(b, &versions)
104+
if err != nil {
105+
return xerrors.Errorf("cannot unmarshal %s: %w", md, err)
93106
}
94-
sort.Strings(keys)
95-
96-
for _, k := range keys {
97-
v := m[k]
98-
fmt.Fprintf(out, "%s%s:", strings.Repeat(" ", indent), k)
99-
if c, ok := v.(map[string]interface{}); ok {
100-
fmt.Fprintln(out)
101-
err := print(c, indent+1)
102-
if err != nil {
103-
return err
104-
}
105-
continue
106-
}
107-
if c, ok := v.(string); ok {
108-
fmt.Fprintf(out, " %s\n", c)
109-
fmt.Fprintln(out)
110-
continue
111-
}
112107

113-
return xerrors.Errorf("unknown value type - this should never happen")
108+
for k, v := range versions.Components {
109+
res["components"].(map[string]interface{})[k] = v
114110
}
115-
return nil
116111
}
117112

118-
return print(res, 0)
113+
return print(out, res, 0)
114+
}
115+
116+
// print serializes the given map to YAML.
117+
// It's not clear how to maintain a stable order of keys using the YAML serializer.
118+
// If it were, we could just through this map at the YAML serializer and call it a day.
119+
// Right now, we have to produce the YAML ourselves.
120+
func print(out io.Writer, m map[string]interface{}, indent int) error {
121+
keys := make([]string, 0, len(m))
122+
for v := range m {
123+
keys = append(keys, v)
124+
}
125+
sort.Strings(keys)
126+
127+
for _, k := range keys {
128+
v := m[k]
129+
fmt.Fprintf(out, "%s%s:", strings.Repeat(" ", indent), k)
130+
if c, ok := v.(map[string]interface{}); ok {
131+
fmt.Fprintln(out)
132+
err := print(out, c, indent+1)
133+
if err != nil {
134+
return err
135+
}
136+
continue
137+
}
138+
if c, ok := v.(string); ok {
139+
fmt.Fprintf(out, " %s\n", c)
140+
fmt.Fprintln(out)
141+
continue
142+
}
143+
144+
return xerrors.Errorf("unknown value type - this should never happen")
145+
}
146+
return nil
119147
}

dev/version-manifest/version-manifest

-2.85 MB
Binary file not shown.

install/installer/pkg/config/v1/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ type ContainerRegistry struct {
255255

256256
PrivateBaseImageAllowList []string `json:"privateBaseImageAllowList"`
257257
EnableAdditionalECRAuth bool `json:"enableAdditionalECRAuth"`
258+
259+
SubassemblyBucket string `json:"subassemblyBucket"`
258260
}
259261

260262
type ContainerRegistryExternal struct {

install/installer/pkg/config/versions/versions.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ type Components struct {
2424
IDEProxy Versioned `json:"ideProxy"`
2525
IDEMetrics Versioned `json:"ideMetrics"`
2626
IDEService Versioned `json:"ideService"`
27-
ImageBuilder Versioned `json:"imageBuilder"`
2827
ImageBuilderMk3 struct {
2928
Versioned
3029
BuilderImage Versioned `json:"builderImage"`
@@ -79,6 +78,10 @@ type Components struct {
7978
WSManagerBridge Versioned `json:"wsManagerBridge"`
8079
WSProxy Versioned `json:"wsProxy"`
8180
NodeLabeler Versioned `json:"node-labeler"`
81+
82+
ImageBuilderNG Versioned `json:"imageBuilderNG"`
83+
WSManagerNG Versioned `json:"wsManagerNG"`
84+
WorkspacekitNG Versioned `json:"workspacekitNG"`
8285
}
8386

8487
func Embedded() (*Manifest, error) {

0 commit comments

Comments
 (0)