@rancher/shell 0.3.4 → 0.3.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.
Files changed (289) hide show
  1. package/assets/images/providers/outscale.svg +19 -0
  2. package/assets/styles/app.scss +1 -1
  3. package/assets/styles/base/_basic.scss +18 -0
  4. package/assets/styles/base/_mixins.scss +0 -11
  5. package/assets/styles/base/_variables.scss +2 -4
  6. package/assets/styles/fonts/_fontstack.scss +11 -11
  7. package/assets/styles/global/_button.scss +12 -2
  8. package/assets/styles/vendor/vue-js-modal.scss +3 -3
  9. package/assets/translations/en-us.yaml +113 -22
  10. package/assets/translations/zh-hans.yaml +113 -24
  11. package/babel.config.js +13 -0
  12. package/chart/gatekeeper.vue +78 -0
  13. package/chart/istio.vue +135 -112
  14. package/chart/logging/index.vue +13 -4
  15. package/chart/monitoring/index.vue +15 -5
  16. package/chart/monitoring/steps/uninstall-v1.vue +2 -2
  17. package/chart/rancher-backup/index.vue +10 -3
  18. package/cloud-credential/aws.vue +1 -1
  19. package/cloud-credential/digitalocean.vue +1 -1
  20. package/cloud-credential/gcp.vue +1 -1
  21. package/cloud-credential/generic.vue +2 -2
  22. package/cloud-credential/linode.vue +1 -1
  23. package/cloud-credential/pnap.vue +1 -1
  24. package/components/ActionMenu.vue +3 -4
  25. package/components/AssignTo.vue +1 -1
  26. package/components/AsyncButton.vue +1 -1
  27. package/components/BannerGraphic.vue +1 -1
  28. package/components/BrandImage.vue +1 -4
  29. package/components/ButtonDropdown.vue +2 -3
  30. package/components/Carousel.vue +85 -37
  31. package/components/ChartPsp.vue +76 -0
  32. package/components/CruResource.vue +6 -2
  33. package/components/DashboardMetrics.vue +12 -10
  34. package/components/DetailText.vue +1 -1
  35. package/components/DisableAuthProviderModal.vue +1 -1
  36. package/components/EmberPage.vue +1 -1
  37. package/components/EtcdInfoBanner.vue +12 -7
  38. package/components/ExplorerMembers.vue +101 -6
  39. package/components/ExplorerProjectsNamespaces.vue +46 -3
  40. package/components/FileDiff.vue +6 -7
  41. package/components/GrafanaDashboard.vue +27 -23
  42. package/components/LazyImage.vue +10 -12
  43. package/components/LogItem.vue +1 -1
  44. package/components/Markdown.vue +1 -1
  45. package/components/PromptRemove.vue +2 -2
  46. package/components/PromptRestore.vue +1 -1
  47. package/components/ResourceDetail/Masthead.vue +16 -0
  48. package/components/ResourceDetail/index.vue +21 -4
  49. package/components/ResourceList/index.vue +1 -1
  50. package/components/ResourceTable.vue +4 -1
  51. package/components/SingleClusterInfo.vue +2 -2
  52. package/components/SortableTable/THead.vue +1 -1
  53. package/components/SortableTable/index.vue +28 -13
  54. package/components/SortableTable/selection.js +58 -50
  55. package/components/Wizard.vue +4 -2
  56. package/components/__tests__/AsyncButton.test.ts +3 -1
  57. package/components/__tests__/ChartPsp.test.ts +75 -0
  58. package/components/__tests__/CruResource.test.ts +3 -1
  59. package/components/auth/Principal.vue +1 -1
  60. package/components/auth/RoleDetailEdit.vue +2 -2
  61. package/components/fleet/FleetBundles.vue +3 -1
  62. package/components/fleet/FleetClusters.vue +1 -2
  63. package/components/fleet/FleetIntro.vue +9 -1
  64. package/components/fleet/FleetNoWorkspaces.vue +62 -0
  65. package/components/fleet/FleetSummary.vue +7 -1
  66. package/components/form/HookOption.vue +14 -10
  67. package/components/form/LabeledSelect.vue +14 -11
  68. package/components/form/Labels.vue +32 -27
  69. package/components/form/MatchExpressions.vue +19 -4
  70. package/components/form/Members/ClusterPermissionsEditor.vue +32 -7
  71. package/components/form/NameNsDescription.vue +32 -46
  72. package/components/form/ProjectMemberEditor.vue +46 -21
  73. package/components/form/ResourceSelector.vue +1 -1
  74. package/components/form/SecretSelector.vue +5 -1
  75. package/components/form/ServiceNameSelect.vue +1 -1
  76. package/components/form/SimpleSecretSelector.vue +9 -9
  77. package/components/form/Tolerations.vue +4 -1
  78. package/components/form/ValueFromResource.vue +14 -9
  79. package/components/form/WorkloadPorts.vue +2 -2
  80. package/components/form/__tests__/LabeledSelect.test.ts +138 -0
  81. package/components/form/__tests__/NameNsDescription.ts +59 -0
  82. package/components/formatter/InternalExternalIP.vue +6 -0
  83. package/components/formatter/InvolvedObjectLink.vue +54 -0
  84. package/components/formatter/Link.vue +20 -4
  85. package/components/formatter/LinkName.vue +6 -1
  86. package/components/formatter/ServiceTargets.vue +1 -1
  87. package/components/formatter/WorkloadHealthScale.vue +8 -2
  88. package/components/nav/Group.vue +2 -2
  89. package/components/nav/NamespaceFilter.vue +23 -11
  90. package/components/nav/TopLevelMenu.vue +2 -4
  91. package/components/nav/Type.vue +1 -1
  92. package/components/nav/WorkspaceSwitcher.vue +46 -5
  93. package/components/nuxt/nuxt-build-indicator.vue +143 -0
  94. package/components/nuxt/nuxt-child.js +122 -0
  95. package/components/nuxt/nuxt-error.vue +98 -0
  96. package/components/nuxt/nuxt-link.client.js +98 -0
  97. package/components/nuxt/nuxt-link.server.js +16 -0
  98. package/components/nuxt/nuxt-loading.vue +154 -0
  99. package/components/nuxt/nuxt.js +101 -0
  100. package/config/labels-annotations.js +17 -0
  101. package/config/middleware.js +12 -0
  102. package/config/product/auth.js +3 -2
  103. package/config/product/explorer.js +34 -6
  104. package/config/product/fleet.js +2 -0
  105. package/config/query-params.js +1 -0
  106. package/config/router.js +414 -0
  107. package/config/store.js +181 -0
  108. package/config/table-headers.js +54 -12
  109. package/config/types.js +18 -8
  110. package/config/uiplugins.js +30 -0
  111. package/content/docs/en-us/whats-new.md +10 -0
  112. package/content/docs/zh-hans/whats-new.md +11 -1
  113. package/core/plugin-routes.ts +23 -0
  114. package/core/plugin.ts +4 -2
  115. package/core/types.ts +258 -1
  116. package/creators/app/app.package.json +2 -1
  117. package/creators/app/files/.eslintrc.js +1 -1
  118. package/creators/app/files/babel.config.js +1 -18
  119. package/creators/app/files/tsconfig.json +0 -1
  120. package/creators/app/files/vue.config.js +6 -0
  121. package/creators/app/init +5 -5
  122. package/creators/pkg/files/.github/workflows/build-extension.yml +110 -0
  123. package/creators/pkg/files/tsconfig.json +0 -1
  124. package/creators/pkg/init +35 -4
  125. package/creators/pkg/pkg.package.json +3 -3
  126. package/creators/update/init +1 -1
  127. package/detail/constraints.gatekeeper.sh.constraint.vue +34 -17
  128. package/detail/fleet.cattle.io.clustergroup.vue +7 -1
  129. package/detail/fleet.cattle.io.gitrepo.vue +19 -11
  130. package/detail/harvesterhci.io.management.cluster.vue +3 -3
  131. package/detail/provisioning.cattle.io.cluster.vue +54 -12
  132. package/detail/workload/index.vue +3 -3
  133. package/dialog/AddClusterMemberDialog.vue +1 -1
  134. package/dialog/AddProjectMemberDialog.vue +2 -2
  135. package/dialog/AddonConfigConfirmationDialog.vue +27 -15
  136. package/dialog/DiagnosticTimingsDialog.vue +1 -1
  137. package/dialog/ForceMachineRemoveDialog.vue +1 -1
  138. package/dialog/GenericPrompt.vue +18 -6
  139. package/dialog/RotateEncryptionKeyDialog.vue +1 -1
  140. package/dialog/SaveAsRKETemplateDialog.vue +1 -1
  141. package/dialog/ScaleMachineDownDialog.vue +1 -1
  142. package/edit/auth/github.vue +8 -8
  143. package/edit/auth/googleoauth.vue +5 -5
  144. package/edit/auth/ldap/index.vue +1 -1
  145. package/edit/auth/oidc.vue +1 -1
  146. package/edit/auth/saml.vue +1 -1
  147. package/edit/cis.cattle.io.clusterscan.vue +1 -1
  148. package/edit/fleet.cattle.io.clustergroup.vue +6 -4
  149. package/edit/fleet.cattle.io.gitrepo.vue +32 -4
  150. package/edit/helm.cattle.io.projecthelmchart.vue +5 -1
  151. package/edit/logging.banzaicloud.io.output/index.vue +18 -5
  152. package/edit/logging.banzaicloud.io.output/providers/loki.vue +1 -0
  153. package/edit/management.cattle.io.fleetworkspace.vue +141 -6
  154. package/edit/management.cattle.io.podsecurityadmissionconfigurationtemplate.vue +4 -1
  155. package/edit/management.cattle.io.setting.vue +1 -1
  156. package/edit/monitoring.coreos.com.alertmanagerconfig/types/webhook.vue +2 -2
  157. package/edit/monitoring.coreos.com.receiver/tls.vue +18 -18
  158. package/edit/monitoring.coreos.com.receiver/types/webhook.banner.vue +4 -4
  159. package/edit/monitoring.coreos.com.receiver/types/webhook.vue +1 -1
  160. package/edit/namespace.vue +14 -10
  161. package/edit/networking.k8s.io.networkpolicy/PolicyRuleTarget.vue +126 -45
  162. package/edit/networking.k8s.io.networkpolicy/index.vue +1 -1
  163. package/edit/provisioning.cattle.io.cluster/MachinePool.vue +21 -4
  164. package/edit/provisioning.cattle.io.cluster/RegistryConfigs.vue +1 -0
  165. package/edit/provisioning.cattle.io.cluster/__tests__/rke2.test.ts +202 -2
  166. package/edit/provisioning.cattle.io.cluster/import.vue +23 -25
  167. package/edit/provisioning.cattle.io.cluster/rke2.vue +344 -102
  168. package/edit/resources.cattle.io.backup.vue +1 -1
  169. package/edit/service.vue +1 -1
  170. package/edit/storage.k8s.io.storageclass/provisioners/driver.harvesterhci.io.vue +2 -2
  171. package/edit/workload/__tests__/Job.test.ts +3 -1
  172. package/edit/workload/index.vue +8 -3
  173. package/edit/workload/mixins/workload.js +22 -7
  174. package/edit/workload/storage/Mount.vue +3 -3
  175. package/initialize/App.js +206 -0
  176. package/initialize/client.js +863 -0
  177. package/initialize/index.js +364 -0
  178. package/layouts/default.vue +7 -3
  179. package/layouts/standalone.vue +13 -0
  180. package/list/catalog.cattle.io.clusterrepo.vue +1 -0
  181. package/list/fleet.cattle.io.bundle.vue +6 -3
  182. package/list/fleet.cattle.io.clusterregistrationtoken.vue +3 -1
  183. package/list/fleet.cattle.io.gitrepo.vue +44 -5
  184. package/list/management.cattle.io.fleetworkspace.vue +45 -0
  185. package/list/node.vue +69 -16
  186. package/list/provisioning.cattle.io.cluster.vue +30 -1
  187. package/list/rbac.authorization.k8s.io.clusterrolebinding.vue +48 -0
  188. package/list/workload.vue +6 -4
  189. package/machine-config/azure.vue +97 -38
  190. package/middleware/authenticated.js +34 -0
  191. package/mixins/chart.js +101 -2
  192. package/mixins/fetch.client.js +95 -0
  193. package/mixins/fetch.server.js +73 -0
  194. package/mixins/labeled-form-element.ts +2 -2
  195. package/mixins/resource-fetch.js +2 -2
  196. package/models/apps.statefulset.js +28 -0
  197. package/models/cluster/node.js +23 -2
  198. package/models/cluster.x-k8s.io.machine.js +4 -2
  199. package/models/clusterroletemplatebinding.js +7 -0
  200. package/models/constraints.gatekeeper.sh.constraint.js +46 -0
  201. package/models/fleet.cattle.io.cluster.js +19 -10
  202. package/models/fleet.cattle.io.gitrepo.js +7 -2
  203. package/models/management.cattle.io.cluster.js +1 -1
  204. package/models/management.cattle.io.fleetworkspace.js +12 -0
  205. package/models/management.cattle.io.gitreporestriction.js +5 -0
  206. package/models/management.cattle.io.podsecurityadmissionconfigurationtemplate.js +3 -0
  207. package/models/pod.js +4 -0
  208. package/models/provisioning.cattle.io.cluster.js +7 -5
  209. package/models/rbac.authorization.k8s.io.clusterrolebinding.js +16 -0
  210. package/models/rbac.authorization.k8s.io.rolebinding.js +16 -0
  211. package/package.json +13 -21
  212. package/pages/auth/setup.vue +2 -2
  213. package/pages/c/_cluster/apps/charts/__tests__/install.helper.test.ts +33 -0
  214. package/pages/c/_cluster/apps/charts/chart.vue +4 -4
  215. package/pages/c/_cluster/apps/charts/install.helpers.js +26 -0
  216. package/pages/c/_cluster/apps/charts/install.vue +98 -102
  217. package/pages/c/_cluster/explorer/EventsTable.vue +5 -19
  218. package/pages/c/_cluster/explorer/index.vue +29 -25
  219. package/pages/c/_cluster/explorer/tools/index.vue +8 -8
  220. package/pages/c/_cluster/fleet/index.vue +95 -34
  221. package/pages/c/_cluster/gatekeeper/index.vue +1 -1
  222. package/pages/c/_cluster/istio/index.vue +5 -5
  223. package/pages/c/_cluster/manager/cloudCredential/index.vue +1 -1
  224. package/pages/c/_cluster/monitoring/index.vue +7 -0
  225. package/pages/c/_cluster/uiplugins/InstallDialog.vue +8 -8
  226. package/pages/c/_cluster/uiplugins/PluginInfoPanel.vue +20 -7
  227. package/pages/c/_cluster/uiplugins/index.vue +49 -17
  228. package/pages/diagnostic.vue +32 -25
  229. package/pages/home.vue +9 -4
  230. package/pages/index.vue +10 -1
  231. package/pages/rio/mesh.vue +1 -2
  232. package/pkg/tsconfig.json +0 -1
  233. package/plugins/clean-html-directive.js +34 -0
  234. package/plugins/dashboard-store/actions.js +32 -9
  235. package/plugins/dashboard-store/index.js +1 -1
  236. package/plugins/dashboard-store/mutations.js +5 -2
  237. package/plugins/dashboard-store/resource-class.js +8 -1
  238. package/plugins/plugin.js +0 -14
  239. package/plugins/portal-vue.js +4 -0
  240. package/plugins/steve/mutations.js +3 -2
  241. package/plugins/steve/steve-description-class.js +5 -1
  242. package/plugins/steve/subscribe.js +63 -54
  243. package/plugins/steve-create-worker.js +14 -0
  244. package/promptRemove/management.cattle.io.globalrole.vue +2 -2
  245. package/promptRemove/management.cattle.io.project.vue +2 -2
  246. package/promptRemove/management.cattle.io.roletemplate.vue +2 -2
  247. package/promptRemove/pod.vue +1 -1
  248. package/public/index.html +65 -0
  249. package/rancher-components/components/Banner/Banner.test.ts +7 -1
  250. package/rancher-components/components/Banner/Banner.vue +2 -1
  251. package/rancher-components/components/Form/Checkbox/Checkbox.vue +2 -0
  252. package/rancher-components/components/Form/Radio/RadioButton.test.ts +31 -0
  253. package/rancher-components/components/Form/Radio/RadioButton.vue +14 -3
  254. package/scripts/build-pkg.sh +1 -0
  255. package/scripts/clean +6 -0
  256. package/scripts/extension/bundle +58 -0
  257. package/scripts/extension/helmpatch +89 -0
  258. package/scripts/extension/publish +333 -0
  259. package/scripts/serve-pkgs +6 -2
  260. package/scripts/test-plugins-build.sh +4 -0
  261. package/store/__tests__/index.test.ts +110 -0
  262. package/store/index.js +145 -58
  263. package/store/type-map.js +6 -2
  264. package/tsconfig.default.json +36 -0
  265. package/tsconfig.json +23 -0
  266. package/types/rancher/index.d.ts +2 -0
  267. package/types/shell/index.d.ts +466 -320
  268. package/utils/__tests__/grafana.test.ts +44 -0
  269. package/utils/__tests__/string.test.ts +12 -0
  270. package/utils/auth.js +65 -0
  271. package/utils/axios.js +190 -0
  272. package/utils/cookie-universal-nuxt.js +10 -0
  273. package/utils/dom.js +15 -0
  274. package/utils/grafana.js +35 -16
  275. package/utils/monitoring.js +2 -1
  276. package/utils/nuxt.js +659 -0
  277. package/utils/position.js +5 -8
  278. package/utils/router.scrollBehavior.js +80 -0
  279. package/utils/select.js +1 -3
  280. package/utils/socket.js +1 -0
  281. package/utils/string.js +13 -0
  282. package/utils/time.js +9 -0
  283. package/vue.config.js +690 -0
  284. package/chart/rancher-alerting-drivers.vue +0 -53
  285. package/chart/rancher-gatekeeper.vue +0 -37
  286. package/creators/app/files/nuxt.config.js +0 -6
  287. package/models/management.cattle.io.podsecurityadmissionconfigurationtemplate.ts +0 -4
  288. package/nuxt.config.js +0 -798
  289. package/plugins/dashboard-store/extensions.js +0 -22
