Newer
Older
Licensed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
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 components
import (
corev1 "k8s.io/api/core/v1"
// +kubebuilder:object:generate=true
type Workload struct {
Dependencies bool `json:"dependencies,omitempty"`
}
func (w *Workload) HasDependencies() bool {
return w.Dependencies
}
ing := &Ingress{
// TODO TO FIX
ObjectMeta: w.IngressMeta,
srv := &Service{
// TODO TO FIX
ObjectMeta: w.ServiceMeta,
meta.SetObjectMeta(w.ObjectMeta, ing.ObjectMeta)
meta.SetObjectMeta(w.ObjectMeta, srv.ObjectMeta)
objects[2] = w.Deployment
return objects
}
func (w *Workload) SetDependencies(s *settings.Component) { w.ConfigSpec = s.ConfigSpec }
func (w *Workload) GetDependencies() settings.Config { return w.ConfigSpec }
// TODO FIXME
w.Dependencies = true
containerPort := corev1.ContainerPort{
Name: w.Backend.Port.Name,
ContainerPort: w.Backend.Port.Port,
Protocol: w.Backend.Port.Protocol,
}
w.ContainerSpec.Ports = append(w.ContainerSpec.Ports, containerPort)
// TODO improve initialisation of objectMeta, labels...
}
if len(w.ObjectMeta.Labels) == 0 {
w.ObjectMeta.Labels = make(map[string]string)
}
if len(w.ObjectMeta.GetComponent()) == 0 {
w.ObjectMeta.SetComponent(DefaultComponent)
}