allow file content to be passed a custom config

This commit is contained in:
Josh Wolf
2021-12-08 09:25:45 -07:00
parent 49f7b5ea0e
commit bb83d5ce5b
2 changed files with 21 additions and 2 deletions
+5 -1
View File
@@ -87,7 +87,11 @@ func (f *file) compute() error {
return err
}
cfg := f.client.Config(f.ref)
cfg := f.config
if cfg == nil {
cfg = f.client.Config(f.ref)
}
cfgDesc, err := partial.Descriptor(cfg)
if err != nil {
return err
+16 -1
View File
@@ -1,6 +1,9 @@
package file
import "github.com/rancherfederal/hauler/internal/getter"
import (
"github.com/rancherfederal/hauler/internal/getter"
"github.com/rancherfederal/hauler/pkg/artifact"
)
type Option func(*file)
@@ -9,3 +12,15 @@ func WithClient(c *getter.Client) Option {
f.client = c
}
}
func WithConfig(obj interface{}, mediaType string) Option {
return func(f *file) {
f.config = artifact.ToConfig(obj, artifact.WithConfigMediaType(mediaType))
}
}
func WithAnnotations(m map[string]string) Option {
return func(f *file) {
f.annotations = m
}
}