Files
odo/pkg/libdevfile/component.go
Philippe Martin e9dbded83b [ui] Set AutoBuild and DeployByDefault (#7051)
* Get and display autoBuild / deployByDefault

* Set autoBuild / deployByDefault

* Update ui static files

* [api] Add orpahn field to Image/Resource

* Display more info about Build / Deploy at startup

* Update ui static files

* e2e tests

* Update ui static files

* Fix unit tests

* 3-states button for AutoBuild

* 3-states button for DeployByDefault

* static ui files
2023-09-01 10:18:49 +02:00

57 lines
1.4 KiB
Go

package libdevfile
import (
"github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/library/v2/pkg/devfile/parser"
"github.com/devfile/library/v2/pkg/devfile/parser/data/v2/common"
)
type component interface {
CheckValidity() error
Apply(handler Handler, kind v1alpha2.CommandGroupKind) error
}
// newComponent creates a concrete component, based on its type
func newComponent(devfileObj parser.DevfileObj, devfileCmp v1alpha2.Component) (component, error) {
var cmp component
componentType, err := common.GetComponentType(devfileCmp)
if err != nil {
return nil, err
}
switch componentType {
case v1alpha2.ContainerComponentType:
cmp = newContainerComponent(devfileObj, devfileCmp)
case v1alpha2.KubernetesComponentType:
cmp = newKubernetesComponent(devfileObj, devfileCmp)
case v1alpha2.OpenshiftComponentType:
cmp = newOpenshiftComponent(devfileObj, devfileCmp)
case v1alpha2.VolumeComponentType:
cmp = newVolumeComponent(devfileObj, devfileCmp)
case v1alpha2.ImageComponentType:
cmp = newImageComponent(devfileObj, devfileCmp)
}
if err := cmp.CheckValidity(); err != nil {
return nil, err
}
return cmp, nil
}
func IsComponentReferenced(allApplyCommands []v1alpha2.Command, cmpName string) bool {
for _, cmd := range allApplyCommands {
if cmd.Apply == nil {
continue
}
if cmd.Apply.Component == cmpName {
return true
}
}
return false
}