Skip to content

Commit 26a4a53

Browse files
committed
Resolve Issue #2
1 parent 43dc569 commit 26a4a53

File tree

8 files changed

+207
-23
lines changed

8 files changed

+207
-23
lines changed

api/v1alpha1/dashboard_types.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ import (
2626

2727
// DashboardSpec defines the desired state of Dashboard
2828
type DashboardSpec struct {
29-
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29+
// INSERT ADDITIONAL SPEC FIELDS - desired state of dashboard
3030
// Important: Run "make" to regenerate code after modifying this file
3131

32-
// Foo is an example field of Dashboard. Edit dashboard_types.go to remove/update
32+
// ConfigMap is where you want said homer configuration stored.
3333
ConfigMap ConfigMap `json:"configMap,omitempty"`
34+
35+
// HomerConfig is base/default Homer configuration.
3436
HomerConfig homer.HomerConfig `json:"homerConfig,omitempty"`
3537
}
3638

@@ -66,6 +68,8 @@ func init() {
6668
}
6769

6870
type ConfigMap struct {
71+
// Name is the ConfigMap name where Homer configuration is stored.
6972
Name string `json:"name,omitempty"`
70-
Key string `json:"key,omitempty"`
71-
}
73+
// Key is the key in the ConfigMap where Homer configuration is stored.
74+
Key string `json:"key,omitempty"`
75+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/homer.rajsingh.info_dashboards.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,40 @@ spec:
4040
description: DashboardSpec defines the desired state of Dashboard
4141
properties:
4242
configMap:
43-
description: Foo is an example field of Dashboard. Edit dashboard_types.go
44-
to remove/update
43+
description: ConfigMap is where you want said homer configuration
44+
stored.
4545
properties:
4646
key:
47+
description: Key is the key in the ConfigMap where Homer configuration
48+
is stored.
4749
type: string
4850
name:
51+
description: Name is the ConfigMap name where Homer configuration
52+
is stored.
4953
type: string
5054
type: object
5155
homerConfig:
56+
description: HomerConfig is base/default Homer configuration.
5257
properties:
5358
defaults:
59+
description: Defaults are your default settings for the dashboard.
5460
properties:
5561
colorTheme:
62+
description: ColorTheme is the name of the color theme to
63+
be used.
5664
type: string
5765
layout:
66+
description: Layout is the layout of the dashboard.
5867
type: string
5968
type: object
6069
footer:
70+
description: Footer to be displayed on the dashboard.
6171
type: string
6272
header:
6373
type: string
6474
links:
75+
description: Links contains any additional links (static) to be
76+
displayed on the dashboard.
6577
items:
6678
properties:
6779
icon:
@@ -75,8 +87,10 @@ spec:
7587
type: object
7688
type: array
7789
logo:
90+
description: Logo used within dashboard.
7891
type: string
7992
services:
93+
description: List of Services to be displayed on the dashboard.
8094
items:
8195
properties:
8296
icon:
@@ -127,8 +141,10 @@ spec:
127141
type: object
128142
type: array
129143
subtitle:
144+
description: Subtitle
130145
type: string
131146
title:
147+
description: Title to which is displayed on the dashboard.
132148
type: string
133149
type: object
134150
type: object

config/rbac/role.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,24 @@ rules:
7575
resources:
7676
- ingresses
7777
verbs:
78+
- create
79+
- delete
7880
- get
7981
- list
82+
- patch
83+
- update
8084
- watch
85+
- apiGroups:
86+
- networking.k8s.io
87+
resources:
88+
- ingresses/finalizers
89+
verbs:
90+
- update
91+
- apiGroups:
92+
- networking.k8s.io
93+
resources:
94+
- ingresses/status
95+
verbs:
96+
- get
97+
- patch
98+
- update

internal/controller/dashboard_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (r *DashboardReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
9393
// Resource Created - Create all resources
9494
deployment := homer.CreateDeployment(dashboard.Name, dashboard.Namespace)
9595
service := homer.CreateService(dashboard.Name, dashboard.Namespace)
96-
configMap := homer.CreateConfigMap(dashboard.Spec.HomerConfig, dashboard.Name, dashboard.Namespace, *ingresses)
96+
configMap := homer.CreateConfigMap(&dashboard.Spec.HomerConfig, dashboard.Name, dashboard.Namespace, *ingresses)
9797
// List of resources
9898
resources := []client.Object{&deployment, &service, &configMap}
9999

internal/controller/ingress_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ package controller
1919
import (
2020
"context"
2121
homerv1alpha1 "github.com/rajsinghtech/homer-operator.git/api/v1alpha1"
22+
homer "github.com/rajsinghtech/homer-operator.git/pkg/homer"
23+
corev1 "k8s.io/api/core/v1"
2224
networkingv1 "k8s.io/api/networking/v1"
2325
"k8s.io/apimachinery/pkg/runtime"
2426
ctrl "sigs.k8s.io/controller-runtime"
2527
"sigs.k8s.io/controller-runtime/pkg/client"
26-
homer "github.com/rajsinghtech/homer-operator.git/pkg/homer"
27-
corev1 "k8s.io/api/core/v1"
2828
"sigs.k8s.io/controller-runtime/pkg/log"
2929
)
3030

@@ -106,4 +106,4 @@ func getAllDashboard(ctx context.Context, r *IngressReconciler) (*homerv1alpha1.
106106
return nil, err
107107
}
108108
return &dashboardList, nil
109-
}
109+
}

