mirror of
https://github.com/hauler-dev/hauler.git
synced 2026-08-27 14:07:17 +00:00
allow file content to be passed a custom config
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user