MCPcopy
hub / github.com/cortexlabs/cortex / getClusterAccessConfigWithCache

Function getClusterAccessConfigWithCache

cli/cmd/lib_cluster_config.go:92–123  ·  view source on GitHub ↗
(hasClusterFlags bool)

Source from the content-addressed store, hash-verified

90}
91
92func getClusterAccessConfigWithCache(hasClusterFlags bool) (*clusterconfig.AccessConfig, error) {
93 accessConfig := &clusterconfig.AccessConfig{
94 ImageManager: consts.DefaultRegistry() + "/manager:" + consts.CortexVersion,
95 }
96
97 cachedPaths := existingCachedClusterConfigPaths()
98 if len(cachedPaths) == 1 {
99 cachedAccessConfig := &clusterconfig.AccessConfig{}
100 cr.ParseYAMLFile(cachedAccessConfig, clusterconfig.AccessValidation, cachedPaths[0])
101 accessConfig.ClusterName = cachedAccessConfig.ClusterName
102 accessConfig.Region = cachedAccessConfig.Region
103 }
104
105 if _flagClusterConfig != "" {
106 errs := cr.ParseYAMLFile(accessConfig, clusterconfig.AccessValidation, _flagClusterConfig)
107 if errors.HasError(errs) {
108 return nil, errors.Append(errors.FirstError(errs...), fmt.Sprintf("\n\ncluster configuration schema can be found at https://docs.cortex.dev/v/%s/", consts.CortexVersionMinor))
109 }
110 }
111
112 if _flagClusterName != "" {
113 accessConfig.ClusterName = _flagClusterName
114 }
115 if _flagClusterRegion != "" {
116 accessConfig.Region = _flagClusterRegion
117 }
118
119 if accessConfig.ClusterName == "" || accessConfig.Region == "" {
120 return nil, ErrorClusterAccessConfigRequired(hasClusterFlags)
121 }
122 return accessConfig, nil
123}
124
125func getInstallClusterConfig(awsClient *aws.Client, clusterConfigFile string) (*clusterconfig.Config, error) {
126 clusterConfig := &clusterconfig.Config{}

Callers 1

cluster.goFile · 0.85

Calls 6

DefaultRegistryFunction · 0.92
HasErrorFunction · 0.92
AppendFunction · 0.92
FirstErrorFunction · 0.92

Tested by

no test coverage detected