pkg/homer/config.go

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package homer
22

3+
// +kubebuilder:object:generate=true
4+
35
import (
46
"os"
57
"reflect"
@@ -13,23 +15,35 @@ import (
1315
"k8s.io/apimachinery/pkg/util/intstr"
1416
)
1517

18+
// HomerConfig contains base configuration for Homer dashboard.
1619
type HomerConfig struct {
17-
Title string `json:"title,omitempty"`
18-
Subtitle string `json:"subtitle,omitempty"`
19-
Logo string `json:"logo,omitempty"`
20-
Header string `json:"header,omitempty"`
21-
Services []Service `json:"services,omitempty"`
22-
Footer string `json:"footer,omitempty"`
20+
// Title to which is displayed on the dashboard.
21+
Title string `json:"title,omitempty"`
22+
// Subtitle
23+
Subtitle string `json:"subtitle,omitempty"`
24+
// Logo used within dashboard.
25+
Logo string `json:"logo,omitempty"`
26+
Header string `json:"header,omitempty"`
27+
// List of Services to be displayed on the dashboard.
28+
Services []Service `json:"services,omitempty"`
29+
// Footer to be displayed on the dashboard.
30+
Footer string `json:"footer,omitempty"`
31+
// Defaults are your default settings for the dashboard.
2332
Defaults DefaultConfig `json:"defaults,omitempty"`
24-
Links []Link `json:"links,omitempty"`
33+
// Links contains any additional links (static) to be displayed on the dashboard.
34+
Links []Link `json:"links,omitempty"`
2535
}
2636

37+
// ProxyConfig contains configuration for proxy settings.
2738
type ProxyConfig struct {
2839
UseCredentials bool `json:"useCredentials,omitempty"`
2940
}
3041

42+
// DefaultConfig contains default settings for the Homer dashboard.
3143
type DefaultConfig struct {
32-
Layout string `json:"layout,omitempty"`
44+
// Layout is the layout of the dashboard.
45+
Layout string `json:"layout,omitempty"`
46+
// ColorTheme is the name of the color theme to be used.
3347
ColorTheme string `json:"colorTheme,omitempty"`
3448
}
3549

@@ -53,7 +67,7 @@ type Item struct {
5367
Class string `json:"class,omitempty"`
5468
Background string `json:"background,omitempty"`
5569
Apikey string `json:"apikey,omitempty"`
56-
Node string `json:"node,omitempty"`
70+
Node string `json:"node,omitempty"`
5771
Legacyapi string `json:"legacyApi,omitempty"`
5872
Librarytype string `json:"libraryType,omitempty"`
5973
Warningvalue string `json:"warning_value,omitempty"`
@@ -82,8 +96,8 @@ func LoadConfigFromFile(filename string) (*HomerConfig, error) {
8296
return &config, nil
8397
}
8498

85-
func CreateConfigMap(config HomerConfig, name string, namespace string, ingresses networkingv1.IngressList) corev1.ConfigMap {
86-
UpdateHomerConfig(&config, ingresses)
99+
func CreateConfigMap(config *HomerConfig, name string, namespace string, ingresses networkingv1.IngressList) corev1.ConfigMap {
100+
UpdateHomerConfig(config, ingresses)
87101
objYAML, err := yaml.Marshal(config)
88102
if err != nil {
89103
return corev1.ConfigMap{}
@@ -284,4 +298,4 @@ func UpdateConfigMapIngress(cm *corev1.ConfigMap, ingress networkingv1.Ingress)
284298
return
285299
}
286300
cm.Data["config.yml"] = string(objYAML)
287-
}
301+
}

pkg/homer/zz_generated.deepcopy.go

Lines changed: 131 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)