Skip to content

Make installer a bit more extensible #18937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 58 additions & 30 deletions dev/version-manifest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"io"
"io/fs"
"log"
"os"
"path/filepath"
"sort"
Expand All @@ -22,7 +23,10 @@ type MD struct {
}

func main() {
produceManifest(os.Stdout, os.DirFS("."))
err := produceManifest(os.Stdout, os.DirFS("."))
if err != nil {
log.Fatal(err)
}
}

func produceManifest(out io.Writer, dir fs.FS) error {
Expand Down Expand Up @@ -82,38 +86,62 @@ func produceManifest(out io.Writer, dir fs.FS) error {
}
}

// It's not clear how to maintain a stable order of keys using the YAML serializer.
// If it were, we could just through this map at the YAML serializer and call it a day.
// Right now, we have to produce the YAML ourselves.
var print func(m map[string]interface{}, indent int) error
print = func(m map[string]interface{}, indent int) error {
keys := make([]string, 0, len(m))
for v := range m {
keys = append(keys, v)
vers, err := fs.Glob(dir, "**/versions.yaml")
if err != nil {
return err
}
for _, md := range vers {
b, err := fs.ReadFile(dir, md)
if err != nil {
return err
}
var versions struct {
Commit string `yaml:"commit"`
Version string `yaml:"version"`
Components map[string]interface{} `yaml:"components"`
}
err = yaml.Unmarshal(b, &versions)
if err != nil {
return xerrors.Errorf("cannot unmarshal %s: %w", md, err)
}
sort.Strings(keys)

for _, k := range keys {
v := m[k]
fmt.Fprintf(out, "%s%s:", strings.Repeat(" ", indent), k)
if c, ok := v.(map[string]interface{}); ok {
fmt.Fprintln(out)
err := print(c, indent+1)
if err != nil {
return err
}
continue
}
if c, ok := v.(string); ok {
fmt.Fprintf(out, " %s\n", c)
fmt.Fprintln(out)
continue
}

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

return print(res, 0)
return print(out, res, 0)
}

// print serializes the given map to YAML.
// It's not clear how to maintain a stable order of keys using the YAML serializer.
// If it were, we could just through this map at the YAML serializer and call it a day.
// Right now, we have to produce the YAML ourselves.
func print(out io.Writer, m map[string]interface{}, indent int) error {
keys := make([]string, 0, len(m))
for v := range m {
keys = append(keys, v)
}
sort.Strings(keys)

for _, k := range keys {
v := m[k]
fmt.Fprintf(out, "%s%s:", strings.Repeat(" ", indent), k)
if c, ok := v.(map[string]interface{}); ok {
fmt.Fprintln(out)
err := print(out, c, indent+1)
if err != nil {
return err
}
continue
}
if c, ok := v.(string); ok {
fmt.Fprintf(out, " %s\n", c)
fmt.Fprintln(out)
continue
}

return xerrors.Errorf("unknown value type - this should never happen")
}
return nil
}
Binary file removed dev/version-manifest/version-manifest
Binary file not shown.
2 changes: 2 additions & 0 deletions install/installer/pkg/config/v1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ type ContainerRegistry struct {

PrivateBaseImageAllowList []string `json:"privateBaseImageAllowList"`
EnableAdditionalECRAuth bool `json:"enableAdditionalECRAuth"`

SubassemblyBucket string `json:"subassemblyBucket"`
}

type ContainerRegistryExternal struct {
Expand Down
5 changes: 4 additions & 1 deletion install/installer/pkg/config/versions/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type Components struct {
IDEProxy Versioned `json:"ideProxy"`
IDEMetrics Versioned `json:"ideMetrics"`
IDEService Versioned `json:"ideService"`
ImageBuilder Versioned `json:"imageBuilder"`
ImageBuilderMk3 struct {
Versioned
BuilderImage Versioned `json:"builderImage"`
Expand Down Expand Up @@ -79,6 +78,10 @@ type Components struct {
WSManagerBridge Versioned `json:"wsManagerBridge"`
WSProxy Versioned `json:"wsProxy"`
NodeLabeler Versioned `json:"node-labeler"`

ImageBuilderNG Versioned `json:"imageBuilderNG"`
WSManagerNG Versioned `json:"wsManagerNG"`
WorkspacekitNG Versioned `json:"workspacekitNG"`
}

func Embedded() (*Manifest, error) {
Expand Down