registry: basic merge of existing registry with generated registry config
This commit is contained in:
parent
4a8fcc7329
commit
267e520fce
@ -188,6 +188,8 @@ func ClusterPrep(ctx context.Context, runtime k3drt.Runtime, clusterConfig *conf
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to generate registry config file for k3s: %+v", err)
|
||||
}
|
||||
RegistryMergeConfig(ctx, regConf, clusterConfig.ClusterCreateOpts.Registries.Config)
|
||||
log.Tracef("Merged registry config: %+v", regConf)
|
||||
regConfBytes, err := yaml.Marshal(®Conf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to marshal registry configuration: %+v", err)
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/imdario/mergo"
|
||||
"github.com/rancher/k3d/v4/pkg/runtimes"
|
||||
k3d "github.com/rancher/k3d/v4/pkg/types"
|
||||
"github.com/rancher/k3d/v4/pkg/types/k3s"
|
||||
@ -305,3 +306,11 @@ func RegistryGenerateLocalRegistryHostingConfigMapYAML(ctx context.Context, regi
|
||||
|
||||
return cmYaml, nil
|
||||
}
|
||||
|
||||
// RegistryMergeConfig merges a source registry config into an existing dest registry cofnig
|
||||
func RegistryMergeConfig(ctx context.Context, dest, src *k3s.Registry) error {
|
||||
if err := mergo.MergeWithOverwrite(dest, src); err != nil {
|
||||
return fmt.Errorf("Failed to merge registry configs: %+v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
4
tests/assets/test_registries.yaml
Normal file
4
tests/assets/test_registries.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
mirrors:
|
||||
"my.company.registry":
|
||||
endpoint:
|
||||
- http://my.company.registry:5000
|
Loading…
Reference in New Issue
Block a user