@rancher/shell 2.0.1 → 2.0.2

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.
Files changed (112) hide show
  1. package/assets/translations/en-us.yaml +73 -34
  2. package/assets/translations/zh-hans.yaml +1 -0
  3. package/components/AssignTo.vue +2 -0
  4. package/components/PromptRemove.vue +8 -3
  5. package/components/Questions/index.vue +2 -2
  6. package/components/ResourceDetail/Masthead.vue +1 -0
  7. package/components/auth/RoleDetailEdit.vue +5 -4
  8. package/components/fleet/FleetClusters.vue +0 -3
  9. package/components/form/Members/ClusterPermissionsEditor.vue +1 -1
  10. package/components/form/ProjectMemberEditor.vue +1 -1
  11. package/components/form/ResourceLabeledSelect.vue +11 -3
  12. package/components/form/labeled-select-utils/labeled-select.utils.ts +1 -1
  13. package/components/formatter/CloudCredExpired.vue +69 -0
  14. package/components/formatter/Date.vue +1 -1
  15. package/components/nav/Header.vue +9 -5
  16. package/components/nav/TopLevelMenu.vue +115 -51
  17. package/components/nav/__tests__/TopLevelMenu.test.ts +53 -27
  18. package/config/labels-annotations.js +2 -0
  19. package/config/pagination-table-headers.js +5 -4
  20. package/config/roles.ts +34 -19
  21. package/config/router/navigation-guards/attempt-first-login.js +1 -1
  22. package/config/router/navigation-guards/authentication.js +1 -1
  23. package/config/router/navigation-guards/i18n.js +1 -1
  24. package/config/router/navigation-guards/index.js +2 -1
  25. package/config/router/navigation-guards/load-initial-settings.js +1 -1
  26. package/config/router/navigation-guards/runtime-extension-route.js +31 -0
  27. package/config/router/routes.js +10 -1
  28. package/config/uiplugins.js +130 -61
  29. package/core/plugin.ts +5 -0
  30. package/core/plugins.js +7 -1
  31. package/detail/catalog.cattle.io.app.vue +17 -4
  32. package/detail/fleet.cattle.io.cluster.vue +11 -9
  33. package/detail/fleet.cattle.io.gitrepo.vue +1 -1
  34. package/edit/provisioning.cattle.io.cluster/__tests__/Basics.test.ts +86 -13
  35. package/edit/provisioning.cattle.io.cluster/__tests__/DirectoryConfig.test.ts +3 -134
  36. package/edit/provisioning.cattle.io.cluster/__tests__/rke2.test.ts +209 -0
  37. package/edit/provisioning.cattle.io.cluster/index.vue +8 -4
  38. package/edit/provisioning.cattle.io.cluster/rke2.vue +128 -17
  39. package/edit/provisioning.cattle.io.cluster/tabs/AddOnAdditionalManifest.vue +50 -0
  40. package/edit/provisioning.cattle.io.cluster/tabs/AddOnConfig.vue +29 -64
  41. package/edit/provisioning.cattle.io.cluster/tabs/Basics.vue +42 -3
  42. package/edit/provisioning.cattle.io.cluster/tabs/DirectoryConfig.vue +22 -86
  43. package/edit/provisioning.cattle.io.cluster/tabs/registries/RegistryConfigs.vue +8 -2
  44. package/edit/provisioning.cattle.io.cluster/tabs/registries/__tests__/RegistryConfigs.test.ts +61 -0
  45. package/initialize/entry-helpers.js +4 -21
  46. package/list/provisioning.cattle.io.cluster.vue +56 -5
  47. package/mixins/__tests__/chart.test.ts +4 -1
  48. package/mixins/chart.js +36 -16
  49. package/models/__tests__/apps.deployment.test.ts +93 -0
  50. package/models/apps.deployment.js +18 -4
  51. package/models/catalog.cattle.io.app.js +108 -21
  52. package/models/cloudcredential.js +159 -2
  53. package/models/fleet.cattle.io.gitrepo.js +4 -13
  54. package/models/management.cattle.io.cluster.js +15 -4
  55. package/models/management.cattle.io.user.js +3 -3
  56. package/models/nodedriver.js +5 -0
  57. package/models/provisioning.cattle.io.cluster.js +41 -3
  58. package/package.json +1 -1
  59. package/pages/404.vue +15 -0
  60. package/pages/auth/login.vue +4 -1
  61. package/pages/auth/setup.vue +4 -1
  62. package/pages/c/_cluster/apps/charts/install.vue +2 -1
  63. package/pages/c/_cluster/explorer/__tests__/index.test.ts +1 -1
  64. package/pages/c/_cluster/explorer/index.vue +6 -2
  65. package/pages/c/_cluster/fleet/index.vue +11 -5
  66. package/pages/c/_cluster/manager/cloudCredential/index.vue +68 -4
  67. package/pages/c/_cluster/manager/jwt.authentication/index.vue +10 -4
  68. package/pages/c/_cluster/settings/performance.vue +2 -2
  69. package/pages/c/_cluster/uiplugins/PluginInfoPanel.vue +7 -10
  70. package/pages/c/_cluster/uiplugins/index.vue +28 -18
  71. package/pages/home.vue +2 -13
  72. package/plugins/dashboard-store/actions.js +1 -1
  73. package/plugins/dashboard-store/getters.js +1 -1
  74. package/plugins/steve/__tests__/getters.test.ts +5 -5
  75. package/plugins/steve/getters.js +6 -4
  76. package/plugins/steve/hybrid-class.js +1 -5
  77. package/scripts/extension/bundle +1 -1
  78. package/scripts/extension/helm/charts/ui-plugin-server/Chart.yaml +1 -1
  79. package/scripts/publish-shell.sh +56 -59
  80. package/scripts/test-plugins-build.sh +45 -39
  81. package/scripts/typegen.sh +26 -23
  82. package/store/type-map.js +4 -2
  83. package/types/shell/index.d.ts +10 -0
  84. package/types/store/pagination.types.ts +1 -1
  85. package/utils/cluster.js +9 -0
  86. package/utils/settings.ts +3 -1
  87. package/utils/string.js +9 -0
  88. package/utils/v-sphere.ts +251 -0
  89. package/creators/app/app.package.json +0 -14
  90. package/creators/app/files/.eslintignore +0 -16
  91. package/creators/app/files/.eslintrc.js +0 -173
  92. package/creators/app/files/.gitignore +0 -70
  93. package/creators/app/files/.gitlab-ci.yml +0 -14
  94. package/creators/app/files/.vscode/settings.json +0 -21
  95. package/creators/app/files/babel.config.js +0 -1
  96. package/creators/app/files/tsconfig.json +0 -42
  97. package/creators/app/files/vue.config.js +0 -6
  98. package/creators/app/init +0 -120
  99. package/creators/app/package.json +0 -25
  100. package/creators/pkg/files/.github/workflows/build-extension-catalog.yml +0 -24
  101. package/creators/pkg/files/.github/workflows/build-extension-charts.yml +0 -22
  102. package/creators/pkg/files/babel.config.js +0 -1
  103. package/creators/pkg/files/index.ts +0 -14
  104. package/creators/pkg/files/tsconfig.json +0 -53
  105. package/creators/pkg/files/vue.config.js +0 -1
  106. package/creators/pkg/init +0 -286
  107. package/creators/pkg/package.json +0 -19
  108. package/creators/pkg/pkg.package.json +0 -21
  109. package/creators/pkg/vue-shim.ts +0 -4
  110. package/creators/update/init +0 -56
  111. package/creators/update/package.json +0 -20
  112. package/creators/update/upgrade +0 -56
@@ -8,8 +8,8 @@ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
8
8
  BASE_DIR="$( cd $SCRIPT_DIR && cd ../.. & pwd)"
9
9
  SHELL_DIR=$BASE_DIR/shell/
10
10
  SHELL_VERSION="99.99.99"
11
- DEFAULT_YARN_REGISTRY="https://registry.npmjs.org"
12
- VERDACCIO_YARN_REGISTRY="http://localhost:4873"
11
+ DEFAULT_NPM_REGISTRY="https://registry.npmjs.org/"
12
+ VERDACCIO_NPM_REGISTRY="http://localhost:4873"
13
13
 
14
14
  echo ${SCRIPT_DIR}
15
15
 
@@ -69,11 +69,11 @@ else
69
69
  rm -rf ~/.config/verdaccio/storage/@rancher/*
70
70
  fi
71
71
 
72
- export YARN_REGISTRY=$VERDACCIO_YARN_REGISTRY
72
+ export NPM_REGISTRY=$VERDACCIO_NPM_REGISTRY
73
73
  export NUXT_TELEMETRY_DISABLED=1
74
74
 
75
75
  # Remove test package from previous run, if present
76
- if [ $TEST_PERSIST_BUILD != "true" ]; then
76
+ if [ "${TEST_PERSIST_BUILD}" != "true" ]; then
77
77
  echo "Removing folder ${BASE_DIR}/pkg/test-pkg"
78
78
  rm -rf ${BASE_DIR}/pkg/test-pkg
79
79
  fi
@@ -81,20 +81,34 @@ fi
81
81
  # We need to patch the version number of the shell, otherwise if we are running
82
82
  # with the currently published version, things will fail as those versions
83
83
  # are already published and Verdaccio will check, since it is a read-through cache
84
- sed -i.bak -e "s/\"version\": \"[0-9]*.[0-9]*.[0-9]*\(-alpha\.[0-9]*\|-release[0-9]*.[0-9]*.[0-9]*\|-rc\.[0-9]*\)\{0,1\}\",/\"version\": \"${SHELL_VERSION}\",/g" ${SHELL_DIR}/package.json
85
- rm ${SHELL_DIR}/package.json.bak
84
+ update_version_in_package_json() {
85
+ local package_json_path="$1"
86
+ local version="$2"
86
87
 
87
- # Same as above for Rancher Components
88
- # We might have bumped the version number but its not published yet, so this will fail
89
- sed -i.bak -e "s/\"version\": \"[0-9]*.[0-9]*.[0-9]*\(-alpha\.[0-9]*\|-release[0-9]*.[0-9]*.[0-9]*\|-rc\.[0-9]*\)\{0,1\}\",/\"version\": \"${SHELL_VERSION}\",/g" ${BASE_DIR}/pkg/rancher-components/package.json
88
+ sed -i.bak -e "s/\"version\": \"[0-9]*.[0-9]*.[0-9]*\(-alpha\.[0-9]*\|-release[0-9]*.[0-9]*.[0-9]*\|-rc\.[0-9]*\)\{0,1\}\",/\"version\": \"${version}\",/g" "$package_json_path"
89
+ rm "${package_json_path}.bak"
90
+ }
91
+
92
+ update_version_in_package_json "${SHELL_DIR}/package.json" "${SHELL_VERSION}"
93
+ update_version_in_package_json "${BASE_DIR}/pkg/rancher-components/package.json" "${SHELL_VERSION}"
94
+ update_version_in_package_json "${BASE_DIR}/creators/extension/package.json" "${SHELL_VERSION}"
90
95
 
91
- # Publish shell
92
- echo "Publishing shell packages to local registry"
96
+ # Publish shell pkg (tag is needed as publish-shell is optimized to work with release-shell-pkg workflow)
97
+ echo "Publishing Shell package to local registry"
93
98
  yarn install
99
+ export TAG="shell-pkg-v${SHELL_VERSION}"
100
+ ${SHELL_DIR}/scripts/publish-shell.sh
101
+
102
+ # Publish creators pkg (tag is needed as publish-shell is optimized to work with release-shell-pkg workflow)
103
+ echo "Publishing Creators package to local registry"
104
+ export TAG="creators-pkg-v${SHELL_VERSION}"
94
105
  ${SHELL_DIR}/scripts/publish-shell.sh
95
106
 
96
107
  # Publish rancher components
97
108
  yarn build:lib
109
+
110
+ npm set registry ${VERDACCIO_NPM_REGISTRY}
111
+ yarn config set registry ${VERDACCIO_NPM_REGISTRY}
98
112
  yarn publish:lib
99
113
 
100
114
  # We pipe into cat for cleaner logging - we need to set pipefail
@@ -107,26 +121,18 @@ if [ "${SKIP_STANDALONE}" == "false" ]; then
107
121
 
108
122
  echo "Using temporary directory ${DIR}"
109
123
 
110
- echo "Verifying app creator package"
124
+ echo "Verifying extension creator"
111
125
 
112
- yarn create @rancher/app test-app
113
- pushd test-app
114
- yarn install
126
+ FORCE_COLOR=true yarn create @rancher/extension test-pkg --app-name test-app | cat
115
127
 
116
- echo "Building skeleton app"
128
+ pushd test-app > /dev/null
117
129
 
130
+ yarn install
118
131
  FORCE_COLOR=true yarn build | cat
119
132
 
120
- # Package creator
121
- echo "Verifying package creator package"
122
- yarn create @rancher/pkg test-pkg -i
123
-
124
- echo "Building test package"
125
- FORCE_COLOR=true yarn build-pkg test-pkg | cat
126
-
127
133
  # Add test list component to the test package
128
134
  # Validates rancher-components imports
129
- mkdir pkg/test-pkg/list
135
+ mkdir -p pkg/test-pkg/list
130
136
  cp ${SHELL_DIR}/list/catalog.cattle.io.clusterrepo.vue pkg/test-pkg/list
131
137
 
132
138
  FORCE_COLOR=true yarn build-pkg test-pkg | cat
@@ -134,7 +140,7 @@ if [ "${SKIP_STANDALONE}" == "false" ]; then
134
140
  echo "Cleaning temporary dir"
135
141
  popd > /dev/null
136
142
 
137
- if [ $TEST_PERSIST_BUILD != "true" ]; then
143
+ if [ "${TEST_PERSIST_BUILD}" != "true" ]; then
138
144
  echo "Removing folder ${DIR}"
139
145
  rm -rf ${DIR}
140
146
  fi
@@ -147,15 +153,16 @@ echo "Validating in-tree package"
147
153
 
148
154
  yarn install
149
155
 
150
- if [ $TEST_PERSIST_BUILD != "true" ]; then
156
+ if [ "${TEST_PERSIST_BUILD}" != "true" ]; then
151
157
  echo "Removing folder ./pkg/test-pkg"
152
158
  rm -rf ./pkg/test-pkg
153
159
  fi
154
160
 
155
- yarn create @rancher/pkg test-pkg -t -i
161
+ yarn create @rancher/extension test-pkg -i
156
162
  cp ${SHELL_DIR}/list/catalog.cattle.io.clusterrepo.vue ./pkg/test-pkg/list
157
163
  FORCE_COLOR=true yarn build-pkg test-pkg | cat
158
- if [ $TEST_PERSIST_BUILD != "true" ]; then
164
+
165
+ if [ "${TEST_PERSIST_BUILD}" != "true" ]; then
159
166
  echo "Removing folder ./pkg/test-pkg"
160
167
  rm -rf ./pkg/test-pkg
161
168
  fi
@@ -168,9 +175,9 @@ function clone_repo_test_extension_build() {
168
175
  echo -e "\nSetting up $REPO_NAME repository locally\n"
169
176
 
170
177
  # set registry to default (to install all of the other dependencies)
171
- yarn config set registry ${DEFAULT_YARN_REGISTRY}
178
+ yarn config set registry ${DEFAULT_NPM_REGISTRY}
172
179
 
173
- if [ $TEST_PERSIST_BUILD != "true" ]; then
180
+ if [ "${TEST_PERSIST_BUILD}" != "true" ]; then
174
181
  echo "Removing folder ${BASE_DIR}/$REPO_NAME"
175
182
  rm -rf ${BASE_DIR}/$REPO_NAME
176
183
  fi
@@ -183,7 +190,7 @@ function clone_repo_test_extension_build() {
183
190
  yarn install
184
191
 
185
192
  # set registry to local verdaccio (to install new shell)
186
- yarn config set registry ${VERDACCIO_YARN_REGISTRY}
193
+ yarn config set registry ${VERDACCIO_NPM_REGISTRY}
187
194
 
188
195
  # update package.json to use a specific version of shell
189
196
  sed -i.bak -e "s/\"\@rancher\/shell\": \"[0-9]*.[0-9]*.[0-9]*\",/\"\@rancher\/shell\": \"${SHELL_VERSION}\",/g" package.json
@@ -209,16 +216,15 @@ function clone_repo_test_extension_build() {
209
216
  popd
210
217
 
211
218
  # delete folder
212
- if [ $TEST_PERSIST_BUILD != "true" ]; then
213
- echo "Removing folder ${BASE_DIR}/$REPO_NAME"
214
- rm -rf ${BASE_DIR}/$REPO_NAME
215
- fi
216
- yarn config set registry ${DEFAULT_YARN_REGISTRY}
219
+ echo "Removing folder ${BASE_DIR}/$REPO_NAME"
220
+ rm -rf ${BASE_DIR}/$REPO_NAME
221
+ yarn config set registry ${DEFAULT_NPM_REGISTRY}
217
222
  }
218
223
 
219
224
  # Here we just add the extension that we want to include as a check (all our official extensions should be included here)
220
225
  # Don't forget to add the unit tests exception to clone_repo_test_extension_build function if a new extension has those
221
- clone_repo_test_extension_build "kubewarden-ui" "kubewarden"
222
- clone_repo_test_extension_build "elemental-ui" "elemental"
226
+ # clone_repo_test_extension_build "kubewarden-ui" "kubewarden"
227
+ # clone_repo_test_extension_build "elemental-ui" "elemental"
228
+ # clone_repo_test_extension_build "capi-ui-extension" "capi"
223
229
 
224
- echo "All done"
230
+ echo "All done"
@@ -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,40 @@ 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
34
 
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
35
+ # # mixins
36
+ ${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
37
37
 
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
38
+ # # models
39
+ ${BASE_DIR}/node_modules/.bin/tsc ${SHELL_DIR}/models/namespace.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/models/ > /dev/null
40
+ ${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
41
 
42
- #./node_modules/.bin/tsc shell/plugins/dashboard-store/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store > /dev/null
42
+ #./node_modules/.bin/tsc ${SHELL_DIR}/plugins/dashboard-store/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store
43
43
 
44
44
  # Go through all of the folders and combine by wrapping with 'declare module'
45
45
 
46
+ echo "Contents of ${SHELL_DIR}/tmp after tsc commands:"
47
+ find ${SHELL_DIR}/tmp
48
+
46
49
  echo "Combining type definitions ..."
47
50
 
48
51
  DEST=${SHELL_DIR}/types/shell
@@ -90,4 +93,4 @@ function processDir() {
90
93
 
91
94
  processDir ${SHELL_DIR}/tmp @shell
92
95
 
93
- rm -rf ${SHELL_DIR}/tmp
96
+ rm -rf ${SHELL_DIR}/tmp
package/store/type-map.js CHANGED
@@ -2021,8 +2021,10 @@ function hasCustom(state, rootState, kind, key, fallback) {
2021
2021
  return cache[key];
2022
2022
  }
2023
2023
 
2024
- // Check to see if the custom kind is provided by a plugin
2025
- if (!!rootState.$plugin.getDynamic(kind, key)) {
2024
+ // Check to see if the custom kind is provided by a plugin (ignore booleans)
2025
+ const pluginComponent = rootState.$plugin.getDynamic(kind, key);
2026
+
2027
+ if (typeof pluginComponent !== 'boolean' && !!pluginComponent) {
2026
2028
  cache[key] = true;
2027
2029
 
2028
2030
  return cache[key];
@@ -158,6 +158,9 @@ export namespace CLUSTER_BADGE {
158
158
  export const ICON_TEXT: string;
159
159
  }
160
160
  export const SYSTEM_LABELS: string[];
161
+ export namespace CLOUD_CREDENTIALS {
162
+ const EXPIRATION: string;
163
+ }
161
164
  }
162
165
 
163
166
  // @shell/config/query-params
@@ -3421,6 +3424,7 @@ export function filterHiddenLocalCluster(mgmtClusters: any, store: any): any;
3421
3424
  * @example smallIdentifier('word-wide-web') => 'www'
3422
3425
  */
