Skip to content

Commit

Permalink
ToVariables conversion func
Browse files Browse the repository at this point in the history
Signed-off-by: dtfranz <[email protected]>
  • Loading branch information
dtfranz committed Sep 12, 2023
1 parent d555222 commit 430dfe4
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions internal/catalogmetadata/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (

bsemver "github.com/blang/semver/v4"

"github.com/operator-framework/deppy/pkg/deppy"
"github.com/operator-framework/deppy/pkg/deppy/input"
"github.com/operator-framework/operator-controller/internal/resolution/entities"

Check failure on line 12 in internal/catalogmetadata/types.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed with -local github.com/operator-framework/operator-controller (goimports)
"github.com/operator-framework/operator-controller/internal/resolution/variables"
"github.com/operator-framework/operator-registry/alpha/declcfg"
"github.com/operator-framework/operator-registry/alpha/property"
)
Expand Down Expand Up @@ -74,6 +78,30 @@ func (b *Bundle) RequiredGVKs() ([]GVKRequired, error) {
return b.requiredGVKs, nil
}

func (b *Bundle) ToVariables() []variables.BundleVariable {
var bundleVars []variables.BundleVariable

Check failure on line 82 in internal/catalogmetadata/types.go

View workflow job for this annotation

GitHub Actions / lint

Consider pre-allocating `bundleVars` (prealloc)
var propertiesMap map[string]string

for propKey, propVal := range b.propertiesMap {
// TODO probably shouldn't do this every time
propertiesMap[propKey] = propVal.String()

Check failure on line 87 in internal/catalogmetadata/types.go

View workflow job for this annotation

GitHub Actions / lint

SA5000: assignment to nil map (staticcheck)
}

for _, channel := range b.InChannels {
catalogScopedEntryName := fmt.Sprintf("%s-%s", channel.Name, b.Name)
// TODO this can be cleaned up significantly when we don't an entity to create the variable
bundleVars = append(bundleVars, *variables.NewBundleVariable(entities.NewBundleEntity(
&input.Entity{
ID: deppy.IdentifierFromString(fmt.Sprintf("%s%s%s", catalogScopedEntryName, b.Package, b.CatalogName)),
Properties: propertiesMap,
}),
// TODO dependencies?
make([]*entities.BundleEntity, 0)))
}

return bundleVars
}

func (b *Bundle) loadPackage() error {
b.mu.Lock()
defer b.mu.Unlock()
Expand Down

0 comments on commit 430dfe4

Please sign in to comment.