Skip to content

Commit

Permalink
Merge pull request #227 from florkbr/add-ready-bool-to-frontend-config
Browse files Browse the repository at this point in the history
Add feoConfigEnabled bool to frontend spec for feo self service
  • Loading branch information
Hyperkid123 authored Nov 13, 2024
2 parents e42c008 + c243d97 commit 92a5c33
Show file tree
Hide file tree
Showing 15 changed files with 206 additions and 14 deletions.
2 changes: 2 additions & 0 deletions api/v1alpha1/frontend_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ type FrontendSpec struct {
// Data for the available widgets for the resource
WidgetRegistry []*WidgetEntry `json:"widgetRegistry,omitempty" yaml:"widgetRegistry,omitempty"`
Replicas *int32 `json:"replicas,omitempty" yaml:"replicas,omitempty"`
// Injects configuration from application when enabled
FeoConfigEnabled bool `json:"feoConfigEnabled,omitempty" yaml:"feoConfigEnabled,omitempty"`
}

var ReconciliationSuccessful = "ReconciliationSuccessful"
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/cloud.redhat.com_frontends.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ spec:
type: boolean
envName:
type: string
feoConfigEnabled:
description: Injects configuration from application when enabled
type: boolean
frontend:
properties:
paths:
Expand Down
17 changes: 14 additions & 3 deletions controllers/frontend_controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ var _ = ginkgo.Describe("Frontend controller with image", func() {
}},
Config: &customConfig,
},
FeoConfigEnabled: true,
},
}
gomega.Expect(k8sClient.Create(ctx, frontend)).Should(gomega.Succeed())
Expand Down Expand Up @@ -126,6 +127,7 @@ var _ = ginkgo.Describe("Frontend controller with image", func() {
Config: &customConfig2,
FullProfile: crd.FalsePtr(),
},
FeoConfigEnabled: true,
},
}
gomega.Expect(k8sClient.Create(ctx, frontend2)).Should(gomega.Succeed())
Expand Down Expand Up @@ -301,6 +303,7 @@ var _ = ginkgo.Describe("Frontend controller with service", func() {
}},
}},
},
FeoConfigEnabled: true,
},
}
gomega.Expect(k8sClient.Create(ctx, frontend)).Should(gomega.Succeed())
Expand Down Expand Up @@ -474,6 +477,7 @@ var _ = ginkgo.Describe("Frontend controller with chrome", func() {
}},
Config: &customConfig,
},
FeoConfigEnabled: true,
},
}
gomega.Expect(k8sClient.Create(ctx, frontend2)).Should(gomega.Succeed())
Expand Down Expand Up @@ -513,6 +517,7 @@ var _ = ginkgo.Describe("Frontend controller with chrome", func() {
}},
}},
},
FeoConfigEnabled: true,
},
}
gomega.Expect(k8sClient.Create(ctx, frontend3)).Should(gomega.Succeed())
Expand Down Expand Up @@ -781,6 +786,7 @@ var _ = ginkgo.Describe("Dependencies", func() {
Dependencies: []string{"depstring"},
}},
},
FeoConfigEnabled: true,
},
}
gomega.Expect(k8sClient.Create(ctx, frontend)).Should(gomega.Succeed())
Expand Down Expand Up @@ -821,6 +827,7 @@ var _ = ginkgo.Describe("Dependencies", func() {
OptionalDependencies: []string{"depstring-op"},
}},
},
FeoConfigEnabled: true,
},
}
gomega.Expect(k8sClient.Create(ctx, frontend2)).Should(gomega.Succeed())
Expand Down Expand Up @@ -860,6 +867,7 @@ var _ = ginkgo.Describe("Dependencies", func() {
}},
}},
},
FeoConfigEnabled: true,
},
}
gomega.Expect(k8sClient.Create(ctx, frontend3)).Should(gomega.Succeed())
Expand Down Expand Up @@ -958,7 +966,8 @@ func frontendFromSearchEntry(tc SearchIndexCase, entry SearchFrontendEntry) *crd
ManifestLocation: "",
Modules: []crd.Module{},
},
SearchEntries: entry.SearchEntries,
SearchEntries: entry.SearchEntries,
FeoConfigEnabled: true,
},
}

