MCPcopy Create free account
hub / github.com/devfile/api / AddComponent

Method AddComponent

test/v200/utils/common/component_test_utils.go:56–78  ·  view source on GitHub ↗

AddComponent adds a component of the specified type, with random attributes, to the devfile schema

(componentType schema.ComponentType)

Source from the content-addressed store, hash-verified

54
55// AddComponent adds a component of the specified type, with random attributes, to the devfile schema
56func (devfile *TestDevfile) AddComponent(componentType schema.ComponentType) schema.Component {
57 LogInfoMessage(fmt.Sprintf("Create a %v component :", componentType))
58 component := schema.Component{}
59 component.Name = GetRandomUniqueString(8, true)
60 LogInfoMessage(fmt.Sprintf("....... Name: %s", component.Name))
61 switch componentType {
62 case schema.ContainerComponentType:
63 component.Container = &schema.ContainerComponent{}
64 devfile.SetContainerComponentValues(&component)
65 case schema.KubernetesComponentType:
66 component.Kubernetes = &schema.KubernetesComponent{}
67 devfile.SetK8sComponentValues(&component)
68 case schema.OpenshiftComponentType:
69 component.Openshift = &schema.OpenshiftComponent{}
70 devfile.SetK8sComponentValues(&component)
71 case schema.VolumeComponentType:
72 component.Volume = &schema.VolumeComponent{}
73 devfile.SetVolumeComponentValues(&component)
74 }
75
76 devfile.componentAdded(component)
77 return component
78}
79
80// GetContainer returns the name of an existing, or newly created, container.
81func (devfile *TestDevfile) GetContainerName() string {

Callers 3

RunTestMethod · 0.95
addVolumeMethod · 0.95
GetContainerNameMethod · 0.95

Calls 6

SetK8sComponentValuesMethod · 0.95
componentAddedMethod · 0.95
LogInfoMessageFunction · 0.85
GetRandomUniqueStringFunction · 0.85

Tested by

no test coverage detected