Skip to content
object.go 2.46 KiB
Newer Older
Timothee Gosselin's avatar
Timothee Gosselin committed
/*

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package container

import (
	corev1 "k8s.io/api/core/v1"
	parameters "k8s.libre.sh/settings"
Timothee Gosselin's avatar
Timothee Gosselin committed
)

// +kubebuilder:object:generate=true
type Container struct {
Timothee Gosselin's avatar
Timothee Gosselin committed
	*TemplateSpec       `json:",inline"`
	parameters.Settings `json:"parameters,omitempty"`
Timothee Gosselin's avatar
Timothee Gosselin committed
}

// +kubebuilder:object:generate=true
type TemplateSpec struct {
	Name             string                        `json:"name,omitempty"`
	Args             []string                      `json:"args,omitempty"`
	Image            string                        `json:"image,omitempty"`
	ImagePullPolicy  corev1.PullPolicy             `json:"imagePullPolicy,omitempty"`
	ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
	Ports            []corev1.ContainerPort        `json:"ports,omitempty"`
	Probes           `json:"inline,omitempty"`
}

// +kubebuilder:object:generate=true
type Probes struct {
	ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty" protobuf:"bytes,11,opt,name=readinessProbe"`
	LivenessProbe  *corev1.Probe `json:"livenessProbe,omitempty" protobuf:"bytes,10,opt,name=livenessProbe"`
}

func (r *TemplateSpec) GetContainerImage() string                      { return r.Image }
func (r *TemplateSpec) GetContainerName() string                       { return r.Name }
func (r *TemplateSpec) GetContainerImagePullPolicy() corev1.PullPolicy { return r.ImagePullPolicy }
func (r *TemplateSpec) GetContainerPorts() []corev1.ContainerPort      { return r.Ports }
func (r *TemplateSpec) GetContainerLivenessProbe() *corev1.Probe       { return r.LivenessProbe }
func (r *TemplateSpec) GetContainerReadinessProbe() *corev1.Probe      { return r.ReadinessProbe }
func (r *TemplateSpec) GetContainerArgs() []string                     { return r.Args }

// func (r *TemplateSpec) GetParameters() parameters.Parameters { return nil }

Timothee Gosselin's avatar
Timothee Gosselin committed
//func NewContainer(spec *TemplateSpec, p parameters.Parameters) *Container {
//	return &Container{
//		Parameters:   p,
//		TemplateSpec: spec,
//	}
//}