read config file
This commit is contained in:
parent
7343c3dbe2
commit
4a8fcc7329
@ -25,6 +25,8 @@ package config
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
cliutil "github.com/rancher/k3d/v4/cmd/util" // TODO: move parseapiport to pkg
|
cliutil "github.com/rancher/k3d/v4/cmd/util" // TODO: move parseapiport to pkg
|
||||||
@ -252,11 +254,24 @@ func TransformSimpleToClusterConfig(ctx context.Context, runtime runtimes.Runtim
|
|||||||
log.Tracef("Parsed registry reference: %+v", reg)
|
log.Tracef("Parsed registry reference: %+v", reg)
|
||||||
clusterCreateOpts.Registries.Use = append(clusterCreateOpts.Registries.Use, reg)
|
clusterCreateOpts.Registries.Use = append(clusterCreateOpts.Registries.Use, reg)
|
||||||
}
|
}
|
||||||
var k3sRegistry *k3s.Registry
|
|
||||||
if err := yaml.Unmarshal([]byte(simpleConfig.Registries.Config), k3sRegistry); err != nil {
|
if simpleConfig.Registries.Config != "" {
|
||||||
return nil, fmt.Errorf("Failed to read registry configuration: %+v", err)
|
var k3sRegistry *k3s.Registry
|
||||||
|
registryConfigFile, err := os.Open(simpleConfig.Registries.Config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("Failed to open registry config file at %s: %+v", simpleConfig.Registries.Config, err)
|
||||||
|
}
|
||||||
|
configBytes, err := ioutil.ReadAll(registryConfigFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("Failed to read registry config file at %s: %+v", registryConfigFile.Name(), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := yaml.Unmarshal(configBytes, &k3sRegistry); err != nil {
|
||||||
|
return nil, fmt.Errorf("Failed to read registry configuration: %+v", err)
|
||||||
|
}
|
||||||
|
log.Tracef("Registry: read config from input:\n%+v", k3sRegistry)
|
||||||
|
clusterCreateOpts.Registries.Config = k3sRegistry
|
||||||
}
|
}
|
||||||
log.Tracef("Registry: read config from input:\n%+v", k3sRegistry)
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* Kubeconfig Options *
|
* Kubeconfig Options *
|
||||||
|
Loading…
Reference in New Issue
Block a user