3423
3426
  export function abbreviateClusterName(input: string): string;
3427
+ export function labelForAddon(name: any, configuration?: boolean): any;
3424
3428
  }
3425
3429
 
3426
3430
  // @shell/utils/color
@@ -4280,6 +4284,12 @@ export function isIpv4(ip: any): boolean;
4280
4284
  export function sanitizeKey(k: any): any;
4281
4285
  export function sanitizeValue(v: any): any;
4282
4286
  export function sanitizeIP(v: any): any;
4287
+ /**
4288
+ * Return the string `<x> / <y>`
4289
+ *
4290
+ * Each param should be a number, otherwise `?` is used
4291
+ */
4292
+ export function xOfy(x: any, y: any): string;
4283
4293
  export namespace CHARSET {
4284
4294
  export { num as NUMERIC };
4285
4295
  export const NO_VOWELS: string;
@@ -227,7 +227,7 @@ export class PaginationParamFilter extends PaginationParam {
227
227
  /**
228
228
  * Convenience method when you just want an instance of {@link PaginationParamFilter} with a simple `filter=x=y` param
229
229
  */
230
- static createSingleField(field: { field?: string; value: string; equals?: boolean; }): PaginationParam {
230
+ static createSingleField(field: { field?: string; value: string; equals?: boolean; exact?: boolean }): PaginationParam {
231
231
  return new PaginationParamFilter({ fields: [new PaginationFilterField(field)] });
232
232
  }
233
233
 
package/utils/cluster.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import semver from 'semver';
2
+ import { camelToTitle } from '@shell/utils/string';
2
3
  import { CAPI } from '@shell/config/labels-annotations';
3
4
  import { MANAGEMENT, VIRTUAL_HARVESTER_PROVIDER } from '@shell/config/types';
4
5
  import { SETTING } from '@shell/config/settings';
@@ -90,3 +91,11 @@ export function abbreviateClusterName(input) {
90
91
 
91
92
  return result;
92
93
  }
94
+
95
+ export function labelForAddon(name, configuration = true) {
96
+ const addon = camelToTitle(name.replace(/^(rke|rke2|rancher)-/, ''));
97
+ const fallback = `${ configuration ? '' : 'Add-on: ' }${ addon }`;
98
+ const key = `cluster.addonChart."${ name }"${ configuration ? '.configuration' : '.label' }`;
99
+
100
+ return this.$store.getters['i18n/withFallback'](key, null, fallback);
101
+ }
package/utils/settings.ts CHANGED
@@ -102,5 +102,7 @@ export const getPerformanceSetting = (rootGetters: Record<string, (arg0: string,
102
102
  }
103
103
 
104
104
  // Start with the default and overwrite the values from the setting - ensures we have defaults for newly added options
105
- return Object.assign(DEFAULT_PERF_SETTING, perfSetting || {});
105
+ const safeDefaults = Object.assign({}, DEFAULT_PERF_SETTING);
106
+
107
+ return Object.assign(safeDefaults, perfSetting || {});
106
108
  };
package/utils/string.js CHANGED
@@ -321,3 +321,12 @@ export function sanitizeValue(v) {
321
321
  export function sanitizeIP(v) {
322
322
  return (v || '').replace(/[^a-z0-9.:_-]/ig, '');
323
323
  }
324
+
325
+ /**
326
+ * Return the string `<x> / <y>`
327
+ *
328
+ * Each param should be a number, otherwise `?` is used
329
+ */
330
+ export function xOfy(x, y) {
331
+ return `${ typeof x === 'number' ? x : '?' }/${ typeof y === 'number' ? y : '?' }`;
332
+ }
@@ -0,0 +1,251 @@
1
+ import merge from 'lodash/merge';
2
+ import { SECRET } from '@shell/config/types';
3
+
4
+ type Rke2Component = {
5
+ versionInfo: any;
6
+ userChartValues: any;
7
+ chartVersionKey: (chartName: string) => string;
8
+ value: any;
9
+ isEdit: boolean;
10
+ $store: any,
11
+ }
12
+
13
+ type SecretDetails = {
14
+ generateName: string,
15
+ upstreamClusterName: string,
16
+ upstreamNamespace: string,
17
+ downstreamName: string,
18
+ downstreamNamespace: string,
19
+ json?: object,
20
+ }
21
+ type Values = any;
22
+
23
+ type ChartValues = {
24
+ defaultValues: Values,
25
+ userValues: Values,
26
+ combined: Values,
27
+ };
28
+
29
+ const rootGenerateName = 'vsphere-secret-';
30
+
31
+ type SecretJson = any;
32
+
33
+ class VSphereUtils {
34
+ private async findSecret(
35
+ { $store }: Rke2Component, {
36
+ generateName, upstreamClusterName, upstreamNamespace, downstreamName, downstreamNamespace
37
+ }: SecretDetails): Promise<SecretJson | undefined> {
38
+ const secrets = await $store.dispatch('management/request', { url: `/v1/${ SECRET }/${ upstreamNamespace }?filter=metadata.name=${ generateName }` });
39
+
40
+ const applicableSecret = secrets.data?.filter((s: any) => {
41
+ return s.metadata.annotations['provisioning.cattle.io/sync-target-namespace'] === downstreamNamespace &&
42
+ s.metadata.annotations['provisioning.cattle.io/sync-target-name'] === downstreamName &&
43
+ s.metadata.annotations['rke.cattle.io/object-authorized-for-clusters'].includes(upstreamClusterName);
44
+ });
45
+
46
+ if (applicableSecret.length > 1) {
47
+ return Promise.reject(new Error(`Found multiple matching secrets (${ upstreamNamespace }/${ upstreamNamespace } for ${ upstreamClusterName }), this will cause synchronizing mishaps. Consider removing stale secrets from old clusters`));
48
+ }
49
+
50
+ return applicableSecret[0];
51
+ }
52
+
53
+ private async findOrCreateSecret(
54
+ rke2Component: Rke2Component,
55
+ {
56
+ generateName, upstreamClusterName, upstreamNamespace, downstreamName, downstreamNamespace, json
57
+ }: SecretDetails
58
+ ) {
59
+ const { $store } = rke2Component;
60
+
61
+ const secretJson = await this.findSecret(rke2Component, {
62
+ generateName,
63
+ upstreamClusterName,
64
+ upstreamNamespace,
65
+ downstreamName,
66
+ downstreamNamespace
67
+ }) || json;
68
+
69
+ return await $store.dispatch('management/create', secretJson);
70
+ }
71
+
72
+ private findChartValues({
73
+ versionInfo,
74
+ userChartValues,
75
+ chartVersionKey,
76
+ }: Rke2Component, chartName: string): ChartValues | undefined {
77
+ const chartValues = versionInfo[chartName]?.values;
78
+
79
+ if (!chartValues) {
80
+ return;
81
+ }
82
+ const userValues = userChartValues[chartVersionKey(chartName)];
83
+
84
+ return {
85
+ defaultValues: chartValues,
86
+ userValues,
87
+ combined: merge({}, chartValues || {}, userValues || {})
88
+ };
89
+ }
90
+
91
+ /**
92
+ * Create upstream vsphere cpi secret to sync downstream
93
+ */
94
+ async handleVsphereCpiSecret(rke2Component: Rke2Component) {
95
+ const generateName = `${ rootGenerateName }cpi-`;
96
+ const downstreamName = 'rancher-vsphere-cpi-credentials';
97
+ const downstreamNamespace = 'kube-system';
98
+ const { value } = rke2Component;
99
+
100
+ // check values for cpi chart has 'use our method' checkbox
101
+ const { userValues, combined } = this.findChartValues(rke2Component, 'rancher-vsphere-cpi') || {};
102
+
103
+ if (!combined?.vCenter?.credentialsSecret?.generate) {
104
+ if (userValues?.vCenter?.username) {
105
+ userValues.vCenter.username = '';
106
+ }
107
+ if (userValues?.vCenter?.password) {
108
+ userValues.vCenter.password = '';
109
+ }
110
+
111
+ return;
112
+ }
113
+
114
+ // find values needed in cpi chart value - https://github.com/rancher/vsphere-charts/blob/main/charts/rancher-vsphere-cpi/questions.yaml#L16-L42
115
+ const { username, password, host } = combined.vCenter;
116
+
117
+ if (!username || !password || !host) {
118
+ throw new Error('vSphere CPI username, password and host are all required when generating a new secret');
119
+ }
120
+
121
+ // create secret as per https://github.com/rancher/vsphere-charts/blob/main/charts/rancher-vsphere-cpi/templates/secret.yaml
122
+ const upstreamClusterName = value.metadata.name;
123
+ const upstreamNamespace = value.metadata.namespace;
124
+ const secret = await this.findOrCreateSecret(rke2Component, {
125
+ generateName,
126
+ upstreamClusterName,
127
+ upstreamNamespace,
128
+ downstreamName,
129
+ downstreamNamespace,
130
+ json: {
131
+ type: SECRET,
132
+ metadata: {
133
+ namespace: upstreamNamespace,
134
+ generateName,
135
+ labels: {
136
+ 'vsphere-cpi-infra': 'secret',
137
+ component: 'rancher-vsphere-cpi-cloud-controller-manager'
138
+ },
139
+ annotations: {
140
+ 'provisioning.cattle.io/sync-target-namespace': downstreamNamespace,
141
+ 'provisioning.cattle.io/sync-target-name': downstreamName,
142
+ 'rke.cattle.io/object-authorized-for-clusters': upstreamClusterName,
143
+ 'provisioning.cattle.io/sync-bootstrap': 'true'
144
+ }
145
+ },
146
+ }
147
+ });
148
+
149
+ secret.setData(`${ host }.username`, username);
150
+ secret.setData(`${ host }.password`, password);
151
+
152
+ await secret.save();
153
+
154
+ // reset cpi chart values
155
+ if (!userValues.vCenter.credentialsSecret) {
156
+ userValues.vCenter.credentialsSecret = {};
157
+ }
158
+ userValues.vCenter.credentialsSecret.generate = false;
159
+ userValues.vCenter.credentialsSecret.name = downstreamName;
160
+ userValues.vCenter.username = '';
161
+ userValues.vCenter.password = '';
162
+ }
163
+
164
+ /**
165
+ * Create upstream vsphere csi secret to sync downstream
166
+ */
167
+ async handleVsphereCsiSecret(rke2Component: Rke2Component) {
168
+ const generateName = `${ rootGenerateName }csi-`;
169
+ const downstreamName = 'rancher-vsphere-csi-credentials';
170
+ const downstreamNamespace = 'kube-system';
171
+ const { value } = rke2Component;
172
+
173
+ // check values for cpi chart has 'use our method' checkbox
174
+ const { userValues, combined } = this.findChartValues(rke2Component, 'rancher-vsphere-csi') || {};
175
+
176
+ if (!combined?.vCenter?.configSecret?.generate) {
177
+ if (userValues?.vCenter?.username) {
178
+ userValues.vCenter.username = '';
179
+ }
180
+ if (userValues?.vCenter?.password) {
181
+ userValues.vCenter.password = '';
182
+ }
183
+
184
+ return;
185
+ }
186
+
187
+ // find values needed in cpi chart value - https://github.com/rancher/vsphere-charts/blob/main/charts/rancher-vsphere-csi/questions.yaml#L1-L36
188
+ const {
189
+ username, password, host, datacenters, port, insecureFlag
190
+ } = combined.vCenter;
191
+
192
+ if (!username || !password || !host || !datacenters) {
193
+ throw new Error('vSphere CSI username, password, host and datacenters are all required when generating a new secret');
194
+ }
195
+
196
+ // This is a copy of https://github.com/rancher/vsphere-charts/blob/a5c99d716df960dc50cf417d9ecffad6b55ca0ad/charts/rancher-vsphere-csi/values.yaml#L12-L21
197
+ // Which makes it's way into the secret via https://github.com/rancher/vsphere-charts/blob/main/charts/rancher-vsphere-csi/templates/secret.yaml#L8
198
+ let configTemplateString = ' [Global]\n cluster-id = {{ required \".Values.vCenter.clusterId must be provided\" (default .Values.vCenter.clusterId .Values.global.cattle.clusterId) | quote }}\n user = {{ .Values.vCenter.username | quote }}\n password = {{ .Values.vCenter.password | quote }}\n port = {{ .Values.vCenter.port | quote }}\n insecure-flag = {{ .Values.vCenter.insecureFlag | quote }}\n\n [VirtualCenter {{ .Values.vCenter.host | quote }}]\n datacenters = {{ .Values.vCenter.datacenters | quote }}';
199
+
200
+ configTemplateString = configTemplateString.replace('{{ required \".Values.vCenter.clusterId must be provided\" (default .Values.vCenter.clusterId .Values.global.cattle.clusterId) | quote }}', `"{{clusterId}}"`);
201
+ configTemplateString = configTemplateString.replace('{{ .Values.vCenter.username | quote }}', `"${ username }"`);
202
+ configTemplateString = configTemplateString.replace('{{ .Values.vCenter.password | quote }}', `"${ password }"`);
203
+ configTemplateString = configTemplateString.replace('{{ .Values.vCenter.port | quote }}', `"${ port }"`);
204
+ configTemplateString = configTemplateString.replace('{{ .Values.vCenter.insecureFlag | quote }}', `"${ insecureFlag }"`);
205
+ configTemplateString = configTemplateString.replace('{{ .Values.vCenter.host | quote }}', `"${ host }"`);
206
+ configTemplateString = configTemplateString.replace('{{ .Values.vCenter.datacenters | quote }}', `"${ datacenters }"`);
207
+ // create secret as per https://github.com/rancher/vsphere-charts/blob/main/charts/rancher-vsphere-csi/templates/secret.yaml
208
+ const upstreamClusterName = value.metadata.name;
209
+ const upstreamNamespace = value.metadata.namespace;
210
+
211
+ const secret = await this.findOrCreateSecret(rke2Component, {
212
+ generateName,
213
+ upstreamClusterName,
214
+ upstreamNamespace,
215
+ downstreamName,
216
+ downstreamNamespace,
217
+ json: {
218
+ type: SECRET,
219
+ metadata: {
220
+ namespace: upstreamNamespace,
221
+ generateName,
222
+ annotations: {
223
+ 'provisioning.cattle.io/sync-target-namespace': downstreamNamespace,
224
+ 'provisioning.cattle.io/sync-target-name': downstreamName,
225
+ 'rke.cattle.io/object-authorized-for-clusters': upstreamClusterName,
226
+ 'provisioning.cattle.io/sync-bootstrap': 'true'
227
+ }
228
+ },
229
+ }
230
+ });
231
+
232
+ secret.setData(`csi-vsphere.conf`, configTemplateString);
233
+
234
+ await secret.save();
235
+
236
+ // reset csi chart values
237
+ if (!userValues.vCenter.configSecret) {
238
+ userValues.vCenter.configSecret = {};
239
+ }
240
+ userValues.vCenter.configSecret.generate = false;
241
+ userValues.vCenter.configSecret.name = downstreamName;
242
+ userValues.vCenter.username = '';
243
+ userValues.vCenter.password = '';
244
+ userValues.vCenter.host = '';
245
+ userValues.vCenter.datacenters = '';
246
+ }
247
+ }
248
+
249
+ const utils = new VSphereUtils();
250
+
251
+ export default utils;
@@ -1,14 +0,0 @@
1
- {
2
- "name": "NAME",
3
- "version": "0.1.0",
4
- "private": false,
5
- "engines": {
6
- "node": ">=12"
7
- },
8
- "dependencies": {},
9
- "resolutions": {
10
- "**/webpack": "4",
11
- "@types/node": "^16",
12
- "glob": "7.2.3"
13
- }
14
- }
@@ -1,16 +0,0 @@
1
- assets/fonts
2
- coverage
3
- .nyc_output
4
- node_modules/
5
- .npm
6
- .eslintcache
7
- .env
8
- .cache
9
- .next
10
- dist
11
- dist-pkg
12
- .DS_Store
13
- dynamic-importer.js
14
- ksconfig.json
15
- shell/utils/dynamic-importer.js
16
- shell/assets/fonts