Created
January 17, 2020 05:18
-
-
Save baijum/e761bc8fb28ba3855e5d1cd118e9192b to your computer and use it in GitHub Desktop.
JSON struct with inline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "gopkg.in/yaml.v3" | |
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | |
| ) | |
| type ApplicationSelector struct { | |
| LabelSelector *metav1.LabelSelector `json:",inline" yaml:",inline"` | |
| Group string `json:"group,omitempty"` | |
| Version string `json:"version"` | |
| Resource string `json:"resource"` | |
| ResourceRef string `json:"resourceRef"` | |
| } | |
| func main() { | |
| as := ApplicationSelector{LabelSelector: &metav1.LabelSelector{MatchLabels: map[string]string{"hi": "ok"}}} | |
| out, _ := yaml.Marshal(as) | |
| fmt.Println(string(out)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment