Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh committed Jul 25, 2024
1 parent 11b9651 commit 084e4a3
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 59 deletions.
2 changes: 1 addition & 1 deletion pkg/addons/adminconsole/adminconsole.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (a *AdminConsole) GenerateHelmConfig(onlyDefaults bool) ([]eckinds.Chart, [
func (a *AdminConsole) GetImages() []string {
var images []string
for image, tag := range Metadata.Images {
images = append(images, fmt.Sprintf("%s:%s", image, tag))
images = append(images, fmt.Sprintf("proxy.replicated.com/anonymous/%s:%s", image, tag))
}
return images
}
Expand Down
115 changes: 62 additions & 53 deletions pkg/addons/applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,85 +158,63 @@ func (a *Applier) GenerateHelmConfigsForRestore() ([]embeddedclusterv1beta1.Char
func (a *Applier) GetBuiltinCharts() (map[string]embeddedclusterv1beta1.Helm, error) {
builtinCharts := map[string]embeddedclusterv1beta1.Helm{}

vel, err := velero.New(defaults.VeleroNamespace, true, a.proxyEnv)
if err != nil {
return nil, fmt.Errorf("unable to create velero addon: %w", err)
}
velChart, velRepo, err := vel.GenerateHelmConfig(true)
if err != nil {
return nil, fmt.Errorf("unable to generate helm config for velero: %w", err)
}
builtinCharts["velero"] = embeddedclusterv1beta1.Helm{
Repositories: velRepo,
Charts: velChart,
}

reg, err := registry.New(defaults.RegistryNamespace, a.config, true, false, a.network)
if err != nil {
return nil, fmt.Errorf("unable to create registry addon: %w", err)
}
regChart, regRepo, err := reg.GenerateHelmConfig(true)
addons, err := a.loadBuiltIn()
if err != nil {
return nil, fmt.Errorf("unable to generate helm config for registry: %w", err)
}
builtinCharts["registry"] = embeddedclusterv1beta1.Helm{
Repositories: regRepo,
Charts: regChart,
}

regHA, err := registry.New(defaults.RegistryNamespace, a.config, true, true, a.network)
if err != nil {
return nil, fmt.Errorf("unable to create registry addon: %w", err)
}
regHAChart, regHARepo, err := regHA.GenerateHelmConfig(true)
if err != nil {
return nil, fmt.Errorf("unable to generate helm config for registry: %w", err)
}
builtinCharts["registry-ha"] = embeddedclusterv1beta1.Helm{
Repositories: regHARepo,
Charts: regHAChart,
return nil, fmt.Errorf("unable to load addons: %w", err)
}

seaweed, err := seaweedfs.New(defaults.SeaweedFSNamespace, a.config, true)
if err != nil {
return nil, fmt.Errorf("unable to create seaweedfs addon: %w", err)
}
seaweedChart, seaweedRepo, err := seaweed.GenerateHelmConfig(true)
if err != nil {
return nil, fmt.Errorf("unable to generate helm config for seaweedfs: %w", err)
}
builtinCharts["seaweedfs"] = embeddedclusterv1beta1.Helm{
Repositories: seaweedRepo,
Charts: seaweedChart,
for name, addon := range addons {
chart, repo, err := addon.GenerateHelmConfig(true)
if err != nil {
return nil, fmt.Errorf("unable to generate helm config for %s: %w", name, err)
}
builtinCharts[name] = embeddedclusterv1beta1.Helm{
Repositories: repo,
Charts: chart,
}
}

return builtinCharts, nil
}

func (a *Applier) GetImages() ([]string, error) {
additionalImages := []string{}
images := []string{}
addons, err := a.load()
if err != nil {
return nil, fmt.Errorf("unable to load addons: %w", err)
}
builtInAddons, err := a.loadBuiltIn()
if err != nil {
return nil, fmt.Errorf("unable to load built-in addons: %w", err)
}
for _, addon := range addons {
additionalImages = append(additionalImages, addon.GetImages()...)
images = append(images, addon.GetImages()...)
}
for _, addon := range builtInAddons {
images = append(images, addon.GetImages()...)
}

return additionalImages, nil
return images, nil
}

func (a *Applier) GetAdditionalImages() ([]string, error) {
additionalImages := []string{}
images := []string{}
addons, err := a.load()
if err != nil {
return nil, fmt.Errorf("unable to load addons: %w", err)
}
builtInAddons, err := a.loadBuiltIn()
if err != nil {
return nil, fmt.Errorf("unable to load built-in addons: %w", err)
}
for _, addon := range addons {
additionalImages = append(additionalImages, addon.GetAdditionalImages()...)
images = append(images, addon.GetAdditionalImages()...)
}
for _, addon := range builtInAddons {
images = append(images, addon.GetAdditionalImages()...)
}

return additionalImages, nil
return images, nil
}

// ProtectedFields returns the protected fields for all the embedded charts.
Expand Down Expand Up @@ -328,6 +306,37 @@ func (a *Applier) load() ([]AddOn, error) {
return addons, nil
}

// load instantiates and returns all addon appliers.
func (a *Applier) loadBuiltIn() (map[string]AddOn, error) {
addons := map[string]AddOn{}

vel, err := velero.New(defaults.VeleroNamespace, true, a.proxyEnv)
if err != nil {
return nil, fmt.Errorf("unable to create velero addon: %w", err)
}
addons["velero"] = vel

reg, err := registry.New(defaults.RegistryNamespace, a.config, true, false, a.network)
if err != nil {
return nil, fmt.Errorf("unable to create registry addon: %w", err)
}
addons["registry"] = reg

regHA, err := registry.New(defaults.RegistryNamespace, a.config, true, true, a.network)
if err != nil {
return nil, fmt.Errorf("unable to create registry addon: %w", err)
}
addons["registry-ha"] = regHA

seaweed, err := seaweedfs.New(defaults.SeaweedFSNamespace, a.config, true)
if err != nil {
return nil, fmt.Errorf("unable to create seaweedfs addon: %w", err)
}
addons["seaweedfs"] = seaweed

return addons, nil
}

// loadForRestore instantiates and returns addon appliers for restore operations.
func (a *Applier) loadForRestore() ([]AddOn, error) {
addons := []AddOn{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (e *EmbeddedClusterOperator) GenerateHelmConfig(onlyDefaults bool) ([]embed
func (a *EmbeddedClusterOperator) GetImages() []string {
var images []string
for image, tag := range Metadata.Images {
images = append(images, fmt.Sprintf("%s:%s", image, tag))
images = append(images, fmt.Sprintf("proxy.replicated.com/anonymous/%s:%s", image, tag))
}
return images
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/addons/openebs/openebs.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (o *OpenEBS) GenerateHelmConfig(onlyDefaults bool) ([]eckinds.Chart, []ecki
func (a *OpenEBS) GetImages() []string {
var images []string
for image, tag := range Metadata.Images {
images = append(images, fmt.Sprintf("%s:%s", image, tag))
images = append(images, fmt.Sprintf("proxy.replicated.com/anonymous/%s:%s", image, tag))
}
return images
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/addons/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (o *Registry) GenerateHelmConfig(onlyDefaults bool) ([]eckinds.Chart, []eck
func (a *Registry) GetImages() []string {
var images []string
for image, tag := range Metadata.Images {
images = append(images, fmt.Sprintf("%s:%s", image, tag))
images = append(images, fmt.Sprintf("proxy.replicated.com/anonymous/%s:%s", image, tag))
}
return images
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/addons/seaweedfs/seaweedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (o *SeaweedFS) GenerateHelmConfig(onlyDefaults bool) ([]eckinds.Chart, []ec
func (a *SeaweedFS) GetImages() []string {
var images []string
for image, tag := range Metadata.Images {
images = append(images, fmt.Sprintf("%s:%s", image, tag))
images = append(images, fmt.Sprintf("proxy.replicated.com/anonymous/%s:%s", image, tag))
}
return images
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/addons/velero/velero.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (o *Velero) GenerateHelmConfig(onlyDefaults bool) ([]eckinds.Chart, []eckin
func (a *Velero) GetImages() []string {
var images []string
for image, tag := range Metadata.Images {
images = append(images, fmt.Sprintf("%s:%s", image, tag))
images = append(images, fmt.Sprintf("proxy.replicated.com/anonymous/%s:%s", image, tag))
}
return images
}
Expand Down

0 comments on commit 084e4a3

Please sign in to comment.