Merge pull request #69 from rancherfederal/68

fix bug packaging thick charts
This commit is contained in:
Josh Wolf
2021-11-12 14:51:01 -07:00
committed by GitHub
2 changed files with 33 additions and 3 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ import (
"k8s.io/apimachinery/pkg/util/yaml"
"github.com/rancherfederal/hauler/pkg/apis/hauler.cattle.io/v1alpha1"
"github.com/rancherfederal/hauler/pkg/collection/chart"
tchart "github.com/rancherfederal/hauler/pkg/collection/chart"
"github.com/rancherfederal/hauler/pkg/collection/k3s"
"github.com/rancherfederal/hauler/pkg/content"
"github.com/rancherfederal/hauler/pkg/log"
@@ -134,7 +134,7 @@ func SyncCmd(ctx context.Context, o *SyncOpts, s *store.Store) error {
}
for _, cfg := range cfg.Spec.Charts {
tc, err := chart.NewChart(cfg.Name, cfg.RepoURL, cfg.Version)
tc, err := tchart.NewChart(cfg.Name, cfg.RepoURL, cfg.Version)
if err != nil {
return err
}
+31 -1
View File
@@ -12,7 +12,10 @@ var _ artifact.Collection = (*tchart)(nil)
// tchart is a thick chart that includes all the dependent images as well as the chart itself
type tchart struct {
chart *chart.Chart
name string
repo string
version string
chart *chart.Chart
computed bool
contents map[gname.Reference]artifact.OCI
@@ -25,6 +28,9 @@ func NewChart(name, repo, version string) (artifact.Collection, error) {
}
return &tchart{
name: name,
repo: repo,
version: version,
chart: o,
contents: make(map[gname.Reference]artifact.OCI),
}, nil
@@ -46,10 +52,34 @@ func (c *tchart) compute() error {
return err
}
if err := c.chartContents(); err != nil {
return err
}
c.computed = true
return nil
}
func (c *tchart) chartContents() error {
oci, err := chart.NewChart(c.name, c.repo, c.version)
if err != nil {
return err
}
tag := c.version
if tag == "" {
tag = gname.DefaultTag
}
ref, err := gname.ParseReference(c.name, gname.WithDefaultRegistry(""), gname.WithDefaultTag(tag))
if err != nil {
return err
}
c.contents[ref] = oci
return nil
}
func (c *tchart) dependentImages() error {
ch, err := c.chart.Load()
if err != nil {