...

Source file src/github.com/redhat-developer/odo/pkg/devfile/validate/components.go

Documentation: github.com/redhat-developer/odo/pkg/devfile/validate

     1  package validate
     2  
     3  import (
     4  	devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
     5  )
     6  
     7  // validateComponents validates the devfile components:
     8  // 1. there should be at least one component
     9  // 2. there should be at least one container component
    10  func validateComponents(components []devfilev1.Component) error {
    11  
    12  	// components cannot be empty
    13  	if len(components) < 1 {
    14  		return &NoComponentsError{}
    15  	}
    16  
    17  	// Check if component of type container is present
    18  	for _, component := range components {
    19  		if component.Container != nil {
    20  			return nil
    21  		}
    22  	}
    23  
    24  	return &NoContainerComponentError{}
    25  }
    26  

View as plain text