Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Add cloud providers via configuration #1553

Draft
wants to merge 37 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
25753e5
Migrated WIP from enh/configure_cloudprovider to vue3 branch
grolu Sep 5, 2023
c51dba5
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Sep 6, 2023
fd98aff
fixed some issues
grolu Sep 8, 2023
9993beb
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Sep 11, 2023
b4527f8
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Oct 9, 2023
c7cf471
Added known vendor names
grolu Oct 20, 2023
b130779
rm unused action
grolu Oct 20, 2023
ae459ff
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Oct 20, 2023
5969d55
Some lint fixes
grolu Oct 23, 2023
0c773ef
Added documentation
grolu Oct 23, 2023
45a673d
Small fixes
grolu Oct 23, 2023
3cad75d
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Oct 23, 2023
6f251a7
Show cloud profiles without seed in frontend
grolu Dec 4, 2023
2e51cf9
Add custom input fields to create shoot infrastructure card
grolu Dec 4, 2023
e139528
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Dec 7, 2023
88ab096
moved custom fields to dedicated component
grolu Dec 11, 2023
2f6711e
Added simple generic selects
grolu Dec 11, 2023
ec98a0a
Removed logger import
grolu Dec 11, 2023
72208fc
updated tests (no longer filter cloudprofiles without matching seed)
grolu Dec 11, 2023
7a8d167
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Feb 5, 2024
fabc571
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Feb 6, 2024
8a9482e
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Mar 1, 2024
35547f7
updated charts
grolu Mar 1, 2024
0c8e20d
Updated documentation
grolu Mar 4, 2024
34a4285
Optimized documentation
grolu Mar 5, 2024
52f7da2
Further cleanup
grolu Mar 6, 2024
b65d099
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Mar 21, 2024
bbca10c
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Jul 23, 2024
bfe68dd
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Jul 23, 2024
400565e
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Jul 24, 2024
0e88908
Fixed helm template. & tests
grolu Jul 25, 2024
38cffb6
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Aug 6, 2024
a5ba4cc
Some docu fixes
grolu Aug 9, 2024
c8911c3
Some minor fixes
grolu Aug 12, 2024
467f7dd
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Sep 23, 2024
3290653
Fixed lint security warnings
grolu Sep 23, 2024
f04a237
Merge branch 'master' into enh/configure_cloudprovider_vue3
grolu Oct 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion backend/lib/routes/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ function sanitizeFrontendConfig (frontendConfig) {
} = {},
vendorHints = [],
resourceQuotaHelp = '',
controlPlaneHighAvailabilityHelp = ''
controlPlaneHighAvailabilityHelp = '',
customCloudProviders = {}
} = sanitizedFrontendConfig

convertAndSanitize(alert, 'message')
Expand Down Expand Up @@ -90,5 +91,12 @@ function sanitizeFrontendConfig (frontendConfig) {
convertAndSanitize(vendorHint, 'message')
}

for (const key of Object.keys(customCloudProviders)) {
const secret = _.get(customCloudProviders, [key, 'secret'])
if (secret) {
convertAndSanitize(secret, 'help')
}
}

return sanitizedFrontendConfig
}
13 changes: 1 addition & 12 deletions backend/lib/services/cloudprofiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

const { NotFound, Forbidden } = require('http-errors')
const authorization = require('./authorization')
const logger = require('../logger')
const _ = require('lodash')
const { getCloudProfiles, getVisibleAndNotProtectedSeeds } = require('../cache')

Expand Down Expand Up @@ -65,17 +64,7 @@ exports.list = async function ({ user }) {

const cloudProfiles = getCloudProfiles()
const seeds = getVisibleAndNotProtectedSeeds()
return _
.chain(cloudProfiles)
.map(assignSeedsToCloudProfileIteratee(seeds))
.filter(cloudProfile => {
if (!_.isEmpty(cloudProfile.data.seedNames)) {
return true
}
logger.info(`No matching seed for cloud profile with name ${cloudProfile.metadata.name} found`)
return false
})
.value()
return _.map(cloudProfiles, assignSeedsToCloudProfileIteratee(seeds))
}

exports.read = async function ({ user, name }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,27 @@ exports[`api cloudprofiles should return all cloudprofiles 2`] = `
"name": "infra1-profileName2",
},
},
{
"data": {
"kubernetes": {
"versions": [
{
"version": "1.9.0",
},
{
"version": "1.8.5",
},
],
},
"seedSelector": {},
"type": "infra2",
},
"metadata": {
"cloudProviderKind": "infra2",
"displayName": "infra2-profileName",
"name": "infra2-profileName",
},
},
{
"data": {
"kubernetes": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ exports[`gardener-dashboard configmap branding should render the template 1`] =
}
`;

exports[`gardener-dashboard configmap cloudProviderList should render the template with cloudProviderList 1`] = `
{
"frontend": {
"cloudProviderList": [
"foo",
"bar",
],
},
}
`;

exports[`gardener-dashboard configmap contentSecurityPolicy should render the template with connectSrc containing additional host sources 1`] = `
{
"contentSecurityPolicy": {
Expand Down Expand Up @@ -146,6 +157,60 @@ exports[`gardener-dashboard configmap controlPlaneHighAvailabilityHelp should re
}
`;

exports[`gardener-dashboard configmap customCloudProviders should render the template with customCloudProviders 1`] = `
{
"frontend": {
"customCloudProviders": {
"fooProvider": {
"secret": {
"fields": [
{
"hint": "Enter a valid namespace",
"key": "namespace",
"label": "Namespace",
"type": "text",
"validators": {
"required": {
"type": "required",
},
},
},
],
"help": "#Custom Cloud Provider
foo",
},
"shoot": {
"createFields": [
{
"hint": "Select foo value",
"key": "selectFoo",
"label": "Select Foo",
"path": "spec.provider",
"type": "select",
"validators": {
"required": {
"type": "required",
},
},
"values": {
"cloudprofilePath": "data.foo",
"key": "name",
},
},
],
"specTemplate": {
"provider": {
"type": "custom",
},
},
},
"zoned": false,
},
},
},
}
`;

exports[`gardener-dashboard configmap experimental should render the template with experimental features 1`] = `
{
"frontend": {
Expand Down Expand Up @@ -736,3 +801,15 @@ exports[`gardener-dashboard configmap vendorHints should render the template 1`]
},
}
`;

exports[`gardener-dashboard configmap vendors should render the template with vendors 1`] = `
{
"frontend": {
"vendors": {
"foo": {
"icon": "foo_icon.svg",
},
},
},
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,115 @@ describe('gardener-dashboard', function () {
})
})

