...

Source file src/github.com/redhat-developer/odo/pkg/libdevfile/generator/component.go

Documentation: github.com/redhat-developer/odo/pkg/libdevfile/generator

     1  package generator
     2  
     3  import (
     4  	"github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
     5  	"github.com/devfile/api/v2/pkg/attributes"
     6  )
     7  
     8  type ContainerComponentParams struct {
     9  	Name       string
    10  	Attributes *attributes.Attributes
    11  
    12  	Container v1alpha2.Container
    13  	Endpoints []v1alpha2.Endpoint
    14  }
    15  
    16  func GetContainerComponent(params ContainerComponentParams) v1alpha2.Component {
    17  	cmp := v1alpha2.Component{
    18  		Name: params.Name,
    19  		ComponentUnion: v1alpha2.ComponentUnion{
    20  			Container: &v1alpha2.ContainerComponent{
    21  				Container: params.Container,
    22  				Endpoints: params.Endpoints,
    23  			},
    24  		},
    25  	}
    26  	if params.Attributes != nil {
    27  		cmp.Attributes = *params.Attributes
    28  	}
    29  	return cmp
    30  }
    31  
    32  type ImageComponentParams struct {
    33  	Name       string
    34  	Attributes *attributes.Attributes
    35  
    36  	Image v1alpha2.Image
    37  }
    38  
    39  func GetImageComponent(params ImageComponentParams) v1alpha2.Component {
    40  	cmp := v1alpha2.Component{
    41  		Name: params.Name,
    42  		ComponentUnion: v1alpha2.ComponentUnion{
    43  			Image: &v1alpha2.ImageComponent{
    44  				Image: params.Image,
    45  			},
    46  		},
    47  	}
    48  	if params.Attributes != nil {
    49  		cmp.Attributes = *params.Attributes
    50  	}
    51  	return cmp
    52  }
    53  
    54  type KubernetesComponentParams struct {
    55  	Name       string
    56  	Attributes *attributes.Attributes
    57  
    58  	Kubernetes *v1alpha2.KubernetesComponent
    59  }
    60  
    61  func GetKubernetesComponent(params KubernetesComponentParams) v1alpha2.Component {
    62  	cmp := v1alpha2.Component{
    63  		Name: params.Name,
    64  		ComponentUnion: v1alpha2.ComponentUnion{
    65  			Kubernetes: params.Kubernetes,
    66  		},
    67  	}
    68  	if params.Attributes != nil {
    69  		cmp.Attributes = *params.Attributes
    70  	}
    71  	return cmp
    72  }
    73  
    74  type OpenshiftComponentParams struct {
    75  	Name       string
    76  	Attributes *attributes.Attributes
    77  
    78  	Openshift *v1alpha2.OpenshiftComponent
    79  }
    80  
    81  func GetOpenshiftComponent(params OpenshiftComponentParams) v1alpha2.Component {
    82  	cmp := v1alpha2.Component{
    83  		Name: params.Name,
    84  		ComponentUnion: v1alpha2.ComponentUnion{
    85  			Openshift: params.Openshift,
    86  		},
    87  	}
    88  	if params.Attributes != nil {
    89  		cmp.Attributes = *params.Attributes
    90  	}
    91  	return cmp
    92  }
    93  
    94  type VolumeComponentParams struct {
    95  	Name string
    96  }
    97  
    98  func GetVolumeComponent(params VolumeComponentParams) v1alpha2.Component {
    99  	cmp := v1alpha2.Component{
   100  		Name: params.Name,
   101  		ComponentUnion: v1alpha2.ComponentUnion{
   102  			Volume: &v1alpha2.VolumeComponent{},
   103  		},
   104  	}
   105  	return cmp
   106  }
   107  

View as plain text