How to merge two Unstructured objects type ?

461 views
Skip to first unread message

Mohamed Mahmoud

unread,
May 2, 2021, 11:37:12 AM5/2/21
to golang-nuts
Hi All:

 I am using two unstructured objects to represent two different ConfigMaps, of the same everything but different data,  I am looking for a way/API to merge both into one ConfigMap

I am looking for something like DeepAppend() or DeepMerge() 
any suggestion or recommendation ?

Thanks,
Mohamed

Amnon

unread,
May 2, 2021, 1:35:06 PM5/2/21
to golang-nuts
I am not sure what you mean by an unstructured object.
So probably best if you show us the code where they are defined.

Mohamed Mahmoud

unread,
May 2, 2021, 2:18:43 PM5/2/21
to golang-nuts
https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured#section-documentation

I am looking for something like the following 
func mergeObjects(obj1 *uns.Unstructured, obj2 *uns.Unstructured) (*uns.Unstructred, error) {

}

Thanks
Message has been deleted

Mohamed Mahmoud

unread,
May 2, 2021, 4:43:26 PM5/2/21
to Amnon, golang-nuts
This will copy over, it won’t append to it correct?

Sent from my iPhone

On May 2, 2021, at 4:17 PM, Amnon <amn...@gmail.com> wrote:

--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/TGjNhPCynEI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/9fe1da2f-cf8a-493c-b040-1876a78c0196n%40googlegroups.com.

Brian Candler

unread,
May 3, 2021, 4:26:48 AM5/3/21
to golang-nuts
On Sunday, 2 May 2021 at 19:18:43 UTC+1 mmahmo...@gmail.com wrote:
https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured#section-documentation

I am looking for something like the following 
func mergeObjects(obj1 *uns.Unstructured, obj2 *uns.Unstructured) (*uns.Unstructred, error) {

}


This sounds like more of a kubernetes question than a go question.  I think you first need to define exactly the semantics of this "merge" operation, because there are many possibilities for how it might work.

You could have a look at how kustomize handles this.  Maybe a strategic merge patch is what you're looking for?

Or maybe this:

Reply all
Reply to author
Forward
0 new messages