...

Source file src/github.com/redhat-developer/odo/pkg/apiserver-gen/go/model_devfile_content.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 DevfileContent struct {
    13  	Content string `json:"content"`
    14  
    15  	Version string `json:"version"`
    16  
    17  	Commands []Command `json:"commands"`
    18  
    19  	Containers []Container `json:"containers"`
    20  
    21  	Images []Image `json:"images"`
    22  
    23  	Resources []Resource `json:"resources"`
    24  
    25  	Volumes []Volume `json:"volumes"`
    26  
    27  	Events Events `json:"events"`
    28  
    29  	Metadata Metadata `json:"metadata"`
    30  }
    31  
    32  // AssertDevfileContentRequired checks if the required fields are not zero-ed
    33  func AssertDevfileContentRequired(obj DevfileContent) error {
    34  	elements := map[string]interface{}{
    35  		"content":    obj.Content,
    36  		"version":    obj.Version,
    37  		"commands":   obj.Commands,
    38  		"containers": obj.Containers,
    39  		"images":     obj.Images,
    40  		"resources":  obj.Resources,
    41  		"volumes":    obj.Volumes,
    42  		"events":     obj.Events,
    43  		"metadata":   obj.Metadata,
    44  	}
    45  	for name, el := range elements {
    46  		if isZero := IsZeroValue(el); isZero {
    47  			return &RequiredError{Field: name}
    48  		}
    49  	}
    50  
    51  	for _, el := range obj.Commands {
    52  		if err := AssertCommandRequired(el); err != nil {
    53  			return err
    54  		}
    55  	}
    56  	for _, el := range obj.Containers {
    57  		if err := AssertContainerRequired(el); err != nil {
    58  			return err
    59  		}
    60  	}
    61  	for _, el := range obj.Images {
    62  		if err := AssertImageRequired(el); err != nil {
    63  			return err
    64  		}
    65  	}
    66  	for _, el := range obj.Resources {
    67  		if err := AssertResourceRequired(el); err != nil {
    68  			return err
    69  		}
    70  	}
    71  	for _, el := range obj.Volumes {
    72  		if err := AssertVolumeRequired(el); err != nil {
    73  			return err
    74  		}
    75  	}
    76  	if err := AssertEventsRequired(obj.Events); err != nil {
    77  		return err
    78  	}
    79  	if err := AssertMetadataRequired(obj.Metadata); err != nil {
    80  		return err
    81  	}
    82  	return nil
    83  }
    84  
    85  // AssertRecurseDevfileContentRequired recursively checks if required fields are not zero-ed in a nested slice.
    86  // Accepts only nested slice of DevfileContent (e.g. [][]DevfileContent), otherwise ErrTypeAssertionError is thrown.
    87  func AssertRecurseDevfileContentRequired(objSlice interface{}) error {
    88  	return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
    89  		aDevfileContent, ok := obj.(DevfileContent)
    90  		if !ok {
    91  			return ErrTypeAssertionError
    92  		}
    93  		return AssertDevfileContentRequired(aDevfileContent)
    94  	})
    95  }
    96  

View as plain text