Skip to content
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

Functional Options for CreateContainer #28

Closed
tri-adam opened this issue Jun 21, 2021 · 0 comments · Fixed by #31
Closed

Functional Options for CreateContainer #28

tri-adam opened this issue Jun 21, 2021 · 0 comments · Fixed by #31
Labels
v2 Affects v2 API

Comments

@tri-adam
Copy link
Member

sif.CreateContainer currently accepts a sif.CreateInfo:

sif/pkg/sif/sif.go

Lines 403 to 410 in 3a39a27

// CreateInfo wraps all SIF file creation info needed.
type CreateInfo struct {
Pathname string // the end result output filename
Launchstr string // the shell run command
Sifversion string // the SIF specification version used
ID uuid.UUID // image unique identifier
InputDescr []DescriptorInput // slice of input info for descriptor creation
}

With this pattern, users must understand the internals of SIF to effectively call CreateContainer. It would be better if these were defaulted, with potential overrides supplied via the functional options pattern. For example:

  • Launchstr: default to sif.HdrLaunch
  • Sifversion: default to sif.HdrVersion
  • ID: default to a generated ID (perhaps the public API can avoid a UUID package at all, to prevent issues such as Replace Deprecated UUID Package #7).
  • InputDescr: default to empty list, allow DescriptorInput via functional option.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 Affects v2 API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant