@rancher/shell 0.3.3 → 0.3.5
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.
- package/assets/styles/app.scss +1 -1
- package/assets/styles/fonts/_fontstack.scss +11 -11
- package/assets/styles/vendor/vue-js-modal.scss +3 -3
- package/assets/translations/en-us.yaml +92 -22
- package/assets/translations/zh-hans.yaml +84 -15
- package/babel.config.js +13 -0
- package/chart/gatekeeper.vue +77 -0
- package/chart/istio.vue +108 -111
- package/chart/logging/index.vue +13 -4
- package/chart/monitoring/index.vue +15 -5
- package/chart/monitoring/steps/uninstall-v1.vue +2 -2
- package/chart/rancher-backup/index.vue +10 -3
- package/cloud-credential/aws.vue +1 -1
- package/cloud-credential/digitalocean.vue +1 -1
- package/cloud-credential/gcp.vue +1 -1
- package/cloud-credential/generic.vue +2 -2
- package/cloud-credential/linode.vue +1 -1
- package/cloud-credential/pnap.vue +1 -1
- package/components/ActionMenu.vue +3 -4
- package/components/AssignTo.vue +1 -1
- package/components/AsyncButton.vue +1 -1
- package/components/BannerGraphic.vue +1 -1
- package/components/ButtonDropdown.vue +2 -3
- package/components/ChartPsp.vue +76 -0
- package/components/CruResource.vue +6 -2
- package/components/DashboardMetrics.vue +12 -10
- package/components/DetailText.vue +1 -1
- package/components/DisableAuthProviderModal.vue +1 -1
- package/components/EmberPage.vue +1 -1
- package/components/EtcdInfoBanner.vue +5 -4
- package/components/ExplorerMembers.vue +1 -1
- package/components/ExplorerProjectsNamespaces.vue +15 -2
- package/components/FileDiff.vue +6 -7
- package/components/GrafanaDashboard.vue +18 -21
- package/components/LazyImage.vue +10 -12
- package/components/LogItem.vue +1 -1
- package/components/Markdown.vue +1 -1
- package/components/PromptRemove.vue +2 -2
- package/components/PromptRestore.vue +1 -1
- package/components/ResourceDetail/Masthead.vue +16 -0
- package/components/ResourceDetail/index.vue +21 -4
- package/components/ResourceList/index.vue +1 -1
- package/components/ResourceTable.vue +4 -1
- package/components/SingleClusterInfo.vue +2 -2
- package/components/SortableTable/THead.vue +1 -1
- package/components/SortableTable/index.vue +5 -2
- package/components/__tests__/AsyncButton.test.ts +3 -1
- package/components/__tests__/ChartPsp.test.ts +75 -0
- package/components/__tests__/CruResource.test.ts +3 -1
- package/components/auth/Principal.vue +1 -1
- package/components/fleet/FleetBundles.vue +3 -1
- package/components/fleet/FleetClusters.vue +1 -2
- package/components/fleet/FleetIntro.vue +9 -1
- package/components/fleet/FleetNoWorkspaces.vue +62 -0
- package/components/fleet/FleetSummary.vue +7 -1
- package/components/form/LabeledSelect.vue +14 -11
- package/components/form/MatchExpressions.vue +17 -2
- package/components/form/NameNsDescription.vue +31 -45
- package/components/form/ResourceSelector.vue +1 -1
- package/components/form/SecretSelector.vue +5 -1
- package/components/form/ServiceNameSelect.vue +1 -1
- package/components/form/SimpleSecretSelector.vue +9 -9
- package/components/form/__tests__/LabeledSelect.test.ts +138 -0
- package/components/form/__tests__/NameNsDescription.ts +32 -0
- package/components/formatter/InternalExternalIP.vue +6 -0
- package/components/formatter/InvolvedObjectLink.vue +54 -0
- package/components/formatter/Link.vue +20 -4
- package/components/formatter/LinkName.vue +6 -1
- package/components/formatter/ServiceTargets.vue +1 -1
- package/components/nav/Group.vue +2 -2
- package/components/nav/NamespaceFilter.vue +15 -11
- package/components/nav/TopLevelMenu.vue +2 -4
- package/components/nav/Type.vue +1 -1
- package/components/nav/WorkspaceSwitcher.vue +46 -5
- package/config/labels-annotations.js +17 -0
- package/config/product/auth.js +3 -2
- package/config/product/explorer.js +11 -4
- package/config/product/fleet.js +2 -0
- package/config/router.js +414 -0
- package/config/table-headers.js +10 -2
- package/config/types.js +11 -8
- package/config/uiplugins.js +30 -0
- package/content/docs/en-us/whats-new.md +10 -0
- package/content/docs/zh-hans/whats-new.md +11 -1
- package/core/plugin-helpers.js +64 -61
- package/core/plugin-routes.ts +23 -0
- package/creators/app/app.package.json +2 -1
- package/creators/app/files/.eslintrc.js +1 -1
- package/creators/app/files/babel.config.js +1 -18
- package/creators/app/files/vue.config.js +7 -0
- package/creators/app/init +5 -5
- package/creators/pkg/files/.github/workflows/build-extension.yml +111 -0
- package/creators/pkg/init +35 -4
- package/creators/update/init +1 -1
- package/detail/constraints.gatekeeper.sh.constraint.vue +20 -10
- package/detail/fleet.cattle.io.gitrepo.vue +19 -11
- package/detail/harvesterhci.io.management.cluster.vue +3 -3
- package/detail/provisioning.cattle.io.cluster.vue +54 -12
- package/detail/workload/index.vue +3 -3
- package/dialog/AddClusterMemberDialog.vue +1 -1
- package/dialog/AddProjectMemberDialog.vue +2 -2
- package/dialog/AddonConfigConfirmationDialog.vue +27 -15
- package/dialog/DiagnosticTimingsDialog.vue +1 -1
- package/dialog/ForceMachineRemoveDialog.vue +1 -1
- package/dialog/GenericPrompt.vue +18 -6
- package/dialog/RotateEncryptionKeyDialog.vue +1 -1
- package/dialog/SaveAsRKETemplateDialog.vue +1 -1
- package/dialog/ScaleMachineDownDialog.vue +1 -1
- package/edit/auth/github.vue +8 -8
- package/edit/auth/googleoauth.vue +5 -5
- package/edit/auth/ldap/index.vue +1 -1
- package/edit/auth/oidc.vue +1 -1
- package/edit/auth/saml.vue +1 -1
- package/edit/cis.cattle.io.clusterscan.vue +1 -1
- package/edit/fleet.cattle.io.clustergroup.vue +6 -4
- package/edit/fleet.cattle.io.gitrepo.vue +16 -3
- package/edit/helm.cattle.io.projecthelmchart.vue +5 -1
- package/edit/management.cattle.io.fleetworkspace.vue +141 -6
- package/edit/management.cattle.io.podsecurityadmissionconfigurationtemplate.vue +4 -1
- package/edit/management.cattle.io.setting.vue +1 -1
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/webhook.vue +2 -2
- package/edit/monitoring.coreos.com.receiver/tls.vue +18 -18
- package/edit/monitoring.coreos.com.receiver/types/webhook.banner.vue +4 -4
- package/edit/monitoring.coreos.com.receiver/types/webhook.vue +1 -1
- package/edit/namespace.vue +2 -2
- package/edit/networking.k8s.io.networkpolicy/PolicyRuleTarget.vue +126 -45
- package/edit/networking.k8s.io.networkpolicy/index.vue +1 -1
- package/edit/provisioning.cattle.io.cluster/MachinePool.vue +10 -0
- package/edit/provisioning.cattle.io.cluster/RegistryConfigs.vue +1 -0
- package/edit/provisioning.cattle.io.cluster/__tests__/rke2.test.ts +202 -2
- package/edit/provisioning.cattle.io.cluster/rke2.vue +248 -84
- package/edit/resources.cattle.io.backup.vue +1 -1
- package/edit/service.vue +1 -1
- package/edit/storage.k8s.io.storageclass/provisioners/driver.harvesterhci.io.vue +2 -2
- package/edit/workload/__tests__/Job.test.ts +3 -1
- package/edit/workload/index.vue +8 -3
- package/edit/workload/mixins/workload.js +16 -0
- package/layouts/default.vue +7 -3
- package/list/fleet.cattle.io.bundle.vue +6 -3
- package/list/fleet.cattle.io.clusterregistrationtoken.vue +3 -1
- package/list/fleet.cattle.io.gitrepo.vue +44 -5
- package/list/management.cattle.io.fleetworkspace.vue +45 -0
- package/list/node.vue +69 -16
- package/list/provisioning.cattle.io.cluster.vue +30 -1
- package/machine-config/azure.vue +97 -38
- package/middleware/authenticated.js +34 -0
- package/mixins/chart.js +73 -2
- package/mixins/resource-fetch.js +2 -2
- package/models/apps.statefulset.js +28 -0
- package/models/cluster/node.js +23 -2
- package/models/cluster.x-k8s.io.machine.js +4 -2
- package/models/clusterroletemplatebinding.js +7 -0
- package/models/constraints.gatekeeper.sh.constraint.js +9 -0
- package/models/fleet.cattle.io.cluster.js +19 -10
- package/models/fleet.cattle.io.gitrepo.js +7 -2
- package/models/management.cattle.io.cluster.js +1 -1
- package/models/management.cattle.io.fleetworkspace.js +12 -0
- package/models/management.cattle.io.gitreporestriction.js +5 -0
- package/models/management.cattle.io.podsecurityadmissionconfigurationtemplate.js +3 -0
- package/models/namespace.js +5 -5
- package/models/provisioning.cattle.io.cluster.js +7 -5
- package/nuxt/App.js +210 -0
- package/nuxt/axios.js +186 -0
- package/nuxt/client.js +817 -0
- package/nuxt/components/nuxt-build-indicator.vue +143 -0
- package/nuxt/components/nuxt-child.js +122 -0
- package/nuxt/components/nuxt-error.vue +98 -0
- package/nuxt/components/nuxt-link.client.js +98 -0
- package/nuxt/components/nuxt-link.server.js +16 -0
- package/nuxt/components/nuxt-loading.vue +154 -0
- package/nuxt/components/nuxt.js +101 -0
- package/nuxt/cookie-universal-nuxt.js +9 -0
- package/nuxt/empty.js +1 -0
- package/nuxt/index.js +365 -0
- package/nuxt/jsonp.js +82 -0
- package/nuxt/loading.html +39 -0
- package/nuxt/middleware.js +12 -0
- package/nuxt/mixins/fetch.client.js +90 -0
- package/nuxt/mixins/fetch.server.js +69 -0
- package/nuxt/portal-vue.js +4 -0
- package/nuxt/server.js +312 -0
- package/nuxt/store.js +178 -0
- package/nuxt/utils.js +630 -0
- package/nuxt/views/app.template.html +9 -0
- package/nuxt/views/error.html +23 -0
- package/package.json +5 -9
- package/pages/auth/setup.vue +2 -2
- package/pages/c/_cluster/apps/charts/__tests__/install.helper.test.ts +33 -0
- package/pages/c/_cluster/apps/charts/chart.vue +4 -4
- package/pages/c/_cluster/apps/charts/install.helpers.js +26 -0
- package/pages/c/_cluster/apps/charts/install.vue +40 -66
- package/pages/c/_cluster/explorer/EventsTable.vue +5 -19
- package/pages/c/_cluster/explorer/index.vue +29 -25
- package/pages/c/_cluster/explorer/tools/index.vue +8 -8
- package/pages/c/_cluster/fleet/index.vue +95 -34
- package/pages/c/_cluster/gatekeeper/index.vue +1 -1
- package/pages/c/_cluster/istio/index.vue +5 -5
- package/pages/c/_cluster/manager/cloudCredential/index.vue +1 -1
- package/pages/c/_cluster/monitoring/index.vue +7 -0
- package/pages/c/_cluster/uiplugins/InstallDialog.vue +8 -8
- package/pages/c/_cluster/uiplugins/PluginInfoPanel.vue +20 -7
- package/pages/c/_cluster/uiplugins/index.vue +49 -17
- package/pages/home.vue +9 -4
- package/pages/index.vue +10 -1
- package/plugins/clean-html-directive.js +31 -0
- package/plugins/dashboard-store/actions.js +32 -9
- package/plugins/dashboard-store/mutations.js +5 -2
- package/plugins/dashboard-store/resource-class.js +8 -1
- package/plugins/steve/mutations.js +3 -2
- package/plugins/steve/steve-description-class.js +5 -1
- package/plugins/steve/subscribe.js +63 -54
- package/plugins/steve-create-worker.js +14 -0
- package/promptRemove/management.cattle.io.globalrole.vue +2 -2
- package/promptRemove/management.cattle.io.project.vue +2 -2
- package/promptRemove/management.cattle.io.roletemplate.vue +2 -2
- package/promptRemove/pod.vue +1 -1
- package/public/index.html +65 -0
- package/rancher-components/components/Banner/Banner.test.ts +9 -1
- package/rancher-components/components/Banner/Banner.vue +1 -1
- package/rancher-components/components/Form/Checkbox/Checkbox.vue +2 -0
- package/rancher-components/components/Form/Radio/RadioButton.vue +1 -1
- package/scripts/build-pkg.sh +1 -0
- package/scripts/clean +6 -0
- package/scripts/extension/bundle +58 -0
- package/scripts/extension/helmpatch +89 -0
- package/scripts/extension/publish +314 -0
- package/scripts/test-plugins-build.sh +4 -0
- package/store/__tests__/index.test.ts +110 -0
- package/store/index.js +145 -58
- package/store/type-map.js +26 -19
- package/tsconfig.default.json +36 -0
- package/tsconfig.json +24 -0
- package/types/shell/index.d.ts +420 -343
- package/utils/__tests__/string.test.ts +12 -0
- package/utils/auth.js +65 -0
- package/utils/monitoring.js +2 -1
- package/utils/position.js +5 -8
- package/utils/router.scrollBehavior.js +80 -0
- package/utils/select.js +1 -3
- package/utils/socket.js +1 -0
- package/utils/string.js +13 -0
- package/utils/time.js +9 -0
- package/vue.config.js +679 -0
- package/yarn-error.log +196 -0
- package/chart/rancher-alerting-drivers.vue +0 -53
- package/chart/rancher-gatekeeper.vue +0 -37
- package/creators/app/files/nuxt.config.js +0 -6
- package/models/management.cattle.io.podsecurityadmissionconfigurationtemplate.ts +0 -4
- package/nuxt.config.js +0 -798
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
BASE_DIR="$(pwd)"
|
|
4
|
+
|
|
5
|
+
CYAN="\033[96m"
|
|
6
|
+
RED="\033[91m"
|
|
7
|
+
RESET="\033[0m"
|
|
8
|
+
BOLD="\033[1m"
|
|
9
|
+
|
|
10
|
+
TMP=${BASE_DIR}/tmp
|
|
11
|
+
CHART_TEMPLATE=${TMP}/ui-plugin-server
|
|
12
|
+
|
|
13
|
+
PKG="${1}"
|
|
14
|
+
PKG_VERSION="${2}"
|
|
15
|
+
REGISTRY="${3}"
|
|
16
|
+
REGISTRY_ORG="${4}"
|
|
17
|
+
IMAGE_PREFIX="${5}"
|
|
18
|
+
PUSH="${6}"
|
|
19
|
+
|
|
20
|
+
PKG_NAME="${PKG}-${PKG_VERSION}"
|
|
21
|
+
|
|
22
|
+
# --------------------------------------------------------------------------------
|
|
23
|
+
# Create the container image
|
|
24
|
+
# --------------------------------------------------------------------------------
|
|
25
|
+
mkdir -p ${TMP}/container
|
|
26
|
+
cp -R ${CHART_TEMPLATE}/* ${TMP}/container/
|
|
27
|
+
|
|
28
|
+
# Copy the plugin assets
|
|
29
|
+
rm -rf ${TMP}/container/plugin
|
|
30
|
+
mkdir ${TMP}/container/plugin
|
|
31
|
+
|
|
32
|
+
cp -R ${BASE_DIR}/dist-pkg/${PKG_NAME}/* ${TMP}/container/plugin
|
|
33
|
+
rm -f ${TMP}/container/plugin/report.html
|
|
34
|
+
|
|
35
|
+
# Build the docker image
|
|
36
|
+
pushd ${TMP}/container > /dev/null
|
|
37
|
+
echo -e "${CYAN}Building container image ...${RESET}"
|
|
38
|
+
|
|
39
|
+
if [ ! -z "${REGISTRY}" ]; then
|
|
40
|
+
REGISTRY=${REGISTRY} ORG=${REGISTRY_ORG} REPO=${IMAGE_PREFIX}${PKG} TAG=${PKG_VERSION} ./scripts/package
|
|
41
|
+
|
|
42
|
+
if [ "${PUSH}" == "--push" ]; then
|
|
43
|
+
echo -e "${CYAN}Pushing container image ...${RESET}"
|
|
44
|
+
|
|
45
|
+
# Ensure that you do not overwrite production images
|
|
46
|
+
if [[ "${REGISTRY_ORG}" == "rancher" ]]; then
|
|
47
|
+
IMAGE=${REGISTRY}${REGISTRY_ORG}/${IMAGE_PREFIX}${PKG}:${PKG_VERSION}
|
|
48
|
+
if docker manifest inspect 2>&1 1>/dev/null; then
|
|
49
|
+
echo -e "${RED}${BOLD}Cannot overwrite production image ${IMAGE_PREFIX}${PKG} since it already exists${RESET}"
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
docker push ${REGISTRY}${REGISTRY_ORG}/${IMAGE_PREFIX}${PKG}:${PKG_VERSION}
|
|
55
|
+
fi
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
popd > /dev/null
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Update Chart.yaml and values.yaml files
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const yaml = require('js-yaml');
|
|
8
|
+
|
|
9
|
+
// TODO: Should already be in the template
|
|
10
|
+
// const UI_PLUGIN_ANNOTATION_NAME = 'catalog.cattle.io/ui-component';
|
|
11
|
+
// const UI_PLUGIN_ANNOTATION_VALUE = 'plugins';
|
|
12
|
+
|
|
13
|
+
console.log('Helm file update');
|
|
14
|
+
|
|
15
|
+
if (process.argv.length !== 5) {
|
|
16
|
+
console.log('Incorrect number of arguments');
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const destFolder = process.argv[2];
|
|
21
|
+
const pkgFilePath = process.argv[3];
|
|
22
|
+
const image = process.argv[4];
|
|
23
|
+
|
|
24
|
+
const pkgFile = JSON.parse(fs.readFileSync(pkgFilePath, 'utf8'));
|
|
25
|
+
|
|
26
|
+
const chartFolder = destFolder;
|
|
27
|
+
const chartFile = path.join(chartFolder, 'Chart.yaml');
|
|
28
|
+
const valuesFile = path.join(chartFolder, 'values.yaml');
|
|
29
|
+
|
|
30
|
+
if (!fs.existsSync(chartFolder)) {
|
|
31
|
+
console.log('Charts folder does not exist');
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// --------------------------------------------------------------------------------
|
|
36
|
+
// Chart.yaml
|
|
37
|
+
// --------------------------------------------------------------------------------
|
|
38
|
+
const chart = yaml.load(fs.readFileSync(chartFile, 'utf8'));
|
|
39
|
+
let updated = false;
|
|
40
|
+
|
|
41
|
+
// Add in annotations to match any rules in the package file
|
|
42
|
+
if (pkgFile.rancher && typeof pkgFile.rancher === 'object') {
|
|
43
|
+
// See if there are any annotations and merge them in, if there are
|
|
44
|
+
if (pkgFile.rancher.annotations) {
|
|
45
|
+
chart.annotations = chart.annotations || {};
|
|
46
|
+
Object.keys(pkgFile.rancher.annotations).forEach((key) => {
|
|
47
|
+
chart.annotations[key] = pkgFile.rancher.annotations[key];
|
|
48
|
+
updated = true;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (updated ){
|
|
54
|
+
// Write out updated file
|
|
55
|
+
const str = yaml.dump(chart);
|
|
56
|
+
|
|
57
|
+
fs.writeFileSync(chartFile, str, 'utf8');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// chart.name = pkgFile.name;
|
|
61
|
+
// chart.appVersion = pkgFile.version;
|
|
62
|
+
// chart.version = pkgFile.version;
|
|
63
|
+
// chart.description = pkgFile.description || `${pkgFile.name} ui plugin `;
|
|
64
|
+
// chart.annotations[UI_PLUGIN_ANNOTATION_NAME] = UI_PLUGIN_ANNOTATION_VALUE;
|
|
65
|
+
|
|
66
|
+
// if (pkgFile.icon) {
|
|
67
|
+
// chart.icon = pkgFile.icon;
|
|
68
|
+
// }
|
|
69
|
+
|
|
70
|
+
// if (pkgFile.keywords) {
|
|
71
|
+
// chart.keywords = pkgFile.keywords;
|
|
72
|
+
// } else {
|
|
73
|
+
// chart.keywords = [];
|
|
74
|
+
// }
|
|
75
|
+
|
|
76
|
+
// if (pkgFile.homepage) {
|
|
77
|
+
// chart.home = pkgFile.homepage;
|
|
78
|
+
// }
|
|
79
|
+
|
|
80
|
+
// --------------------------------------------------------------------------------
|
|
81
|
+
// values.yaml
|
|
82
|
+
// --------------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
const values = yaml.load(fs.readFileSync(valuesFile, 'utf8'));
|
|
85
|
+
|
|
86
|
+
values.pluginServer.image.repository = `${image}`;
|
|
87
|
+
|
|
88
|
+
const valuesYaml = yaml.dump(values, {quotingType: '"' });
|
|
89
|
+
fs.writeFileSync(valuesFile, valuesYaml, 'utf8');
|
|
@@ -0,0 +1,314 @@
|
|
|
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
|
+
echo -e "${CYAN}GitHub Repository: ${GITHUB_SOURCE}${RESET}"
|
|
85
|
+
echo -e "${CYAN}GitHub Branch : ${GITHUB_BRANCH}${RESET}"
|
|
86
|
+
else
|
|
87
|
+
echo -e ${CYAN}"Image prefix: ${IMAGE_PREFIX}${RESET}"
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
# --------------------------------------------------------------------------------
|
|
91
|
+
# Check that we have the required commands avaialble for this script
|
|
92
|
+
# --------------------------------------------------------------------------------
|
|
93
|
+
|
|
94
|
+
if ! [[ -f ${BASE_DIR}/package.json ]]; then
|
|
95
|
+
echo -e "${YELLOW}You must run from the top-level folder${RESET}"
|
|
96
|
+
exit 1
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
# Check this is a Rancher extension
|
|
100
|
+
IS_SHELL=$(grep "\"@rancher/shell" package.json -c)
|
|
101
|
+
|
|
102
|
+
if [ "${IS_SHELL}" -ne 1 ]; then
|
|
103
|
+
echo -e "${YELLOW}Current folder does not appear to contain Rancher Extensions${RESET}"
|
|
104
|
+
exit 1
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
if ! [[ -d ${BASE_DIR}/node_modules ]]; then
|
|
108
|
+
echo -e "${YELLOW}You must run ${BOLD}yarn install${NORMAL} before running this script${RESET}"
|
|
109
|
+
exit 1
|
|
110
|
+
fi
|
|
111
|
+
|
|
112
|
+
COMMANDS=("node" "jq" "yq" "git" "docker" "helm" "yarn")
|
|
113
|
+
HAVE_COMMANDS="true"
|
|
114
|
+
for CMD in "${COMMANDS[@]}"
|
|
115
|
+
do
|
|
116
|
+
if ! command -v ${CMD} >/dev/null; then
|
|
117
|
+
echo -e "${YELLOW}This script requires ${BOLD}${CMD}${NORMAL} to be installed and on your PATH${RESET}"
|
|
118
|
+
HAVE_COMMANDS="false"
|
|
119
|
+
fi
|
|
120
|
+
done
|
|
121
|
+
|
|
122
|
+
if [ "${HAVE_COMMANDS}" == "false" ]; then
|
|
123
|
+
exit 1
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
# --------------------------------------------------------------------------------
|
|
127
|
+
# Only do conatiner args checks if not GitHub publish
|
|
128
|
+
if [ "${GITHUB_BUILD}" == "false" ]; then
|
|
129
|
+
if [[ -z ${REGISTRY_ORG} ]]; then
|
|
130
|
+
# Infer that the user has the same Docker registry org as their GitHub org
|
|
131
|
+
GITHUB_REPO=$(git config --get remote.origin.url | sed -e 's/^git@.*:\([[:graph:]]*\).git/\1/')
|
|
132
|
+
REGISTRY_ORG=$(dirname ${GITHUB_REPO})
|
|
133
|
+
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}"
|
|
134
|
+
fi
|
|
135
|
+
|
|
136
|
+
if [[ -z ${REGISTRY_ORG} ]]; then
|
|
137
|
+
# Inferring from the git config still failed
|
|
138
|
+
echo "Cannot build images without valid organization for Docker images. Unable to infer REGISTRY_ORG="
|
|
139
|
+
exit 1
|
|
140
|
+
fi
|
|
141
|
+
|
|
142
|
+
docker images > /dev/null
|
|
143
|
+
if [ $? -ne 0 ]; then
|
|
144
|
+
echo "docker is not running - this is required to build container images for the UI Plugins"
|
|
145
|
+
exit 1
|
|
146
|
+
fi
|
|
147
|
+
fi
|
|
148
|
+
|
|
149
|
+
ASSETS=${BASE_DIR}/assets
|
|
150
|
+
CHARTS=${BASE_DIR}/charts
|
|
151
|
+
mkdir -p ${ASSETS}
|
|
152
|
+
mkdir -p ${CHARTS}
|
|
153
|
+
|
|
154
|
+
TMP=${BASE_DIR}/tmp
|
|
155
|
+
CHART_TMP=${BASE_DIR}/tmp/_charts
|
|
156
|
+
rm -rf ${TMP}
|
|
157
|
+
mkdir -p ${TMP}
|
|
158
|
+
|
|
159
|
+
CHART_TEMPLATE=${BASE_DIR}/tmp/ui-plugin-server
|
|
160
|
+
|
|
161
|
+
# --------------------------------------------------------------------------------
|
|
162
|
+
# Clone the plugin server template into the temporary folder
|
|
163
|
+
# --------------------------------------------------------------------------------
|
|
164
|
+
pushd ${TMP} > /dev/null
|
|
165
|
+
git clone -q https://github.com/nwmac/ui-plugin-server.git
|
|
166
|
+
popd > /dev/null
|
|
167
|
+
|
|
168
|
+
# --------------------------------------------------------------------------------
|
|
169
|
+
# Iterate through all packages - built them all or build only those specified on the command line
|
|
170
|
+
# --------------------------------------------------------------------------------
|
|
171
|
+
for d in pkg/*/ ; do
|
|
172
|
+
pkg=$(basename $d)
|
|
173
|
+
|
|
174
|
+
if [ -z "$1" ] || [[ " ${PLUGINS[*]} " =~ " ${pkg} " ]]; then
|
|
175
|
+
# Check we don't already have a published version by looking in the assets folder
|
|
176
|
+
PKG_VERSION=$(jq -r .version ./pkg/${pkg}/package.json)
|
|
177
|
+
PKG_NAME="${pkg}-${PKG_VERSION}"
|
|
178
|
+
PKG_ASSET=${ASSETS}/${pkg}/${PKG_NAME}.tgz
|
|
179
|
+
|
|
180
|
+
echo -e "${CYAN}${BOLD}Building plugin: ${pkg} (${PKG_VERSION}) ${RESET}"
|
|
181
|
+
|
|
182
|
+
echo "Package version: ${PKG_VERSION}"
|
|
183
|
+
echo "Package folder: ${PKG_NAME}"
|
|
184
|
+
|
|
185
|
+
# --------------------------------------------------------------------------------
|
|
186
|
+
# Build the plugin from source
|
|
187
|
+
# --------------------------------------------------------------------------------
|
|
188
|
+
echo -e "${CYAN}Building plugin from source code${RESET}"
|
|
189
|
+
FORCE_COLOR=1 yarn build-pkg $pkg | cat
|
|
190
|
+
|
|
191
|
+
if [ "${GITHUB_BUILD}" == "false" ]; then
|
|
192
|
+
# Build the docker image
|
|
193
|
+
${SCRIPT_DIR}/bundle ${pkg} ${PKG_VERSION} ${REGISTRY} ${REGISTRY_ORG} ${IMAGE_PREFIX} ${PUSH}
|
|
194
|
+
else
|
|
195
|
+
echo -e "${CYAN}Adding plugin code ...${RESET}"
|
|
196
|
+
|
|
197
|
+
EXT_FOLDER=${BASE_DIR}/extensions/${pkg}/${PKG_VERSION}
|
|
198
|
+
PKG_DIST="${BASE_DIR}/dist-pkg/${PKG_NAME}"
|
|
199
|
+
|
|
200
|
+
rm -rf ${EXT_FOLDER}
|
|
201
|
+
|
|
202
|
+
mkdir -p ${EXT_FOLDER}/plugin
|
|
203
|
+
|
|
204
|
+
# Copy the code into the folder
|
|
205
|
+
cp -R ${PKG_DIST}/* ${EXT_FOLDER}/plugin
|
|
206
|
+
|
|
207
|
+
pushd ${BASE_DIR}/extensions/${pkg}/${PKG_VERSION} > /dev/null
|
|
208
|
+
rm -f plugin/report.html
|
|
209
|
+
find plugin -type f | sort > files.txt
|
|
210
|
+
popd > /dev/null
|
|
211
|
+
fi
|
|
212
|
+
|
|
213
|
+
rm -rf ${TMP}/container
|
|
214
|
+
|
|
215
|
+
# --------------------------------------------------------------------------------
|
|
216
|
+
# Create the Helm chart
|
|
217
|
+
# --------------------------------------------------------------------------------
|
|
218
|
+
|
|
219
|
+
if [ -f ${PKG_ASSET} ] && [ "${FORCE}" == "false" ]; then
|
|
220
|
+
echo -e "${YELLOW}Helm chart has already been created - skipping (run with -f to force build)${RESET}"
|
|
221
|
+
continue;
|
|
222
|
+
fi
|
|
223
|
+
|
|
224
|
+
CHART_FOLDER=${CHARTS}/${pkg}/${PKG_VERSION}
|
|
225
|
+
|
|
226
|
+
mkdir -p ${ASSETS}/${pkg}
|
|
227
|
+
rm -rf ${CHART_FOLDER}
|
|
228
|
+
mkdir -p ${CHART_FOLDER}
|
|
229
|
+
|
|
230
|
+
cp -R ${CHART_TEMPLATE}/charts/ui-plugin-server/* ${CHART_FOLDER}
|
|
231
|
+
|
|
232
|
+
# Update Chart.yaml and values.yaml from the package file metadata
|
|
233
|
+
# Use the script from the template repository
|
|
234
|
+
echo -e "${CYAN}Patching Helm chart template${RESET}"
|
|
235
|
+
|
|
236
|
+
CHART=${CHART_FOLDER} REGISTRY="${REGISTRY}" ORG="${REGISTRY_ORG}" PACKAGE_JSON=${BASE_DIR}/pkg/${pkg}/package.json ${CHART_TEMPLATE}/scripts/patch
|
|
237
|
+
|
|
238
|
+
# Copy README file from the plugin to the Helm chart, if there is one
|
|
239
|
+
if [ -f "./pkg/${pkg}/README.md" ]; then
|
|
240
|
+
cp ./pkg/${pkg}/README.md ${CHART_FOLDER}/README.md
|
|
241
|
+
fi
|
|
242
|
+
|
|
243
|
+
if [ "${GITHUB_BUILD}" == "true" ]; then
|
|
244
|
+
echo "Patching for GitHub build"
|
|
245
|
+
pushd ${CHART_FOLDER} > /dev/null
|
|
246
|
+
cd templates
|
|
247
|
+
mv cr.yaml temp.cr
|
|
248
|
+
rm *.yaml
|
|
249
|
+
mv temp.cr cr.yaml
|
|
250
|
+
ENDPOINT=https://raw.githubusercontent.com/${GITHUB_SOURCE}/${GITHUB_BRANCH}/extensions/${pkg}/${PKG_VERSION}
|
|
251
|
+
sed -i.bak -e 's@endpoint: .*@endpoint: '"${ENDPOINT}"'@g' cr.yaml
|
|
252
|
+
rm *.bak
|
|
253
|
+
popd > /dev/null
|
|
254
|
+
fi
|
|
255
|
+
|
|
256
|
+
# Additional patches
|
|
257
|
+
${SCRIPT_DIR}/helmpatch ${CHART_FOLDER} "${BASE_DIR}/pkg/${pkg}/package.json" "${REGISTRY}${REGISTRY_ORG}/${IMAGE_PREFIX}${pkg}"
|
|
258
|
+
|
|
259
|
+
# Package into a .tgz helm chart
|
|
260
|
+
helm package ${CHART_FOLDER} -d ${ASSETS}/${pkg}
|
|
261
|
+
|
|
262
|
+
# --------------------------------------------------------------------------------
|
|
263
|
+
# Update the helm index just for this chart
|
|
264
|
+
# --------------------------------------------------------------------------------
|
|
265
|
+
HELM_INDEX=${BASE_DIR}/index.yaml
|
|
266
|
+
|
|
267
|
+
if [ -f "${HELM_INDEX}" ]; then
|
|
268
|
+
UPDATE="--merge ${HELM_INDEX}"
|
|
269
|
+
fi
|
|
270
|
+
|
|
271
|
+
# Base URL referencing assets directly from GitHub
|
|
272
|
+
BASE_URL="assets/${pkg}"
|
|
273
|
+
|
|
274
|
+
rm -rf ${CHART_TMP}
|
|
275
|
+
mkdir -p ${CHART_TMP}
|
|
276
|
+
cp ${ASSETS}/${pkg}/*.tgz ${CHART_TMP}
|
|
277
|
+
|
|
278
|
+
helm repo index ${CHART_TMP} --url ${BASE_URL} ${UPDATE}
|
|
279
|
+
|
|
280
|
+
cp ${CHART_TMP}/index.yaml ${HELM_INDEX}
|
|
281
|
+
|
|
282
|
+
if [ "${GITHUB_BUILD}" == "true" ]; then
|
|
283
|
+
# Make temp directory for workflow build artifact
|
|
284
|
+
mkdir -p tmp/{assets,charts,extensions}/$pkg
|
|
285
|
+
|
|
286
|
+
cp -r ${PKG_ASSET} tmp/assets/$pkg
|
|
287
|
+
cp -r ${CHARTS}/${pkg}/${PKG_VERSION} tmp/charts/$pkg
|
|
288
|
+
cp -r ${EXT_FOLDER} tmp/extensions/$pkg
|
|
289
|
+
fi
|
|
290
|
+
|
|
291
|
+
BUILT="true"
|
|
292
|
+
fi
|
|
293
|
+
done
|
|
294
|
+
|
|
295
|
+
if [ "${GITHUB_BUILD}" == "true" ]; then
|
|
296
|
+
cp index.yaml tmp
|
|
297
|
+
fi
|
|
298
|
+
|
|
299
|
+
if [ "${BUILT}" == "true" ]; then
|
|
300
|
+
echo -e "${CYAN}${BOLD}${CHECK} One or more packages built${RESET}"
|
|
301
|
+
fi
|
|
302
|
+
|
|
303
|
+
# Clean up
|
|
304
|
+
rm -rf ${CHART_TMP}
|
|
305
|
+
|
|
306
|
+
if [ "${GITHUB_BUILD}" == "false" ]; then
|
|
307
|
+
rm -rf ${TMP}
|
|
308
|
+
fi
|
|
309
|
+
|
|
310
|
+
# If the user asked to create a commit, commit the changes
|
|
311
|
+
# if [ "${COMMIT}" == "true" ]; then
|
|
312
|
+
# echo -e "${CYAN}${BOLD}Creating git commit${RESET}"
|
|
313
|
+
# git add --all
|
|
314
|
+
# fi
|
|
@@ -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
|
+
});
|