Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Read config variable from management cluster and set it into cleanup …
Browse files Browse the repository at this point in the history
…cluster
  • Loading branch information
DingPing Yuan committed Sep 22, 2022
1 parent 43a5968 commit ac80da0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions tkg/client/delete_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ func (c *TkgClient) DeleteRegion(options DeleteRegionOptions) error { //nolint:f

// If clusterclass feature flag is enabled then deploy management components
if config.IsFeatureActivated(config.FeatureFlagPackageBasedLCM) {
// Read config variable from management cluster and set it into cleanup cluster
configValues, err := c.getUserConfigVariableValueMapFromSecret(regionContext.SourceFilePath, regionContext.ContextName)
if err != nil {
return errors.Wrap(err, "unable to get config variables from management cluster")
}
for k, v := range configValues {
// Handle bool, int and string
c.TKGConfigReaderWriter().Set(k, fmt.Sprint(v))
}
if err = c.InstallOrUpgradeManagementComponents(cleanupClusterKubeconfigPath, "", false); err != nil {
return errors.Wrap(err, "unable to install management components to bootstrap cluster")
}
Expand Down
4 changes: 2 additions & 2 deletions tkg/client/management_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (c *TkgClient) getTKGPackageConfigValuesFile(managementPackageVersion, kube
var err error

if upgrade {
userProviderConfigValues, err = c.getUserConfigVariableValueMapForUpgrade(kubeconfig, kubecontext)
userProviderConfigValues, err = c.getUserConfigVariableValueMapFromSecret(kubeconfig, kubecontext)
} else {
userProviderConfigValues, err = c.getUserConfigVariableValueMap()
}
Expand Down Expand Up @@ -137,7 +137,7 @@ func (c *TkgClient) getUserConfigVariableValueMap() (map[string]interface{}, err
return c.GetUserConfigVariableValueMap(path, c.TKGConfigReaderWriter())
}

func (c *TkgClient) getUserConfigVariableValueMapForUpgrade(kubeconfig, kubecontext string) (map[string]interface{}, error) {
func (c *TkgClient) getUserConfigVariableValueMapFromSecret(kubeconfig, kubecontext string) (map[string]interface{}, error) {
clusterClient, err := clusterclient.NewClient(kubeconfig, kubecontext, clusterclient.Options{})
if err != nil {
return nil, errors.Wrap(err, "unable to get cluster client")
Expand Down

0 comments on commit ac80da0

Please sign in to comment.