Skip to content

Commit

Permalink
Merge pull request #491 from zhouhaoA1/feature_components_deploy
Browse files Browse the repository at this point in the history
fix component yaml unmarshal bug
  • Loading branch information
kosmos-robot committed Apr 25, 2024
2 parents 251d1f5 + 1f59424 commit daf78ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
1 change: 0 additions & 1 deletion pkg/kubenest/controller/virtualcluster_init_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ func (c *VirtualClusterInitController) createVirtualCluster(virtualCluster *v1al
return err
}
virtualCluster.Spec.Kubeconfig = base64.StdEncoding.EncodeToString(secret.Data[constants.KubeConfig])
virtualCluster.Status.Phase = v1alpha1.Completed
return nil
}

Expand Down
16 changes: 5 additions & 11 deletions pkg/kubenest/tasks/manifests_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ func applyTemplatedManifests(dynamicClient dynamic.Interface, manifestGlob strin
if err != nil {
return errors.Wrapf(err, "Read file %s error", manifest)
}
err = yaml.Unmarshal(bytesData, &obj)
templateData, err := util.ParseTemplate(string(bytesData), templateMapping)
if err != nil {
panic(err)
}
err = yaml.Unmarshal(templateData, &obj)
if err != nil {
return errors.Wrapf(err, "Unmarshal manifest bytes data error")
}
Expand All @@ -151,17 +155,7 @@ func applyTemplatedManifests(dynamicClient dynamic.Interface, manifestGlob strin
return errors.Wrapf(err, "Convert configmap %s to unstructured obj error", obj.GetName())
}
obj = unstructured.Unstructured{Object: res}
} else {
templatedBytes, err := util.ParseTemplate(string(bytesData), templateMapping)
if err != nil {
return errors.Wrapf(err, "Parse template data %s", string(bytesData))
}
err = yaml.Unmarshal(templatedBytes, &obj)
if err != nil {
return errors.Wrapf(err, "Unmarshal templatedBytes error")
}
}

err = createObject(dynamicClient, obj.GetNamespace(), obj.GetName(), &obj)
if err != nil {
return errors.Wrapf(err, "Create object error")
Expand Down

0 comments on commit daf78ac

Please sign in to comment.