...

Source file src/github.com/redhat-developer/odo/pkg/apiserver-gen/go/model_command.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 Command struct {
    13  	Name string `json:"name"`
    14  
    15  	Group string `json:"group"`
    16  
    17  	Default bool `json:"default,omitempty"`
    18  
    19  	Type string `json:"type"`
    20  
    21  	Exec ExecCommand `json:"exec,omitempty"`
    22  
    23  	Apply ApplyCommand `json:"apply,omitempty"`
    24  
    25  	Image ImageCommand `json:"image,omitempty"`
    26  
    27  	Composite CompositeCommand `json:"composite,omitempty"`
    28  }
    29  
    30  // AssertCommandRequired checks if the required fields are not zero-ed
    31  func AssertCommandRequired(obj Command) error {
    32  	elements := map[string]interface{}{
    33  		"name":  obj.Name,
    34  		"group": obj.Group,
    35  		"type":  obj.Type,
    36  	}
    37  	for name, el := range elements {
    38  		if isZero := IsZeroValue(el); isZero {
    39  			return &RequiredError{Field: name}
    40  		}
    41  	}
    42  
    43  	if err := AssertExecCommandRequired(obj.Exec); err != nil {
    44  		return err
    45  	}
    46  	if err := AssertApplyCommandRequired(obj.Apply); err != nil {
    47  		return err
    48  	}
    49  	if err := AssertImageCommandRequired(obj.Image); err != nil {
    50  		return err
    51  	}
    52  	if err := AssertCompositeCommandRequired(obj.Composite); err != nil {
    53  		return err
    54  	}
    55  	return nil
    56  }
    57  
    58  // AssertRecurseCommandRequired recursively checks if required fields are not zero-ed in a nested slice.
    59  // Accepts only nested slice of Command (e.g. [][]Command), otherwise ErrTypeAssertionError is thrown.
    60  func AssertRecurseCommandRequired(objSlice interface{}) error {
    61  	return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
    62  		aCommand, ok := obj.(Command)
    63  		if !ok {
    64  			return ErrTypeAssertionError
    65  		}
    66  		return AssertCommandRequired(aCommand)
    67  	})
    68  }
    69  

View as plain text