mirror of
https://github.com/hauler-dev/hauler.git
synced 2026-02-14 18:09:51 +00:00
refactor to baseline on pluggable oci collection/distribution Co-authored-by: Josh Wolf <josh@joshwolf.dev>
48 lines
747 B
Go
48 lines
747 B
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/rancherfederal/hauler/pkg/content"
|
|
"github.com/rancherfederal/hauler/pkg/log"
|
|
)
|
|
|
|
type addOptions struct {
|
|
repo string
|
|
}
|
|
|
|
type AddOption func(*addOptions)
|
|
|
|
func makeAddOptions(opts ...AddOption) addOptions {
|
|
opt := addOptions{}
|
|
for _, o := range opts {
|
|
o(&opt)
|
|
}
|
|
return opt
|
|
}
|
|
|
|
func (s *Store) Add(ctx context.Context, oci content.Oci, opts ...AddOption) error {
|
|
l := log.FromContext(ctx)
|
|
opt := makeAddOptions(opts...)
|
|
|
|
if err := s.precheck(); err != nil {
|
|
return err
|
|
}
|
|
|
|
if opt.repo == "" {
|
|
}
|
|
|
|
if err := oci.Copy(ctx, s.registryURL()); err != nil {
|
|
return err
|
|
}
|
|
|
|
_ = l
|
|
return nil
|
|
}
|
|
|
|
func OverrideRepo(r string) AddOption {
|
|
return func(opts *addOptions) {
|
|
opts.repo = r
|
|
}
|
|
}
|