...

Source file src/github.com/redhat-developer/odo/pkg/apiserver-gen/go/model_resource.go

Documentation: github.com/redhat-developer/odo/pkg/apiserver-gen/go

     1  /*
     2   * odo dev
     3   *
     4   * API interface for 'odo dev'
     5   *
     6   * API version: 0.1
     7   * Generated by: OpenAPI Generator (https://openapi-generator.tech)
     8   */
     9  
    10  package openapi
    11  
    12  type Resource struct {
    13  	Name string `json:"name"`
    14  
    15  	Inlined string `json:"inlined,omitempty"`
    16  
    17  	Uri string `json:"uri,omitempty"`
    18  
    19  	DeployByDefault string `json:"deployByDefault"`
    20  
    21  	// true if the resource is not referenced in any command
    22  	Orphan bool `json:"orphan"`
    23  }
    24  
    25  // AssertResourceRequired checks if the required fields are not zero-ed
    26  func AssertResourceRequired(obj Resource) error {
    27  	elements := map[string]interface{}{
    28  		"name":            obj.Name,
    29  		"deployByDefault": obj.DeployByDefault,
    30  		"orphan":          obj.Orphan,
    31  	}
    32  	for name, el := range elements {
    33  		if isZero := IsZeroValue(el); isZero {
    34  			return &RequiredError{Field: name}
    35  		}
    36  	}
    37  
    38  	return nil
    39  }
    40  
    41  // AssertRecurseResourceRequired recursively checks if required fields are not zero-ed in a nested slice.
    42  // Accepts only nested slice of Resource (e.g. [][]Resource), otherwise ErrTypeAssertionError is thrown.
    43  func AssertRecurseResourceRequired(objSlice interface{}) error {
    44  	return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
    45  		aResource, ok := obj.(Resource)
    46  		if !ok {
    47  			return ErrTypeAssertionError
    48  		}
    49  		return AssertResourceRequired(aResource)
    50  	})
    51  }
    52  

View as plain text