Skip to content

Commit

Permalink
Merge pull request #19 from tobernguyen/master
Browse files Browse the repository at this point in the history
feat: support updating PersistentVolumeClaim
  • Loading branch information
moshloop authored Mar 2, 2021
2 parents 49bb50b + 4567df3 commit aa0f38d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ func (c *Client) ApplyUnstructured(namespace string, objects ...*unstructured.Un
spec["clusterIP"] = existing.Object["spec"].(map[string]interface{})["clusterIP"]
} else if unstructuredObj.GetKind() == "ServiceAccount" {
unstructuredObj.Object["secrets"] = existing.Object["secrets"]
} else if unstructuredObj.GetKind() == "PersistentVolumeClaim" {
resourcesRequests, found, err := unstructured.NestedFieldCopy(unstructuredObj.Object, "spec", "resources", "requests")
if err != nil {
c.Errorf("Failed to get spec.resources.requests of %s/%s/%s", client.Resource, unstructuredObj.GetNamespace(), unstructuredObj.GetName())
}
unstructuredObj.Object["spec"] = existing.Object["spec"]
if found {
unstructured.SetNestedField(unstructuredObj.Object, resourcesRequests, "spec", "resources", "requests")
}
}
for _, immutable := range c.ImmutableAnnotations {
if existing, ok := existing.GetAnnotations()[immutable]; ok {
Expand Down Expand Up @@ -158,6 +167,15 @@ func (c *Client) Apply(namespace string, objects ...runtime.Object) error {
spec["clusterIP"] = existing.Object["spec"].(map[string]interface{})["clusterIP"]
} else if unstructuredObj.GetKind() == "ServiceAccount" {
unstructuredObj.Object["secrets"] = existing.Object["secrets"]
} else if unstructuredObj.GetKind() == "PersistentVolumeClaim" {
resourcesRequests, found, err := unstructured.NestedFieldCopy(unstructuredObj.Object, "spec", "resources", "requests")
if err != nil {
c.Errorf("Failed to get spec.resources.requests of %s/%s/%s", resource.Resource, unstructuredObj.GetNamespace(), unstructuredObj.GetName())
}
unstructuredObj.Object["spec"] = existing.Object["spec"]
if found {
unstructured.SetNestedField(unstructuredObj.Object, resourcesRequests, "spec", "resources", "requests")
}
}
// apps/DameonSet MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable
// webhook CA's
Expand Down

0 comments on commit aa0f38d

Please sign in to comment.