-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add thick chart builtin collection (chart with required images)
- Loading branch information
Showing
10 changed files
with
172 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package chart | ||
|
||
import ( | ||
gname "github.com/google/go-containerregistry/pkg/name" | ||
|
||
"github.com/rancherfederal/hauler/pkg/artifact" | ||
"github.com/rancherfederal/hauler/pkg/content/chart" | ||
"github.com/rancherfederal/hauler/pkg/content/image" | ||
) | ||
|
||
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 | ||
|
||
computed bool | ||
contents map[gname.Reference]artifact.OCI | ||
} | ||
|
||
func NewChart(name, repo, version string) (artifact.Collection, error) { | ||
o, err := chart.NewChart(name, repo, version) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &tchart{ | ||
chart: o, | ||
contents: make(map[gname.Reference]artifact.OCI), | ||
}, nil | ||
} | ||
|
||
func (c *tchart) Contents() (map[gname.Reference]artifact.OCI, error) { | ||
if err := c.compute(); err != nil { | ||
return nil, err | ||
} | ||
return c.contents, nil | ||
} | ||
|
||
func (c *tchart) compute() error { | ||
if c.computed { | ||
return nil | ||
} | ||
|
||
if err := c.dependentImages(); err != nil { | ||
return err | ||
} | ||
|
||
c.computed = true | ||
return nil | ||
} | ||
|
||
func (c *tchart) dependentImages() error { | ||
ch, err := c.chart.Load() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
imgs, err := ImagesInChart(ch) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, img := range imgs.Spec.Images { | ||
ref, err := gname.ParseReference(img.Ref) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
i, err := image.NewImage(img.Ref) | ||
if err != nil { | ||
return err | ||
} | ||
c.contents[ref] = i | ||
} | ||
|
||
return nil | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
apiVersion: collection.hauler.cattle.io/v1alpha1 | ||
kind: ThickCharts | ||
metadata: | ||
name: mythickchart | ||
spec: | ||
charts: | ||
# charts are also fetched and served as OCI content (currently experimental in helm) | ||
# HELM_EXPERIMENTAL_OCI=1 helm chart pull <hauler-registry>/loki:2.6.2 | ||
- name: loki | ||
repoURL: https://grafana.github.io/helm-charts |