Expand Down Expand Up @@ -1152,7 +1161,8 @@ func frontendFromWidget(wc WidgetCase, wf WidgetFrontendTestEntry) *crd.Frontend
ManifestLocation: "",
Modules: []crd.Module{},
},
WidgetRegistry: wf.Widgets,
WidgetRegistry: wf.Widgets,
FeoConfigEnabled: true,
},
}
return frontend
Expand Down Expand Up @@ -1300,7 +1310,8 @@ func frontendFromServiceTile(sct ServiceTileCase, ste ServiceTileTestEntry) *crd
ManifestLocation: "",
Modules: []crd.Module{},
},
ServiceTiles: ste.ServiceTiles,
ServiceTiles: ste.ServiceTiles,
FeoConfigEnabled: true,
},
}
return frontend
Expand Down
12 changes: 7 additions & 5 deletions controllers/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ func defaultNetSpec(ingressClass, host string, ingressPaths []networking.HTTPIng

func setupFedModules(feEnv *crd.FrontendEnvironment, frontendList *crd.FrontendList, fedModules map[string]crd.FedModule) error {
for _, frontend := range frontendList.Items {
if frontend.Spec.Module != nil {
if (frontend.Name == "chrome" || frontend.Spec.FeoConfigEnabled) && frontend.Spec.Module != nil {
// module names in fed-modules.json must be camelCase
// K8s does not allow camelCase names, only
// whatever-this-case-is, so we convert.
Expand Down Expand Up @@ -840,7 +840,7 @@ func adjustSearchEntry(searchEntry *crd.SearchEntry, frontend crd.Frontend) crd.
func setupSearchIndex(feList *crd.FrontendList) []crd.SearchEntry {
searchIndex := []crd.SearchEntry{}
for _, frontend := range feList.Items {
if frontend.Spec.SearchEntries != nil {
if frontend.Spec.FeoConfigEnabled && frontend.Spec.SearchEntries != nil {
for _, searchEntry := range frontend.Spec.SearchEntries {
if searchEntry != nil {
searchIndex = append(searchIndex, adjustSearchEntry(searchEntry, frontend))
Expand All @@ -854,8 +854,10 @@ func setupSearchIndex(feList *crd.FrontendList) []crd.SearchEntry {
func setupWidgetRegistry(feList *crd.FrontendList) []crd.WidgetEntry {
widgetRegistry := []crd.WidgetEntry{}
for _, frontend := range feList.Items {
for _, widget := range frontend.Spec.WidgetRegistry {
widgetRegistry = append(widgetRegistry, *widget)
if frontend.Spec.FeoConfigEnabled {
for _, widget := range frontend.Spec.WidgetRegistry {
widgetRegistry = append(widgetRegistry, *widget)
}
}
}

Expand Down Expand Up @@ -900,7 +902,7 @@ func setupServiceTilesData(feList *crd.FrontendList, feEnvironment crd.FrontendE

skippedTiles := []string{}
for _, frontend := range feList.Items {
if frontend.Spec.ServiceTiles != nil {
if frontend.Spec.FeoConfigEnabled && frontend.Spec.ServiceTiles != nil {
for _, tile := range frontend.Spec.ServiceTiles {
groupKey := getServiceTilePath(tile.Section, tile.Group)
if groupTiles, ok := tileGroupAccessMap[groupKey]; ok {
Expand Down
3 changes: 3 additions & 0 deletions deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ objects:
type: boolean
envName:
type: string
feoConfigEnabled:
description: Injects configuration from application when enabled
type: boolean
frontend:
properties:
paths:
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/bundles/01-create-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ spec:
routes:
- pathname: /edge
moduleID: edge
feoConfigEnabled: true
---
apiVersion: cloud.redhat.com/v1alpha1
kind: Bundle
Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/feo-config-flag-disabled/00-create-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: test-feo-config-flag-namespace
spec:
finalizers:
- kubernetes
150 changes: 150 additions & 0 deletions tests/e2e/feo-config-flag-disabled/01-create-resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
---
apiVersion: cloud.redhat.com/v1alpha1
kind: FrontendEnvironment
metadata:
name: test-feo-config-flag-namespace-environment
spec:
generateNavJSON: true
ssl: false
hostname: foo.redhat.com
sso: https://sso.foo.redhat.com
---
apiVersion: cloud.redhat.com/v1alpha1
kind: Frontend
metadata:
name: edge
namespace: test-feo-config-flag-namespace
spec:
envName: test-feo-config-flag-namespace-environment
title: Edge
deploymentRepo: https://github.com/RedHatInsights/edge-frontend
API:
versions:
- v1
frontend:
paths:
- /apps/edge
image: "quay.io/cloudservices/edge-frontend:3244a17"
navItems:
- title: Inventory
expandable: true
routes:
- title: "Groups"
appId: "edge"
filterable: false
href: /edge/fleet-management
permissions:
- method: withEmail
args:
- "@redhat.com"
- "@sbb.ch"
- title: "Systems"
appId: "edge"
filterable: false
href: /edge/inventory
permissions:
- method: withEmail
args:
- "@redhat.com"
- "@sbb.ch"
permissions:
- method: withEmail
args:
- "@redhat.com"
- title: Manage Images
expandable: true
routes:
- title: "Images"
appId: "edge"
filterable: false
href: /edge/manage-images
permissions:
- method: withEmail
args:
- "@redhat.com"
- "@sbb.ch"
- title: "Custom Repositories"
appId: "edge"
filterable: false
href: /edge/repositories
permissions:
- method: withEmail
args:
- "@redhat.com"
- "@sbb.ch"
permissions:
- method: withEmail
args:
- "@redhat.com"
- "@sbb.ch"
- title: Learning Resources
href: /edge/learning-resources
permissions:
- method: withEmail
args:
- "@redhat.com"
- "@sbb.ch"
module:
manifestLocation: /apps/edge/fed-mods.json
modules:
- id: edge
module: ./RootApp
routes:
- pathname: /edge
moduleID: edge
serviceTiles:
- section: automation
group: ansible
id: ansible-link
title: Ansible FOO
href: /ansible/foo
description: Ansible FOO description thing
icon: AnsibleIcon
- section: iam
group: iam
id: iam-link
title: IAM FOO
href: /iam
description: Some Iam thing
icon: IAMIcon
isExternal: true
searchEntries:
- id: "landing"
title: "Landing"
href: /
description: "Landing page description"
alt_title:
- HCC Home page
- Home
- id: "landing-widgets"
title: "Widget fantastic"
href: /widgets
description: "Widget"
widgetRegistry:
- scope: "widgets"
module: "./RandomWidget"
config:
icon: "CogIcon"
title: "Random Widget"
defaults:
sm:
w: 1
h: 1
maxH: 1
minH: 1
md:
w: 1
h: 1
maxH: 1
minH: 1
lg:
w: 1
h: 1
maxH: 1
minH: 1
xl:
w: 1
h: 1
maxH: 1
minH: 1
feoConfigEnabled: false
14 changes: 14 additions & 0 deletions tests/e2e/feo-config-flag-disabled/02-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# The config map should be present in the default namespace
# however as FeoConfigEnabled is false - json should not be present
kind: ConfigMap
apiVersion: v1
metadata:
name: test-feo-config-flag-namespace-environment
namespace: test-feo-config-flag-namespace
labels:
frontendenv: test-feo-config-flag-namespace-environment
ownerReferences:
- apiVersion: cloud.redhat.com/v1alpha1
name: test-feo-config-flag-namespace-environment
data:
fed-modules.json: '{}'
1 change: 0 additions & 1 deletion tests/e2e/generate-nav-json/01-create-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ spec:
ssoUrl: 'https://'
manifestLocation: /apps/chrome/js/fed-mods.json
title: Chrome

3 changes: 1 addition & 2 deletions tests/e2e/generate-search-index/01-create-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ spec:
manifestLocation: /apps/search/fed-mods.json
modules: []
moduleID: search


feoConfigEnabled: true
1 change: 1 addition & 0 deletions tests/e2e/generate-service-tiles/01-create-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ spec:
description: Some Iam thing
icon: IAMIcon
isExternal: true
feoConfigEnabled: true
3 changes: 1 addition & 2 deletions tests/e2e/generate-widget-registry/01-create-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@ spec:
manifestLocation: /apps/widgets/fed-mods.json
modules: []
moduleID: widgets


feoConfigEnabled: true
1 change: 1 addition & 0 deletions tests/e2e/propagate-config-map/01-create-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ spec:
routes:
- pathname: /edge
moduleID: edge
feoConfigEnabled: true
---
apiVersion: cloud.redhat.com/v1alpha1
kind: Bundle
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/storage/01-create-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ spec:
ssoUrl: 'https://'
manifestLocation: /apps/chrome/js/fed-mods.json
title: Chrome

0 comments on commit 92a5c33

Please sign in to comment.