Uploaded image for project: 'Service Binding'
  1. Service Binding
  2. APPSVC-324

API Review: Use GroupVersionResource where appropriate

XMLWordPrintable

    • App Services Sprint 178

      We have Group, Version and Resource in different types. We should use GroupVersionResource instead. 

      An example is the code below that can be found in our repository:

      type ApplicationSelector struct {
      	MatchLabels map[string]string `json:"matchLabels"`
      	Group       string            `json:"group,omitempty"`
      	Version     string            `json:"version"`
      	Resource    string            `json:"resource"`
      	ResourceRef string            `json:"resourceRef"`
      }
      

      An implementation could be having a field that's inlined only in the presentation layer by using the inline json modifier:

      type ApplicationSelector struct {
      	GroupVersionResource metav1.GroupVersionResource `json:",inline"`
      	MatchLabels          map[string]string           `json:"matchLabels"`
      	ResourceRef          string                      `json:"resourceRef"`
      }
      

      Another option I believe would be embed GroupVersionResource in ApplicationSelector, so the call sites are preserved.

      https://github.com/redhat-developer/service-binding-operator/blob/master/pkg/apis/apps/v1alpha1/servicebindingrequest_types.go#L74-L76

       

              bmuthuka Baiju Muthukadan
              isuttonl Igor Sutton (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: