...

Source file src/github.com/redhat-developer/odo/pkg/devfile/validate/commands.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  // validateCommands validates the devfile commands:
     8  // 1. checks if its either an exec or composite command
     9  // 2. checks if the composite is a non run kind command
    10  func validateCommands(commandsMap map[string]devfilev1.Command) (err error) {
    11  
    12  	for _, command := range commandsMap {
    13  		err = validateCommand(command)
    14  		if err != nil {
    15  			return err
    16  		}
    17  	}
    18  
    19  	return
    20  }
    21  
    22  // validateCommand validates the given command
    23  // 1. command has to be of type exec or composite,
    24  // 2. if composite command, it should not be of kind run
    25  func validateCommand(command devfilev1.Command) (err error) {
    26  
    27  	// devfile command type for odo must be exec, apply or composite
    28  	if command.Exec == nil && command.Apply == nil && command.Composite == nil {
    29  		return &UnsupportedOdoCommandError{commandId: command.Id}
    30  	}
    31  
    32  	return
    33  }
    34  

View as plain text