Skip to content

Commit

Permalink
update and improve eslint in backend package
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerkoser committed Sep 25, 2024
1 parent 74eb02b commit 771a002
Show file tree
Hide file tree
Showing 185 changed files with 3,751 additions and 1,722 deletions.
1,155 changes: 1,143 additions & 12 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
30 changes: 15 additions & 15 deletions backend/__fixtures__/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const pathToRegexp = require('path-to-regexp')
const {
COOKIE_HEADER_PAYLOAD,
COOKIE_TOKEN,
COOKIE_SIGNATURE
COOKIE_SIGNATURE,
} = require('../lib/security/constants')
const jose = require('../lib/security/jose')
const { sessionSecrets } = require('./config').default
Expand All @@ -31,7 +31,7 @@ async function getCookieValue (token) {
const cookies = {
[COOKIE_HEADER_PAYLOAD]: join([header, payload], '.'),
[COOKIE_SIGNATURE]: signature,
[COOKIE_TOKEN]: encrypted
[COOKIE_TOKEN]: encrypted,
}
return reduce(cookies, (accumulator, value, key) => {
if (accumulator) {
Expand Down Expand Up @@ -65,13 +65,13 @@ const auth = {
},
get bearer () {
return bearer
}
},
}
},
getTokenPayload ({ authorization } = {}) {
const [, token] = /^Bearer (.*)$/.exec(authorization)
return decode(token)
}
},
}

const mocks = {
Expand All @@ -91,28 +91,28 @@ const mocks = {
verbs: ['get'],
apiGroups: ['core.gardener.cloud'],
resources: ['projects'],
resourceName: ['foo']
resourceName: ['foo'],
})
resourceRules.push({
verbs: ['create'],
apiGroups: ['core.gardener.cloud'],
resources: ['projects']
resources: ['projects'],
})
} else {
resourceRules.push({
verbs: ['get'],
apiGroups: ['core.gardener.cloud'],
resources: ['projects'],
resourceName: ['foo']
resourceName: ['foo'],
})
}
return {
...json,
status: {
resourceRules,
nonResourceRules,
incomplete
}
incomplete,
},
}
}
},
Expand Down Expand Up @@ -143,8 +143,8 @@ const mocks = {
return Promise.resolve({
...json,
status: {
allowed
}
allowed,
},
})
}
},
Expand All @@ -163,14 +163,14 @@ const mocks = {
return Promise.resolve({
status: {
user,
authenticated
}
authenticated,
},
})
}
}
},
}

module.exports = {
...auth,
mocks
mocks,
}
36 changes: 18 additions & 18 deletions backend/__fixtures__/cloudprofiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,65 +12,65 @@ function getCloudProfile ({ uid, name, kind, seedSelector = {} }) {
return {
metadata: {
name,
uid
uid,
},
spec: {
type: kind,
seedSelector,
kubernetes: {
versions: [
{
version: '1.9.0'
version: '1.9.0',
},
{
version: '1.8.5'
}
]
}
}
version: '1.8.5',
},
],
},
},
}
}

const cloudProfileList = [
getCloudProfile({
uid: 1,
name: 'infra1-profileName',
kind: 'infra1'
kind: 'infra1',
}),
getCloudProfile({
uid: 2,
name: 'infra1-profileName2',
kind: 'infra1',
seedSelector: {
providerTypes: ['infra2', 'infra3']
}
providerTypes: ['infra2', 'infra3'],
},
}),
getCloudProfile({
uid: 3,
name: 'infra2-profileName',
kind: 'infra2'
kind: 'infra2',
}),
getCloudProfile({
uid: 4,
name: 'infra3-profileName',
kind: 'infra3',
seedSelector: {
matchLabels: { foo: 'bar' }
}
matchLabels: { foo: 'bar' },
},
}),
getCloudProfile({
uid: 5,
name: 'infra3-profileName2',
kind: 'infra3'
kind: 'infra3',
}),
getCloudProfile({
uid: 6,
name: 'infra4-profileName',
kind: 'infra4',
seedSelector: {
providerTypes: ['*']
}
})
providerTypes: ['*'],
},
}),
]

const cloudprofiles = {
Expand All @@ -83,7 +83,7 @@ const cloudprofiles = {
list () {
return cloneDeep(cloudProfileList)
},
reset () {}
reset () {},
}

module.exports = cloudprofiles
60 changes: 30 additions & 30 deletions backend/__fixtures__/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { toHex, toBase64, gardenerConfigPath } = require('./helper')
const ca = [
'-----BEGIN CERTIFICATE-----',
toBase64('...'),
'-----END CERTIFICATE-----'
'-----END CERTIFICATE-----',
].join('\n')

const defaultConfigPath = gardenerConfigPath()
Expand All @@ -30,8 +30,8 @@ const defaultConfig = {
repository: 'ticket-dev',
webhookSecret: toHex('webhook-secret'),
authentication: {
token: toHex('token')
}
token: toHex('token'),
},
},
sessionSecret,
sessionSecrets: [sessionSecret],
Expand All @@ -41,92 +41,92 @@ const defaultConfig = {
ca,
client_id: 'dashboard',
redirect_uris: [
'https://localhost:8443/auth/callback'
'https://localhost:8443/auth/callback',
],
scope: 'openid email profile groups audience:server:client_id:dashboard audience:server:client_id:kube-kubectl',
clockTolerance: 42,
public: {
clientId: 'kube-kubectl',
clientSecret: toHex('kube-kubectl-secret')
}
clientSecret: toHex('kube-kubectl-secret'),
},
},
terminal: {
container: {
image: 'dummyImage:1.0.0'
image: 'dummyImage:1.0.0',
},
containerImageDescriptions: [
{
image: '/dummyImage:.*/',
description: 'Dummy Image Description'
description: 'Dummy Image Description',
},
{
image: 'fooImage:0.1.2',
description: 'Foo Image Description'
}
description: 'Foo Image Description',
},
],
gardenTerminalHost: {
seedRef: 'infra1-seed2'
seedRef: 'infra1-seed2',
},
garden: {
operatorCredentials: {
serviceAccountRef: {
name: 'dashboard-terminal-admin',
namespace: 'garden'
}
}
}
namespace: 'garden',
},
},
},
},
unreachableSeeds: {
matchLabels: {
'test-unreachable': 'true'
}
'test-unreachable': 'true',
},
},
frontend: {
features: {
terminalEnabled: true
terminalEnabled: true,
},
helpMenuItems: [
{
title: 'Getting Started',
icon: 'description',
url: 'https://gardener.cloud/about/'
url: 'https://gardener.cloud/about/',
},
{
title: 'Feedback',
icon: 'mdi-slack',
url: 'https://kubernetes.slack.com/messages/gardener/'
url: 'https://kubernetes.slack.com/messages/gardener/',
},
{
title: 'Issues',
icon: 'mdi-bug',
url: 'https://github.com/gardener/dashboard/issues/'
}
url: 'https://github.com/gardener/dashboard/issues/',
},
],
serviceAccountDefaultTokenExpiration: 42
}
serviceAccountDefaultTokenExpiration: 42,
},
}

const configMap = new Map()

configMap.set(defaultConfigPath, defaultConfig)

configMap.set('/etc/gardener/1/config.yaml', {
port: 1234
port: 1234,
})

configMap.set('/etc/gardener/2/config.yaml', {
port: 1234,
logLevel: 'info'
logLevel: 'info',
})

configMap.set('/etc/gardener/3/config.yaml', {
sessionSecret: undefined
sessionSecret: undefined,
})

configMap.set('/etc/gardener/4/config.yaml', {
oidc: {
...defaultConfig.oidc
}
...defaultConfig.oidc,
},
})

module.exports = {
Expand All @@ -136,5 +136,5 @@ module.exports = {
},
list () {
return Array.from(configMap.entries())
}
},
}
20 changes: 10 additions & 10 deletions backend/__fixtures__/configmaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { createUrl } = require('./helper')
function getConfigMap ({ namespace, name, labels, creationTimestamp, data = {} }) {
const metadata = {
namespace,
name
name,
}
if (!isEmpty(labels)) {
metadata.labels = labels
Expand All @@ -32,13 +32,13 @@ function getClusterIdentitConfigMap ({ identity = 'landscape-test' } = {}) {
namespace: 'kube-system',
name: 'cluster-identity',
data: {
'cluster-identity': identity
}
'cluster-identity': identity,
},
})
}

const configMapsList = [
getClusterIdentitConfigMap()
getClusterIdentitConfigMap(),
]

const configMaps = {
Expand All @@ -60,13 +60,13 @@ const configMaps = {
name,
namespace,
labels: {
'gardener.cloud/role': 'ca-cluster'
'gardener.cloud/role': 'ca-cluster',
},
data: {
'ca.crt': 'ca.crt'
}
'ca.crt': 'ca.crt',
},
})
}
},
}

const matchOptions = { decode: decodeURIComponent }
Expand Down Expand Up @@ -116,10 +116,10 @@ const mocks = {

return Promise.reject(createError(404))
}
}
},
}

module.exports = {
...configMaps,
mocks
mocks,
}
Loading

0 comments on commit 771a002

Please sign in to comment.