@@ -0,0 +1,333 @@
1
+ #!/usr/bin/env bash
2
+
3
+ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
4
+ BASE_DIR="$(pwd)"
5
+
6
+ CYAN="\033[96m"
7
+ YELLOW="\033[93m"
8
+ RESET="\033[0m"
9
+ BOLD="\033[1m"
10
+ NORMAL="\033[22m"
11
+ CHECK="\xE2\x9C\x94"
12
+
13
+ PUSH=""
14
+ REGISTRY=""
15
+ REGISTRY_ORG=""
16
+ IMAGE_PREFIX="ui-extension-"
17
+ FORCE="false"
18
+ GITHUB_BUILD="true"
19
+
20
+ GITHUB_SOURCE=$(git config --get remote.origin.url | sed -e 's/^git@.*:\([[:graph:]]*\).git/\1/')
21
+ GITHUB_BRANCH="main"
22
+
23
+ usage() {
24
+ echo "Usage: $0 [<options>] [plugins]"
25
+ echo " options:"
26
+ echo " -p Push container images on build"
27
+ echo " -f Force building the chart even if it already exists"
28
+ echo " -r <name> Specify destination container registry for built images"
29
+ echo " -o <name> Specify destination container registry organization for built images"
30
+ echo " -i <prefix> Specify prefix for the built container image (default: 'ui-extension-')"
31
+ echo " -c Build as a container image rather than publishing to Github"
32
+ echo " -s <repo> Specify destination GitHub repository (org/name) - defaults to the git origin"
33
+ echo " -b <branch> Specify destination GitHub branch"
34
+ exit 1
35
+ }
36
+
37
+ while getopts "hvr:o:pi:fcb:s:" opt; do
38
+ case $opt in
39
+ h)
40
+ usage
41
+ ;;
42
+ p)
43
+ PUSH="--push"
44
+ ;;
45
+ r)
46
+ REGISTRY="${OPTARG%/}/"
47
+ ;;
48
+ o)
49
+ REGISTRY_ORG="${OPTARG}"
50
+ ;;
51
+ i)
52
+ IMAGE_PREFIX="${OPTARG}"
53
+ ;;
54
+ f)
55
+ FORCE="true"
56
+ ;;
57
+ c)
58
+ GITHUB_BUILD="false"
59
+ ;;
60
+ s)
61
+ GITHUB_BUILD="true"
62
+ GITHUB_SOURCE="${OPTARG}"
63
+ ;;
64
+ b)
65
+ GITHUB_BUILD="true"
66
+ GITHUB_BRANCH="${OPTARG}"
67
+ ;;
68
+ *)
69
+ usage
70
+ ;;
71
+ esac
72
+ done
73
+
74
+ shift $((OPTIND-1))
75
+
76
+ PLUGINS=( "$@" )
77
+ BUILT="false"
78
+
79
+ echo -e "${CYAN}${BOLD}Publishing UI Plugins${RESET}"
80
+
81
+ pushd ${BASE_DIR} > /dev/null
82
+
83
+ if [ "${GITHUB_BUILD}" == "true" ]; then
84
+ # Determine if gh-pages build is possible
85
+ if [[ "${GITHUB_BRANCH}" == "gh-pages" ]] && ! git show-ref -q --heads gh-pages; then
86
+ echo -e "${YELLOW}'gh-pages' branch not found, this branch must exist before running this script${RESET}"
87
+ exit 1
88
+ fi
89
+
90
+ echo -e "${CYAN}GitHub Repository: ${GITHUB_SOURCE}${RESET}"
91
+ echo -e "${CYAN}GitHub Branch : ${GITHUB_BRANCH}${RESET}"
92
+ else
93
+ echo -e ${CYAN}"Image prefix: ${IMAGE_PREFIX}${RESET}"
94
+ fi
95
+
96
+ # --------------------------------------------------------------------------------
97
+ # Check that we have the required commands avaialble for this script
98
+ # --------------------------------------------------------------------------------
99
+
100
+ if ! [[ -f ${BASE_DIR}/package.json ]]; then
101
+ echo -e "${YELLOW}You must run from the top-level folder${RESET}"
102
+ exit 1
103
+ fi
104
+
105
+ # Check this is a Rancher extension
106
+ IS_SHELL=$(grep "\"@rancher/shell" package.json -c)
107
+
108
+ if [ "${IS_SHELL}" -ne 1 ]; then
109
+ echo -e "${YELLOW}Current folder does not appear to contain Rancher Extensions${RESET}"
110
+ exit 1
111
+ fi
112
+
113
+ if ! [[ -d ${BASE_DIR}/node_modules ]]; then
114
+ echo -e "${YELLOW}You must run ${BOLD}yarn install${NORMAL} before running this script${RESET}"
115
+ exit 1
116
+ fi
117
+
118
+ COMMANDS=("node" "jq" "yq" "git" "docker" "helm" "yarn")
119
+ HAVE_COMMANDS="true"
120
+ for CMD in "${COMMANDS[@]}"
121
+ do
122
+ if ! command -v ${CMD} >/dev/null; then
123
+ echo -e "${YELLOW}This script requires ${BOLD}${CMD}${NORMAL} to be installed and on your PATH${RESET}"
124
+ HAVE_COMMANDS="false"
125
+ fi
126
+ done
127
+
128
+ if [ "${HAVE_COMMANDS}" == "false" ]; then
129
+ exit 1
130
+ fi
131
+
132
+ # --------------------------------------------------------------------------------
133
+ # Only do conatiner args checks if not GitHub publish
134
+ if [ "${GITHUB_BUILD}" == "false" ]; then
135
+ if [[ -z ${REGISTRY_ORG} ]]; then
136
+ # Infer that the user has the same Docker registry org as their GitHub org
137
+ GITHUB_REPO=$(git config --get remote.origin.url | sed -e 's/^git@.*:\([[:graph:]]*\).git/\1/')
138
+ REGISTRY_ORG=$(dirname ${GITHUB_REPO})
139
+ echo -e "Inferring built images will reside in registry organization ${CYAN}${BOLD}${REGISTRY}${REGISTRY_ORG}${RESET} based on configured origin remote pointing to ${CYAN}${BOLD}${GITHUB_REPO}${RESET}"
140
+ fi
141
+
142
+ if [[ -z ${REGISTRY_ORG} ]]; then
143
+ # Inferring from the git config still failed
144
+ echo "Cannot build images without valid organization for Docker images. Unable to infer REGISTRY_ORG="
145
+ exit 1
146
+ fi
147
+
148
+ docker images > /dev/null
149
+ if [ $? -ne 0 ]; then
150
+ echo "docker is not running - this is required to build container images for the UI Plugins"
151
+ exit 1
152
+ fi
153
+ fi
154
+
155
+ ASSETS=${BASE_DIR}/assets
156
+ CHARTS=${BASE_DIR}/charts
157
+ mkdir -p ${ASSETS}
158
+ mkdir -p ${CHARTS}
159
+
160
+ TMP=${BASE_DIR}/tmp
161
+ CHART_TMP=${BASE_DIR}/tmp/_charts
162
+ rm -rf ${TMP}
163
+ mkdir -p ${TMP}
164
+
165
+ CHART_TEMPLATE=${BASE_DIR}/tmp/ui-plugin-server
166
+
167
+ # --------------------------------------------------------------------------------
168
+ # Clone the plugin server template into the temporary folder
169
+ # --------------------------------------------------------------------------------
170
+ pushd ${TMP} > /dev/null
171
+ git clone -q https://github.com/nwmac/ui-plugin-server.git
172
+ popd > /dev/null
173
+
174
+ # --------------------------------------------------------------------------------
175
+ # Iterate through all packages - built them all or build only those specified on the command line
176
+ # --------------------------------------------------------------------------------
177
+ for d in pkg/*/ ; do
178
+ pkg=$(basename $d)
179
+
180
+ if [ -z "$1" ] || [[ " ${PLUGINS[*]} " =~ " ${pkg} " ]]; then
181
+ # Check we don't already have a published version by looking in the assets folder
182
+ PKG_VERSION=$(jq -r .version ./pkg/${pkg}/package.json)
183
+ PKG_NAME="${pkg}-${PKG_VERSION}"
184
+ PKG_ASSET=${ASSETS}/${pkg}/${PKG_NAME}.tgz
185
+
186
+ echo -e "${CYAN}${BOLD}Building plugin: ${pkg} (${PKG_VERSION}) ${RESET}"
187
+
188
+ echo "Package version: ${PKG_VERSION}"
189
+ echo "Package folder: ${PKG_NAME}"
190
+
191
+ # --------------------------------------------------------------------------------
192
+ # Build the plugin from source
193
+ # --------------------------------------------------------------------------------
194
+ echo -e "${CYAN}Building plugin from source code${RESET}"
195
+ FORCE_COLOR=1 yarn build-pkg $pkg | cat
196
+
197
+ echo -e "${CYAN}Adding plugin code ...${RESET}"
198
+
199
+ EXT_FOLDER=${BASE_DIR}/extensions/${pkg}/${PKG_VERSION}
200
+ PKG_DIST="${BASE_DIR}/dist-pkg/${PKG_NAME}"
201
+
202
+ rm -rf ${EXT_FOLDER}
203
+
204
+ mkdir -p ${EXT_FOLDER}/plugin
205
+
206
+ # Copy the code into the folder
207
+ cp -R ${PKG_DIST}/* ${EXT_FOLDER}/plugin
208
+
209
+ pushd ${BASE_DIR}/extensions/${pkg}/${PKG_VERSION} > /dev/null
210
+ rm -f plugin/report.html
211
+ find plugin -type f | sort > files.txt
212
+ popd > /dev/null
213
+
214
+ rm -rf ${TMP}/container
215
+
216
+ # --------------------------------------------------------------------------------
217
+ # Create the Helm chart
218
+ # --------------------------------------------------------------------------------
219
+
220
+ if [ -f ${PKG_ASSET} ] && [ "${FORCE}" == "false" ]; then
221
+ echo -e "${YELLOW}Helm chart has already been created - skipping (run with -f to force build)${RESET}"
222
+ continue;
223
+ fi
224
+
225
+ CHART_FOLDER=${CHARTS}/${pkg}/${PKG_VERSION}
226
+
227
+ mkdir -p ${ASSETS}/${pkg}
228
+ rm -rf ${CHART_FOLDER}
229
+ mkdir -p ${CHART_FOLDER}
230
+
231
+ cp -R ${CHART_TEMPLATE}/charts/ui-plugin-server/* ${CHART_FOLDER}
232
+
233
+ # Update Chart.yaml and values.yaml from the package file metadata
234
+ # Use the script from the template repository
235
+ echo -e "${CYAN}Patching Helm chart template${RESET}"
236
+
237
+ CHART=${CHART_FOLDER} REGISTRY="${REGISTRY}" ORG="${REGISTRY_ORG}" PACKAGE_JSON=${BASE_DIR}/pkg/${pkg}/package.json ${CHART_TEMPLATE}/scripts/patch
238
+
239
+ # Copy README file from the plugin to the Helm chart, if there is one
240
+ if [ -f "./pkg/${pkg}/README.md" ]; then
241
+ cp ./pkg/${pkg}/README.md ${CHART_FOLDER}/README.md
242
+ fi
243
+
244
+ if [ "${GITHUB_BUILD}" == "true" ]; then
245
+ echo "Patching for GitHub build"
246
+ pushd ${CHART_FOLDER} > /dev/null
247
+ cd templates
248
+ mv cr.yaml temp.cr
249
+ rm *.yaml
250
+ mv temp.cr cr.yaml
251
+ ENDPOINT=https://raw.githubusercontent.com/${GITHUB_SOURCE}/${GITHUB_BRANCH}/extensions/${pkg}/${PKG_VERSION}
252
+ sed -i.bak -e 's@endpoint: .*@endpoint: '"${ENDPOINT}"'@g' cr.yaml
253
+ rm *.bak
254
+ popd > /dev/null
255
+ fi
256
+
257
+ # Additional patches
258
+ ${SCRIPT_DIR}/helmpatch ${CHART_FOLDER} "${BASE_DIR}/pkg/${pkg}/package.json" "${REGISTRY}${REGISTRY_ORG}/${IMAGE_PREFIX}${pkg}"
259
+
260
+ # Package into a .tgz helm chart
261
+ helm package ${CHART_FOLDER} -d ${ASSETS}/${pkg}
262
+
263
+ # --------------------------------------------------------------------------------
264
+ # Update the helm index just for this chart
265
+ # --------------------------------------------------------------------------------
266
+ HELM_INDEX=${BASE_DIR}/index.yaml
267
+
268
+ if [ -f "${HELM_INDEX}" ]; then
269
+ UPDATE="--merge ${HELM_INDEX}"
270
+ elif [ "${GITHUB_BUILD}" == "true" ] && [[ -n ${GITHUB_SOURCE} ]]; then
271
+ GITHUB_SOURCE=$(echo -e "${GITHUB_SOURCE}" | sed 's/https:\/\///g')
272
+
273
+ # Check if git branch contains index.yaml
274
+ wget -P ${BASE_DIR} https://raw.githubusercontent.com/${GITHUB_SOURCE}/${GITHUB_BRANCH}/index.yaml
275
+
276
+ if [ -f "${HELM_INDEX}" ]; then
277
+ UPDATE="--merge ${HELM_INDEX}"
278
+ fi
279
+ fi
280
+
281
+ # Base URL referencing assets directly from GitHub
282
+ BASE_URL="assets/${pkg}"
283
+
284
+ rm -rf ${CHART_TMP}
285
+ mkdir -p ${CHART_TMP}
286
+ cp ${ASSETS}/${pkg}/*.tgz ${CHART_TMP}
287
+
288
+ helm repo index ${CHART_TMP} --url ${BASE_URL} ${UPDATE}
289
+
290
+ cp ${CHART_TMP}/index.yaml ${HELM_INDEX}
291
+
292
+ if [ "${GITHUB_BUILD}" == "true" ]; then
293
+ # Make temp directory for workflow build artifact
294
+ mkdir -p tmp/{assets,charts,extensions}/$pkg
295
+
296
+ cp -r ${PKG_ASSET} tmp/assets/$pkg
297
+ cp -r ${CHARTS}/${pkg}/${PKG_VERSION} tmp/charts/$pkg
298
+ cp -r ${EXT_FOLDER} tmp/extensions/$pkg
299
+ fi
300
+
301
+ BUILT="true"
302
+ fi
303
+ done
304
+
305
+ if [ "${GITHUB_BUILD}" == "false" ]; then
306
+ BASE=$(basename ${BASE_DIR})
307
+ EXT_VERSION=$(jq -r .version ${BASE_DIR}/package.json)
308
+
309
+ if [ -z ${EXT_VERSION} ]; then
310
+ EXT_VERSION="0.0.0"
311
+ fi
312
+
313
+ echo -e "${CYAN}Base extension: ${BASE}${RESET}"
314
+ echo -e "${CYAN}Extension version: ${EXT_VERSION}${RESET}"
315
+
316
+ # Build the docker image
317
+ ${SCRIPT_DIR}/bundle ${BASE} ${EXT_VERSION} ${REGISTRY} ${REGISTRY_ORG} ${IMAGE_PREFIX} ${PUSH}
318
+ fi
319
+
320
+ if [ "${GITHUB_BUILD}" == "true" ]; then
321
+ cp index.yaml tmp
322
+ fi
323
+
324
+ if [ "${BUILT}" == "true" ]; then
325
+ echo -e "${CYAN}${BOLD}${CHECK} One or more packages built${RESET}"
326
+ fi
327
+
328
+ # Clean up
329
+ rm -rf ${CHART_TMP}
330
+
331
+ if [ "${GITHUB_BUILD}" == "false" ]; then
332
+ rm -rf ${TMP}
333
+ fi
@@ -2,13 +2,17 @@
2
2
 
3
3
  const fs = require('fs-extra');
4
4
  const path = require('path');
5
-
6
- console.log(__dirname);
5
+ const { exit } = require('process');
7
6
 
8
7
  const dir = path.resolve('.');
9
8
  const pkgs = path.join(dir, 'dist-pkg');
10
9
  let port = 4500;
11
10
 
11
+ if (!fs.existsSync(pkgs)) {
12
+ console.log(`\n\x1B[31m%s\x1B[0m\n`, `Error: The 'dist-pkg directory doesn't exist. You likely need to run the 'yarn build-pkg <pkg name>' command first.`);
13
+ exit(1);
14
+ }
15
+
12
16
  const express = require('express');
13
17
  const serveStatic = require('serve-static');
14
18
 
@@ -91,6 +91,10 @@ ${SHELL_DIR}/scripts/publish-shell.sh
91
91
  yarn build:lib
92
92
  yarn publish:lib
93
93
 
94
+ # We pipe into cat for cleaner logging - we need to set pipefail
95
+ # to ensure the build fails in these cases
96
+ set -o pipefail
97
+
94
98
  if [ "${SKIP_STANDALONE}" == "false" ]; then
95
99
  DIR=$(mktemp -d)
96
100
  pushd $DIR > /dev/null
@@ -0,0 +1,110 @@
1
+ import { getters } from '../index';
2
+
3
+ describe('getters', () => {
4
+ describe('namespaces', () => {
5
+ it('should return empty dictionary', () => {
6
+ const expectation = {};
7
+ const state = {};
8
+ const stateGetters = { currentProduct: () => ({}) };
9
+
10
+ const result = getters.namespaces(state, stateGetters)();
11
+
12
+ expect(result).toStrictEqual(expectation);
13
+ });
14
+
15
+ it('should return all the namespaces for related category', () => {
16
+ const clusterId = 'my-cluster';
17
+ const namespaceId = 'my-namespace';
18
+ const expectation = { [namespaceId]: true };
19
+ const state = {
20
+ allNamespaces: [{ id: namespaceId }],
21
+ prefs: { data: { 'all-namespaces': false } },
22
+ namespaceFilters: []
23
+ };
24
+ const stateGetters = {
25
+ isAllNamespaces: true,
26
+ currentProduct: { inStore: 'whatever' },
27
+ 'whatever/all': {},
28
+ currentCluster: { id: clusterId },
29
+ };
30
+
31
+ const result = getters.namespaces(state, stateGetters)();
32
+
33
+ expect(result).toStrictEqual(expectation);
34
+ });
35
+
36
+ it('should return Rancher system namespaces', () => {
37
+ const clusterId = 'my-cluster';
38
+ const namespaceId = 'my-rancher-system-namespace';
39
+ const expectation = { [namespaceId]: true };
40
+ const state = {
41
+ allNamespaces: [{
42
+ id: namespaceId,
43
+ isObscure: true
44
+ }],
45
+ prefs: { data: { 'all-namespaces': true } },
46
+ namespaceFilters: []
47
+ };
48
+ const stateGetters = {
49
+ isAllNamespaces: true,
50
+ currentProduct: { inStore: 'whatever' },
51
+ 'whatever/all': {},
52
+ currentCluster: { id: clusterId },
53
+ };
54
+
55
+ const result = getters.namespaces(state, stateGetters)();
56
+
57
+ expect(result).toStrictEqual(expectation);
58
+ });
59
+
60
+ it('should filter Rancher system namespaces', () => {
61
+ const clusterId = 'my-cluster';
62
+ const namespaceId = 'my-rancher-system-namespace';
63
+ const expectation = { };
64
+ const state = {
65
+ allNamespaces: [{
66
+ id: namespaceId,
67
+ isObscure: true
68
+ }],
69
+ prefs: { data: { 'all-namespaces': false } },
70
+ namespaceFilters: []
71
+ };
72
+ const stateGetters = {
73
+ isAllNamespaces: true,
74
+ currentProduct: { inStore: 'whatever' },
75
+ 'whatever/all': {},
76
+ currentCluster: { id: clusterId },
77
+ };
78
+
79
+ const result = getters.namespaces(state, stateGetters)();
80
+
81
+ expect(result).toStrictEqual(expectation);
82
+ });
83
+
84
+ it('should filter namespaces by project', () => {
85
+ const clusterId = 'my-cluster';
86
+ const namespaceId = 'my-product-namespace';
87
+ const projectId = 'my-project';
88
+ const expectation = { [namespaceId]: true };
89
+ const state = {
90
+ allNamespaces: [{ id: namespaceId }],
91
+ prefs: { data: { 'all-namespaces': false } },
92
+ namespaceFilters: [`project://${ projectId }`]
93
+ };
94
+ const stateGetters = {
95
+ isAllNamespaces: false,
96
+ currentProduct: { inStore: 'whatever' },
97
+ 'whatever/all': {},
98
+ 'management/byId': () => ({
99
+ id: projectId,
100
+ namespaces: [{ id: namespaceId }]
101
+ }),
102
+ currentCluster: { id: clusterId },
103
+ };
104
+
105
+ const result = getters.namespaces(state, stateGetters)();
106
+
107
+ expect(result).toStrictEqual(expectation);
108
+ });
109
+ });
110
+ });