Skip to content

Commit

Permalink
Extend Blueprints to permit baseImageURI to be optionally overridden …
Browse files Browse the repository at this point in the history
…for each Homeserver (#436)

* Refactor method to permit baseImageURI to be passed in for each Homeserver.

* Propigate error when images are unable to be constructed.

This provides better messages when using homerunner API to generate new
blueprints, otherwise the API only reports that no images exist.
  • Loading branch information
michaelkaye authored Aug 11, 2022
1 parent 01bde96 commit aed418c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions internal/b/blueprints.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ type Homeserver struct {
Rooms []Room
// The list of application services to create on the homeserver
ApplicationServices []ApplicationService
// Optionally override the baseImageURI for blueprint creation
BaseImageURI *string
}

type User struct {
Expand Down
13 changes: 11 additions & 2 deletions internal/docker/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ func (d *Builder) ConstructBlueprintIfNotExist(bprint b.Blueprint) error {
return fmt.Errorf("ConstructBlueprintIfNotExist(%s): failed to ImageList: %w", bprint.Name, err)
}
if len(images) == 0 {
d.ConstructBlueprint(bprint)
err = d.ConstructBlueprint(bprint)
if err != nil {
return fmt.Errorf("ConstructBlueprintIfNotExist(%s): failed to ConstructBlueprint: %w", bprint.Name, err)
}
}
return nil
}
Expand Down Expand Up @@ -380,9 +383,15 @@ func (d *Builder) constructHomeserver(blueprintName string, runner *instruction.
// deployBaseImage runs the base image and returns the baseURL, containerID or an error.
func (d *Builder) deployBaseImage(blueprintName string, hs b.Homeserver, contextStr, networkID string) (*HomeserverDeployment, error) {
asIDToRegistrationMap := asIDToRegistrationFromLabels(labelsForApplicationServices(hs))
var baseImageURI string
if hs.BaseImageURI == nil {
baseImageURI = d.Config.BaseImageURI
} else {
baseImageURI = *hs.BaseImageURI
}

return deployImage(
d.Docker, d.Config.BaseImageURI, fmt.Sprintf("complement_%s", contextStr),
d.Docker, baseImageURI, fmt.Sprintf("complement_%s", contextStr),
d.Config.PackageNamespace, blueprintName, hs.Name, asIDToRegistrationMap, contextStr,
networkID, d.Config,
)
Expand Down

0 comments on commit aed418c

Please sign in to comment.