describe('cloudProviderList', function () {
it('should render the template with cloudProviderList', async function () {
const values = {
global: {
dashboard: {
frontendConfig: {
cloudProviderList: [
'foo',
'bar'
]
}
}
}
}
const documents = await renderTemplates(templates, values)
expect(documents).toHaveLength(1)
const [configMap] = documents
const config = yaml.load(configMap.data['config.yaml'])
expect(pick(config, ['frontend.cloudProviderList'])).toMatchSnapshot()
})
})

describe('customCloudProviders', function () {
it('should render the template with customCloudProviders', async function () {
const values = {
global: {
dashboard: {
frontendConfig: {
customCloudProviders: {
fooProvider: {
zoned: false,
shoot: {
createFields: [
{
key: 'selectFoo',
path: 'spec.provider',
hint: 'Select foo value',
label: 'Select Foo',
type: 'select',
validators: {
required: {
type: 'required'
}
},
values: {
cloudprofilePath: 'data.foo',
key: 'name'
}
}
],
specTemplate: {
provider: {
type: 'custom'
}
}
},
secret: {
fields: [
{
key: 'namespace',
hint: 'Enter a valid namespace',
label: 'Namespace',
type: 'text',
validators: {
required: {
type: 'required'
}
}
}
],
help: '#Custom Cloud Provider\nfoo'
}
}
}
}
}
}
}
const documents = await renderTemplates(templates, values)
expect(documents).toHaveLength(1)
const [configMap] = documents
const config = yaml.load(configMap.data['config.yaml'])
expect(pick(config, ['frontend.customCloudProviders'])).toMatchSnapshot()
})
})

describe('vendors', function () {
it('should render the template with vendors', async function () {
const values = {
global: {
dashboard: {
frontendConfig: {
vendors: {
foo: {
icon: 'foo_icon.svg'
}
}
}
}
}
}
const documents = await renderTemplates(templates, values)
expect(documents).toHaveLength(1)
const [configMap] = documents
const config = yaml.load(configMap.data['config.yaml'])
expect(pick(config, ['frontend.vendors'])).toMatchSnapshot()
})
})

describe('knownConditions', function () {
it('should render the template with knownConditions markdown', async function () {
const values = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.global.dashboard.enabled }}
{{- if .Values.global.dashboard.frontendConfig.vendorAssets }}
apiVersion: v1
kind: ConfigMap
metadata:
name: dashboard-vendor-assets
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to configmap-assets.spec.js, add tests for vendor-assets

namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: gardener-dashboard
app.kubernetes.io/component: dashboard
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
binaryData:
{{- range $file, $content := .Values.global.dashboard.frontendConfig.vendorAssets }}
{{ $file }}: |
{{ $content }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,18 @@ data:
{{- if .Values.global.dashboard.frontendConfig.serviceAccountDefaultTokenExpiration }}
serviceAccountDefaultTokenExpiration: {{ .Values.global.dashboard.frontendConfig.serviceAccountDefaultTokenExpiration }}
{{- end }}
{{- if .Values.global.dashboard.frontendConfig.cloudProviderList }}
cloudProviderList:
{{- range .Values.global.dashboard.frontendConfig.cloudProviderList }}
- {{ . }}
{{- end }}
{{- end }}
{{- if .Values.global.dashboard.frontendConfig.customCloudProviders }}
customCloudProviders: {{ toYaml .Values.global.dashboard.frontendConfig.customCloudProviders | nindent 8 }}
{{- end }}
{{- if .Values.global.dashboard.frontendConfig.vendors }}
vendors: {{ toYaml .Values.global.dashboard.frontendConfig.vendors | nindent 8 }}
{{- end }}
{{- if .Values.global.dashboard.frontendConfig.knownConditions }}
knownConditions: {{ toYaml .Values.global.dashboard.frontendConfig.knownConditions | nindent 8 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ spec:
name: dashboard-assets
defaultMode: 0444
{{- end }}
{{- if .Values.global.dashboard.frontendConfig.vendorAssets }}
- name: vendor-assets
configMap:
name: dashboard-vendor-assets
defaultMode: 0444
{{- end }}
{{- if .Values.global.dashboard.oidc }}
- name: gardener-dashboard-oidc
secret:
Expand Down Expand Up @@ -206,6 +212,10 @@ spec:
- name: assets
mountPath: /app/public/static/assets
{{- end }}
{{- if .Values.global.dashboard.frontendConfig.vendorAssets }}
- name: vendor-assets
mountPath: /app/public/static/vendor-assets
{{- end }}
{{- if .Values.global.dashboard.serviceAccountTokenVolumeProjection.enabled }}
- name: service-account-token
mountPath: /var/run/secrets/projected/serviceaccount
Expand Down
Loading