1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-09 10:48:10 +00:00

move metadata init to InitClusterObject

This commit is contained in:
kinarashah 2019-07-08 15:21:03 -07:00 committed by Alena Prokharchyk
parent dc6f397f78
commit f360207416
3 changed files with 6 additions and 9 deletions

View File

@ -3,6 +3,7 @@ package cluster
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/rancher/rke/metadata"
"net" "net"
"reflect" "reflect"
"strings" "strings"
@ -160,6 +161,9 @@ func InitClusterObject(ctx context.Context, rkeConfig *v3.RancherKubernetesEngin
StateFilePath: GetStateFilePath(flags.ClusterFilePath, flags.ConfigDir), StateFilePath: GetStateFilePath(flags.ClusterFilePath, flags.ConfigDir),
PrivateRegistriesMap: make(map[string]v3.PrivateRegistry), PrivateRegistriesMap: make(map[string]v3.PrivateRegistry),
} }
if metadata.K8sVersionToRKESystemImages == nil {
metadata.InitMetadata(ctx)
}
if len(c.ConfigPath) == 0 { if len(c.ConfigPath) == 0 {
c.ConfigPath = pki.ClusterConfig c.ConfigPath = pki.ClusterConfig
} }

View File

@ -3,7 +3,6 @@ package cmd
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/rancher/rke/metadata"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -14,7 +13,7 @@ import (
"github.com/rancher/rke/log" "github.com/rancher/rke/log"
"github.com/rancher/rke/pki" "github.com/rancher/rke/pki"
"github.com/rancher/rke/util" "github.com/rancher/rke/util"
v3 "github.com/rancher/types/apis/management.cattle.io/v3" "github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/urfave/cli" "github.com/urfave/cli"
) )
@ -75,9 +74,7 @@ func ClusterInit(ctx context.Context, rkeConfig *v3.RancherKubernetesEngineConfi
if len(flags.CertificateDir) == 0 { if len(flags.CertificateDir) == 0 {
flags.CertificateDir = cluster.GetCertificateDirPath(flags.ClusterFilePath, flags.ConfigDir) flags.CertificateDir = cluster.GetCertificateDirPath(flags.ClusterFilePath, flags.ConfigDir)
} }
if metadata.K8sVersionToRKESystemImages == nil {
metadata.InitMetadata(ctx)
}
rkeFullState, _ := cluster.ReadStateFile(ctx, stateFilePath) rkeFullState, _ := cluster.ReadStateFile(ctx, stateFilePath)
kubeCluster, err := cluster.InitClusterObject(ctx, rkeConfig, flags) kubeCluster, err := cluster.InitClusterObject(ctx, rkeConfig, flags)

View File

@ -4,7 +4,6 @@ import (
"bufio" "bufio"
"context" "context"
"fmt" "fmt"
"github.com/rancher/rke/metadata"
"os" "os"
"strings" "strings"
@ -58,9 +57,6 @@ func ClusterRemove(
log.Infof(ctx, "Tearing down Kubernetes cluster") log.Infof(ctx, "Tearing down Kubernetes cluster")
if metadata.K8sVersionToRKESystemImages == nil {
metadata.InitMetadata(ctx)
}
kubeCluster, err := cluster.InitClusterObject(ctx, rkeConfig, flags) kubeCluster, err := cluster.InitClusterObject(ctx, rkeConfig, flags)
if err != nil { if err != nil {
return err return err