@@ -43,6 +43,12 @@ func (devfile *TestDevfile) AddComponent(componentType schema.ComponentType) sch
4343 if componentType == schema .ContainerComponentType {
4444 component = devfile .createContainerComponent ()
4545 devfile .SetContainerComponentValues (& component )
46+ } else if componentType == schema .KubernetesComponentType {
47+ component = devfile .createKubernetesComponent ()
48+ devfile .SetK8sComponentValues (& component )
49+ } else if componentType == schema .OpenshiftComponentType {
50+ component = devfile .createOpenshiftComponent ()
51+ devfile .SetK8sComponentValues (& component )
4652 } else if componentType == schema .VolumeComponentType {
4753 component = devfile .createVolumeComponent ()
4854 devfile .SetVolumeComponentValues (& component )
@@ -63,6 +69,32 @@ func (devfile *TestDevfile) createContainerComponent() schema.Component {
6369
6470}
6571
72+ // createKubernetesComponent creates a kubernetes component, ready for attribute setting
73+ func (devfile * TestDevfile ) createKubernetesComponent () schema.Component {
74+
75+ LogInfoMessage ("Create a kubernetes component :" )
76+ component := schema.Component {}
77+ component .Name = GetRandomUniqueString (8 , true )
78+ LogInfoMessage (fmt .Sprintf ("....... Name: %s" , component .Name ))
79+ component .Kubernetes = & schema.KubernetesComponent {}
80+ devfile .componentAdded (component )
81+ return component
82+
83+ }
84+
85+ // createOpenshiftComponent creates an openshift component, ready for attribute setting
86+ func (devfile * TestDevfile ) createOpenshiftComponent () schema.Component {
87+
88+ LogInfoMessage ("Create an openshift component :" )
89+ component := schema.Component {}
90+ component .Name = GetRandomUniqueString (8 , true )
91+ LogInfoMessage (fmt .Sprintf ("....... Name: %s" , component .Name ))
92+ component .Openshift = & schema.OpenshiftComponent {}
93+ devfile .componentAdded (component )
94+ return component
95+
96+ }
97+
6698// createVolumeComponent creates a volume component , ready for attribute setting
6799func (devfile * TestDevfile ) createVolumeComponent () schema.Component {
68100
@@ -162,6 +194,39 @@ func (devfile *TestDevfile) SetContainerComponentValues(component *schema.Compon
162194
163195}
164196
197+ func (devfile * TestDevfile ) SetK8sComponentValues (component * schema.Component ) {
198+ var k8type * schema.K8sLikeComponent = & schema.K8sLikeComponent {}
199+
200+ if component .Kubernetes != nil {
201+ k8type = & component .Kubernetes .K8sLikeComponent
202+ } else if component .Openshift != nil {
203+ k8type = & component .Openshift .K8sLikeComponent
204+ }
205+
206+ if k8type .Inlined != "" {
207+ k8type .Inlined = GetRandomString (GetRandomNumber (8 , 18 ), false )
208+ LogInfoMessage (fmt .Sprintf ("....... updated k8type.Inlined: %s" , k8type .Inlined ))
209+ } else if k8type .Uri != "" {
210+ k8type .Uri = GetRandomString (GetRandomNumber (8 , 18 ), false )
211+ LogInfoMessage (fmt .Sprintf ("....... updated k8type.Uri: %s" , k8type .Uri ))
212+ } else {
213+ //This is the component creation scenario when no inlined or uri property is set
214+ if GetBinaryDecision () {
215+ k8type .Inlined = GetRandomString (GetRandomNumber (8 , 18 ), false )
216+ LogInfoMessage (fmt .Sprintf ("....... created Inlined: %s" , k8type .Inlined ))
217+ } else {
218+ k8type .Uri = GetRandomString (GetRandomNumber (8 , 18 ), false )
219+ LogInfoMessage (fmt .Sprintf ("....... created Uri: %s" , k8type .Uri ))
220+ }
221+ }
222+
223+ if GetBinaryDecision () {
224+ k8type .Endpoints = devfile .CreateEndpoints ()
225+ }
226+
227+ devfile .componentUpdated (* component )
228+ }
229+
165230// SetVolumeComponentValues randomly sets/updates volume component attributes to random values
166231func (devfile * TestDevfile ) SetVolumeComponentValues (component * schema.Component ) {
167232
0 commit comments