Commit cbb2b7b0 authored by Timothee Gosselin's avatar Timothee Gosselin

rename proxy to web && cleanup

parent 85500585
Pipeline #185 canceled with stages
......@@ -166,10 +166,10 @@ type NextcloudSpec struct {
// Component spec is used for sync functions
// +optional
Component string `json:"component,omitempty"`
Proxy Proxy `json:"proxy,omitempty"`
Web Web `json:"web,omitempty"`
}
type Proxy struct {
type Web struct {
// Nextcloud runtime image to use. Defaults to indiehosters/nextcloud:<latest stable runtime ag>
// +optional
Image string `json:"image,omitempty"`
......
......@@ -249,36 +249,36 @@ func (in *ObjectStoreSpec) DeepCopy() *ObjectStoreSpec {
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Proxy) DeepCopyInto(out *Proxy) {
func (in *StorageSpec) DeepCopyInto(out *StorageSpec) {
*out = *in
if in.Local != nil {
in, out := &in.Local, &out.Local
*out = new(LocalSpec)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Proxy.
func (in *Proxy) DeepCopy() *Proxy {
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageSpec.
func (in *StorageSpec) DeepCopy() *StorageSpec {
if in == nil {
return nil
}
out := new(Proxy)
out := new(StorageSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *StorageSpec) DeepCopyInto(out *StorageSpec) {
func (in *Web) DeepCopyInto(out *Web) {
*out = *in
if in.Local != nil {
in, out := &in.Local, &out.Local
*out = new(LocalSpec)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageSpec.
func (in *StorageSpec) DeepCopy() *StorageSpec {
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Web.
func (in *Web) DeepCopy() *Web {
if in == nil {
return nil
}
out := new(StorageSpec)
out := new(Web)
in.DeepCopyInto(out)
return out
}
......@@ -6325,6 +6325,16 @@ spec:
version:
description: Version defines the desired app version
type: string
web:
properties:
image:
description: Nextcloud runtime image to use. Defaults to indiehosters/nextcloud:<latest
stable runtime ag>
type: string
imagePullPolicy:
description: ImagePullPolicy overridesNextcloudRuntime spec.imagePullPolicy
type: string
type: object
type: object
status:
properties:
......
......@@ -138,10 +138,10 @@ const conf = `
}
`
// SyncConfigMap syncs configMap resource for application proxy
// SyncConfigMap syncs configMap resource for application web
func (r *NextcloudReconciler) SyncConfigMap(app Nextcloud) (reconcile.Result, error) {
app.Spec.Component = "proxy"
app.Spec.Component = "web"
result, err := configmap.CreateOrUpdate(configmap.Conf{
Instance: app.Nextcloud,
......@@ -150,7 +150,7 @@ func (r *NextcloudReconciler) SyncConfigMap(app Nextcloud) (reconcile.Result, er
GenLabelsFunc: GenLabels,
// GenAnnotationsFunc: GenAnnotationsFunc,
// AppendLabels: AppendLabels,
GenDataFunc: configMapForProxy,
GenDataFunc: configMapForWeb,
Reconcile: r,
})
......@@ -163,7 +163,7 @@ func (r *NextcloudReconciler) SyncConfigMap(app Nextcloud) (reconcile.Result, er
return result, nil
}
func configMapForProxy(app interfaces.Object) (map[string]string, error) {
func configMapForWeb(app interfaces.Object) (map[string]string, error) {
var cm map[string]string
tmpl, err := template.New("test").Parse(conf)
if err != nil {
......
......@@ -67,7 +67,7 @@ func (r *NextcloudReconciler) SyncDeployment(app Nextcloud) (reconcile.Result, e
func (r *NextcloudReconciler) SyncDeploymentWeb(app Nextcloud) (reconcile.Result, error) {
app.Nextcloud.Spec.Component = "proxy"
app.Nextcloud.Spec.Component = "web"
result, err := deployment.CreateOrUpdate(deployment.Conf{
Instance: app.Nextcloud,
......@@ -80,14 +80,13 @@ func (r *NextcloudReconciler) SyncDeploymentWeb(app Nextcloud) (reconcile.Result
Containers: []container.Conf{
{
Name: "web",
Image: app.Nextcloud.Spec.Proxy.Image,
ImagePullPolicy: app.Nextcloud.Spec.Proxy.ImagePullPolicy,
Image: app.Nextcloud.Spec.Web.Image,
ImagePullPolicy: app.Nextcloud.Spec.Web.ImagePullPolicy,
GenContainerPortsFunc: GenContainerWebPorts,
GenContainerVolumeMountsFunc: GenContainerWebVolumeMounts,
GenContainerEnvVarFunc: GenContainerWebEnvVar,
},
},
GenVolumesFunc: GenContainerProxyVolumes,
GenVolumesFunc: GenContainerWebVolumes,
},
})
......
......@@ -264,22 +264,6 @@ func (app *Nextcloud) EnvApp() []corev1.EnvVar {
return out
}
// EnvProxy creates proxy env variables for pod
func (app *Nextcloud) EnvProxy() []corev1.EnvVar {
out := []corev1.EnvVar{
{
// TOFIX
Name: "SERVER_HOST",
Value: app.Nextcloud.Name,
},
{
Name: "SERVER_PORT",
Value: "9000",
},
}
return out
}
// EnvConf creates config env variables for pod
func (app *Nextcloud) EnvConf() []corev1.EnvVar {
out := []corev1.EnvVar{
......
......@@ -32,11 +32,11 @@ import (
// SyncIngress syncs ingress for application
func (r *NextcloudReconciler) SyncIngress(app Nextcloud) (reconcile.Result, error) {
app.Nextcloud.Spec.Component = "proxy"
app.Nextcloud.Spec.Component = "web"
result, err := ingress.CreateOrUpdate(ingress.Conf{
Instance: app.Nextcloud,
Name: fmt.Sprintf("%s-proxy", app.Nextcloud.Name),
Name: fmt.Sprintf("%s-web", app.Nextcloud.Name),
Namespace: app.Nextcloud.Namespace,
GenLabelsFunc: GenLabels,
Reconcile: r,
......@@ -87,7 +87,7 @@ func GenRules(obj interfaces.Object) ([]networkingv1beta1.IngressRule, error) {
}
bk := networkingv1beta1.IngressBackend{
ServiceName: fmt.Sprintf("%s-proxy", app.Name),
ServiceName: fmt.Sprintf("%s-web", app.Name),
ServicePort: intstr.FromString("http"),
}
......
......@@ -200,28 +200,14 @@ func GenContainerAppEnvVar(obj interfaces.Object) ([]corev1.EnvVar, error) {
return envList, nil
}
func GenContainerWebEnvVar(obj interfaces.Object) ([]corev1.EnvVar, error) {
var envList []corev1.EnvVar
app, ok := obj.(*appsv1alpha1.Nextcloud)
if !ok {
return envList, errors.New("failed to assert the original object")
}
nc := New(app)
envList = nc.EnvProxy()
return envList, nil
}
func GenContainerProxyVolumes(obj interfaces.Object) ([]corev1.Volume, error) {
func GenContainerWebVolumes(obj interfaces.Object) ([]corev1.Volume, error) {
var volumes []corev1.Volume
app, ok := obj.(*appsv1alpha1.Nextcloud)
if !ok {
return volumes, errors.New("failed to assert the original object")
}
volProxy := corev1.Volume{
volWeb := corev1.Volume{
Name: "nginx",
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
......@@ -231,7 +217,7 @@ func GenContainerProxyVolumes(obj interfaces.Object) ([]corev1.Volume, error) {
},
},
}
volumes = append(volumes, volProxy)
volumes = append(volumes, volWeb)
return volumes, nil
}
......
......@@ -56,11 +56,11 @@ func (r *NextcloudReconciler) SyncService(app Nextcloud) (reconcile.Result, erro
// SyncServiceWeb sync service resource for application
func (r *NextcloudReconciler) SyncServiceWeb(app Nextcloud) (reconcile.Result, error) {
app.Nextcloud.Spec.Component = "proxy"
app.Nextcloud.Spec.Component = "web"
result, err := service.CreateOrUpdate(service.Conf{
Instance: app.Nextcloud,
Name: fmt.Sprintf("%s-proxy", app.Nextcloud.Name),
Name: fmt.Sprintf("%s-web", app.Nextcloud.Name),
Namespace: app.Nextcloud.Namespace,
GenLabelsFunc: GenLabels,
Reconcile: r,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment