@rancher/shell 1.2.5-rc.1 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import {
4
4
  import { CATALOG as CATALOG_ANNOTATIONS, FLEET } from '@shell/config/labels-annotations';
5
5
  import { compare, isPrerelease, sortable } from '@shell/utils/version';
6
6
  import { filterBy } from '@shell/utils/array';
7
- import { CATALOG, MANAGEMENT, NORMAN } from '@shell/config/types';
7
+ import { CATALOG, MANAGEMENT, NORMAN, SECRET } from '@shell/config/types';
8
8
  import { SHOW_PRE_RELEASE } from '@shell/store/prefs';
9
9
  import { set } from '@shell/utils/object';
10
10
 
@@ -271,28 +271,119 @@ export default class CatalogApp extends SteveModel {
271
271
  };
272
272
  }
273
273
 
274
- get deployedAsLegacy() {
275
- return async() => {
276
- if (this.spec?.values?.global) {
277
- const { clusterName, projectName } = this.spec.values.global;
278
-
279
- if (clusterName && projectName) {
280
- try {
281
- const legacyApp = await this.$dispatch('rancher/find', {
282
- type: NORMAN.APP,
283
- id: `${ projectName }:${ this.metadata?.name }`,
284
- opt: { url: `/v3/project/${ clusterName }:${ projectName }/apps/${ projectName }:${ this.metadata?.name }` }
285
- }, { root: true });
286
-
287
- if (legacyApp) {
288
- return legacyApp;
289
- }
290
- } catch (e) {}
291
- }
274
+ async deployedAsLegacy() {
275
+ await this.fetchValues();
276
+
277
+ if (this.values?.global) {
278
+ const { clusterName, projectName } = this.values.global;
279
+
280
+ if (clusterName && projectName) {
281
+ try {
282
+ const legacyApp = await this.$dispatch('rancher/find', {
283
+ type: NORMAN.APP,
284
+ id: `${ projectName }:${ this.metadata?.name }`,
285
+ opt: { url: `/v3/project/${ clusterName }:${ projectName }/apps/${ projectName }:${ this.metadata?.name }` }
286
+ }, { root: true });
287
+
288
+ if (legacyApp) {
289
+ return legacyApp;
290
+ }
291
+ } catch (e) {}
292
292
  }
293
+ }
293
294
 
294
- return false;
295
- };
295
+ return false;
296
+ }
297
+
298
+ /**
299
+ * User and Chart values live in a helm secret, so fetch it (with special param)
300
+ */
301
+ async fetchValues(force = false) {
302
+ if (!this.secretId) {
303
+ // If there's no secret id this isn't ever going to work, no need to carry on
304
+ return;
305
+ }
306
+
307
+ const haveValues = !!this._values && !!this._chartValues;
308
+
309
+ if (haveValues && !force) {
310
+ // If we already have the required values and we're not forced to re-fetch, no need to carry on
311
+ return;
312
+ }
313
+
314
+ try {
315
+ await this.$dispatch('find', {
316
+ type: SECRET,
317
+ id: this.secretId,
318
+ opt: {
319
+ force: force || (!!this._secret && !haveValues), // force if explicitly requested or there's ean existing secret without the required values we have a secret without the values in (Secret has been fetched another way)
320
+ watch: false, // Cannot watch with custom params (they are dropped on calls made when resyncing over socket)
321
+ params: { includeHelmData: true }
322
+ }
323
+ });
324
+ } catch (e) {
325
+ console.error(`Cannot find values for ${ this.id } (unable to fetch)`, e); // eslint-disable-line no-console
326
+ }
327
+ }
328
+
329
+ get secretId() {
330
+ const metadata = this.metadata;
331
+
332
+ if (!metadata) {
333
+ return null;
334
+ }
335
+ const secretReference = metadata?.ownerReferences?.find((ow) => ow.kind.toLowerCase() === SECRET);
336
+
337
+ const secretId = secretReference?.name;
338
+ const secretNamespace = metadata.namespace;
339
+
340
+ if (!secretNamespace || !secretId) {
341
+ console.warn(`Cannot find values for ${ this.id } (cannot find related secret namespace or id)`); // eslint-disable-line no-console
342
+
343
+ return null;
344
+ }
345
+
346
+ return `${ secretNamespace }/${ secretId }`;
347
+ }
348
+
349
+ get _secret() {
350
+ return this.secretId ? this.$getters['byId'](SECRET, this.secretId) : null;
351
+ }
352
+
353
+ _validateSecret(noun) {
354
+ if (this._secret === undefined) {
355
+ throw new Error(`Cannot find ${ noun } for ${ this.id } (chart secret has not been fetched via app \`fetchValues\`)`);
356
+ }
357
+
358
+ if (this._secret === null) {
359
+ throw new Error(`Cannot find ${ noun } for ${ this.id } (chart secret cannot or has failed to fetch) `);
360
+ }
361
+ }
362
+
363
+ /**
364
+ * The user's helm values
365
+ */
366
+ get values() {
367
+ this._validateSecret('values');
368
+
369
+ return this._values;
370
+ }
371
+
372
+ get _values() {
373
+ return this._secret?.data?.release?.config;
374
+ }
375
+
376
+ /**
377
+ * The Charts default helm values
378
+ */
379
+ get chartValues() {
380
+ this._validateSecret('chartValues');
381
+
382
+ return this._chartValues;
383
+ }
384
+
385
+ get _chartValues() {
386
+ return this._secret?.data?.release?.chart?.values;
296
387
  }
297
388
  }
298
389
 
@@ -16,6 +16,8 @@ import { LINUX, WINDOWS } from '@shell/store/catalog';
16
16
  import { KONTAINER_TO_DRIVER } from './management.cattle.io.kontainerdriver';
17
17
  import { PINNED_CLUSTERS } from '@shell/store/prefs';
18
18
 
19
+ const DEFAULT_BADGE_COLOR = '#707070';
20
+
19
21
  // See translation file cluster.providers for list of providers
20
22
  // If the logo is not named with the provider name, add an override here
21
23
  const PROVIDER_LOGO_OVERRIDE = {};
@@ -295,20 +297,30 @@ export default class MgmtCluster extends HybridModel {
295
297
 
296
298
  // Custom badge to show for the Cluster (if the appropriate annotations are set)
297
299
  get badge() {
298
- const text = this.metadata?.annotations?.[CLUSTER_BADGE.TEXT];
300
+ const icon = this.metadata?.annotations?.[CLUSTER_BADGE.ICON_TEXT];
301
+ const comment = this.metadata?.annotations?.[CLUSTER_BADGE.TEXT];
299
302
 
300
- if (!text) {
303
+ if (!icon && !comment) {
301
304
  return undefined;
302
305
  }
303
306
 
304
- const color = this.metadata?.annotations[CLUSTER_BADGE.COLOR] || '#7f7f7f';
307
+ let color = this.metadata?.annotations[CLUSTER_BADGE.COLOR] || DEFAULT_BADGE_COLOR;
305
308
  const iconText = this.metadata?.annotations[CLUSTER_BADGE.ICON_TEXT] || '';
309
+ let foregroundColor;
310
+
311
+ try {
312
+ foregroundColor = textColor(parseColor(color.trim())); // Remove any whitespace
313
+ } catch (_e) {
314
+ // If we could not parse the badge color, use the defaults
315
+ color = DEFAULT_BADGE_COLOR;
316
+ foregroundColor = textColor(parseColor(color));
317
+ }
306
318
 
307
319
  return {
308
- text,
320
+ text: comment || undefined,
309
321
  color,
310
- textColor: textColor(parseColor(color)),
311
- iconText: iconText.substr(0, 2)
322
+ textColor: foregroundColor,
323
+ iconText: iconText.substr(0, 3)
312
324
  };
313
325
  }
314
326
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rancher/shell",
3
- "version": "1.2.5-rc.1",
3
+ "version": "1.2.6",
4
4
  "description": "Rancher Dashboard Shell",
5
5
  "repository": "https://github.com/rancherlabs/dashboard",
6
6
  "license": "Apache-2.0",
@@ -301,8 +301,9 @@ export default {
301
301
  */
302
302
  userValues = diff(this.loadedVersionValues, this.chartValues);
303
303
  } else if ( this.existing ) {
304
+ await this.existing.fetchValues(); // In theory this has already been called, but do again to be safe
304
305
  /* For an already installed app, use the values from the previous install. */
305
- userValues = clone(this.existing.spec?.values || {});
306
+ userValues = clone(this.existing.values || {});
306
307
  } else {
307
308
  /* For an new app, start empty. */
308
309
  userValues = {};
@@ -42,7 +42,7 @@ for d in ${BASE_DIR}/dist-pkg/*; do
42
42
  mkdir plugin && mv ./${pkg}/* ./plugin
43
43
  rm -rf ./${pkg}/* && mv ./plugin ./${pkg}
44
44
 
45
- find ${pkg} -type f -printf '%P\n' | sort > ./${pkg}/files.txt
45
+ find ${pkg} -type f | sed "s|^${pkg}/||" | sort > ./${pkg}/files.txt
46
46
  popd > /dev/null
47
47
 
48
48
  cp -R ${BASE_DIR}/dist-pkg/${pkg} ${TMP}/container/plugin
@@ -1,10 +1,8 @@
1
1
  annotations:
2
2
  catalog.cattle.io/certified: rancher # Any application we are adding as a helm chart
3
- catalog.cattle.io/kube-version: '>= 1.16.0-0 < 1.29.0-0'
4
3
  catalog.cattle.io/namespace: cattle-ui-plugin-system # Must prefix with cattle- and suffix with -system=
5
4
  catalog.cattle.io/os: linux
6
5
  catalog.cattle.io/permits-os: linux, windows
7
- catalog.cattle.io/rancher-version: '>= 2.7.0-0 < 2.9.0-0'
8
6
  catalog.cattle.io/scope: management
9
7
  catalog.cattle.io/ui-component: plugins
10
8
  apiVersion: v2
@@ -4,27 +4,36 @@ GITHUB_RELEASE_TAG=$1
4
4
  GITHUB_RUN_ID=$2
5
5
  GITHUB_WORKFLOW_TYPE=$3
6
6
 
7
- # Check packages for released tag name
8
- if [[ "${GITHUB_WORKFLOW_TYPE}" == "container" ]]; then
7
+ echo "Parse tag name - evaluating release tag $GITHUB_RELEASE_TAG"
8
+
9
+ # Ensure "catalog" workflow release tag name matches the root <pkg-name>
10
+ if [[ "${GITHUB_WORKFLOW_TYPE}" == "catalog" ]]; then
11
+ BASE_EXT=$(jq -r .name package.json)
12
+ EXT_VERSION=$(jq -r .version package.json)
13
+
14
+ if [[ "${GITHUB_RELEASE_TAG}" != "${BASE_EXT}-${EXT_VERSION}" ]]; then
15
+ echo -e "release tag doesn't match catalog tag: release tag -> ${GITHUB_RELEASE_TAG} ::: curr catalog tag -> ${BASE_EXT}-${EXT_VERSION}"
16
+ gh run cancel ${GITHUB_RUN_ID}
17
+ exit 1
18
+ fi
19
+ # Ensure "chart" workflow release tag name matches some pkg/<pkg-name>
20
+ else
21
+ NO_MATCHES="true"
22
+
9
23
  for d in pkg/*/ ; do
10
24
  pkg=$(basename $d)
11
25
 
12
26
  PKG_VERSION=$(jq -r .version pkg/${pkg}/package.json)
13
- PKG_NAME="${pkg}-${PKG_VERSION}"
27
+ CURR_PKG_TAG="${pkg}-${PKG_VERSION}"
14
28
 
15
- if [[ "${GITHUB_RELEASE_TAG}" == "${PKG_NAME}" ]]; then
16
- gh run cancel ${GITHUB_RUN_ID}
17
- else
18
- continue
29
+ if [[ "${GITHUB_RELEASE_TAG}" == "${CURR_PKG_TAG}" ]]; then
30
+ NO_MATCHES="false"
19
31
  fi
20
32
  done
21
- else
22
- # Check base extension name for tag name
23
- BASE_EXT=$(jq -r .name package.json)
24
- EXT_VERSION=$(jq -r .version package.json)
25
33
 
26
- if [[ "${GITHUB_RELEASE_TAG}" == "${BASE_EXT}-${EXT_VERSION}" ]]; then
27
- echo -e "tag: ${GITHUB_RELEASE_TAG}"
34
+ if [[ "${NO_MATCHES}" == "true" ]]; then
35
+ echo -e "release tag doesn't match any chart tag: ${GITHUB_RELEASE_TAG}. Check your pkg/<!-YOUR-EXT-> folders and corresponding versions to complete the match"
28
36
  gh run cancel ${GITHUB_RUN_ID}
37
+ exit 1
29
38
  fi
30
- fi
39
+ fi
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
+ set -eo pipefail
4
+
3
5
  SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
4
- BASE_DIR="$(
5
- cd $SCRIPT_DIR && cd ../.. &
6
- pwd
7
- )"
6
+ BASE_DIR="$(cd $SCRIPT_DIR && cd ../.. && pwd)"
8
7
  SHELL_DIR=$BASE_DIR/shell/
9
8
  CREATORS_DIR=$BASE_DIR/creators/extension
10
9
  FORCE_PUBLISH_TO_NPM="false"
@@ -65,6 +64,13 @@ function publish() {
65
64
  PUBLISH_ARGS="$PUBLISH_ARGS --tag legacy-v1"
66
65
  fi
67
66
 
67
+ # when testing the workflow, we don't want to actually do an npm publish but only a dry run
68
+ if [ ${DRY_RUN} == "true" ]; then
69
+ PUBLISH_ARGS="$PUBLISH_ARGS --dry-run"
70
+ fi
71
+
72
+ echo "Publish to NPM - arguments ::: ${PUBLISH_ARGS}"
73
+
68
74
  # Make a note of dependency versions, if required
69
75
  node ${SCRIPT_DIR}/record-deps.js
70
76
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
4
- BASE_DIR="$( cd $SCRIPT_DIR && cd ../.. & pwd)"
4
+ BASE_DIR="$(git rev-parse --show-toplevel)"
5
5
  SHELL_DIR=$BASE_DIR/shell
6
6
 
7
7
  echo "Generating typescript definitions"
@@ -12,37 +12,42 @@ mkdir -p ${SHELL_DIR}/tmp
12
12
  echo "Generating ..."
13
13
 
14
14
  # utils
15
- ${BASE_DIR}/node_modules/.bin/tsc shell/utils/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/utils > /dev/null
16
- ${BASE_DIR}/node_modules/.bin/tsc shell/utils/validators/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/utils/validators > /dev/null
17
- ${BASE_DIR}/node_modules/.bin/tsc shell/utils/crypto/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/utils/crypto > /dev/null
15
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/utils/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/utils > /dev/null
16
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/utils/validators/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/utils/validators > /dev/null
17
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/utils/crypto/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/utils/crypto > /dev/null
18
18
 
19
19
  # config
20
- ${BASE_DIR}/node_modules/.bin/tsc shell/config/query-params.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/config > /dev/null
21
- ${BASE_DIR}/node_modules/.bin/tsc shell/config/table-headers.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/config > /dev/null
22
- ${BASE_DIR}/node_modules/.bin/tsc shell/config/types.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/config > /dev/null
23
- ${BASE_DIR}/node_modules/.bin/tsc shell/config/labels-annotations.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/config > /dev/null
20
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/config/query-params.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/config > /dev/null
21
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/config/table-headers.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/config > /dev/null
22
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/config/types.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/config > /dev/null
23
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/config/labels-annotations.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/config > /dev/null
24
24
 
25
- # store
26
- ${BASE_DIR}/node_modules/.bin/tsc shell/store/features.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/store > /dev/null
27
- ${BASE_DIR}/node_modules/.bin/tsc shell/store/prefs.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/store > /dev/null
25
+ # # store
26
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/store/features.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/store > /dev/null
27
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/store/prefs.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/store > /dev/null
28
28
 
29
- # plugins
30
- ${BASE_DIR}/node_modules/.bin/tsc shell/plugins/dashboard-store/normalize.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
31
- ${BASE_DIR}/node_modules/.bin/tsc shell/plugins/dashboard-store/resource-class.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
32
- ${BASE_DIR}/node_modules/.bin/tsc shell/plugins/dashboard-store/classify.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
33
- ${BASE_DIR}/node_modules/.bin/tsc shell/plugins/dashboard-store/actions.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
29
+ # # plugins
30
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/plugins/dashboard-store/normalize.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
31
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/plugins/dashboard-store/resource-class.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
32
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/plugins/dashboard-store/classify.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
33
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/plugins/dashboard-store/actions.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
34
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/plugins/steve/steve-class.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/steve/ > /dev/null
34
35
 
35
- # mixins
36
- ${BASE_DIR}/node_modules/.bin/tsc shell/mixins/create-edit-view/index.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/mixins/create-edit-view > /dev/null
36
+ # # mixins
37
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/mixins/create-edit-view/index.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/mixins/create-edit-view > /dev/null
38
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/mixins/resource-fetch.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/mixins > /dev/null
37
39
 
38
- # models
39
- ${BASE_DIR}/node_modules/.bin/tsc shell/models/namespace.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/models/ > /dev/null
40
- ${BASE_DIR}/node_modules/.bin/tsc shell/models/networking.k8s.io.ingress.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/models/ > /dev/null
40
+ # # models
41
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/models/namespace.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/models/ > /dev/null
42
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/models/networking.k8s.io.ingress.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/models/ > /dev/null
41
43
 
42
- #./node_modules/.bin/tsc shell/plugins/dashboard-store/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store > /dev/null
44
+ #./node_modules/.bin/tsc ${SHELL_DIR}/plugins/dashboard-store/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store
43
45
 
44
46
  # Go through all of the folders and combine by wrapping with 'declare module'
45
47
 
48
+ echo "Contents of ${SHELL_DIR}/tmp after tsc commands:"
49
+ find ${SHELL_DIR}/tmp
50
+
46
51
  echo "Combining type definitions ..."
47
52
 
48
53
  DEST=${SHELL_DIR}/types/shell
package/store/features.js CHANGED
@@ -32,6 +32,7 @@ export const FLEET = create('continuous-delivery', true);
32
32
  export const HARVESTER = create('harvester', true);
33
33
  export const HARVESTER_CONTAINER = create('harvester-baremetal-container-workload', false);
34
34
  export const FLEET_WORKSPACE_BACK = create('provisioningv2-fleet-workspace-back-population', false);
35
+ export const PROVISIONING_PRE_BOOTSTRAP = create('provisioningprebootstrap', false);
35
36
 
36
37
  // Not currently used.. no point defining ones we don't use
37
38
  // export const EMBEDDED_CLUSTER_API = create('embedded-cluster-api', true);