@rancher/shell 0.5.3 → 1.2.1
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/.DS_Store +0 -0
- package/assets/images/providers/aks-black.svg +28 -0
- package/assets/images/providers/aks.svg +31 -0
- package/assets/styles/global/_labeled-input.scss +1 -0
- package/assets/styles/global/_layout.scss +0 -99
- package/assets/translations/en-us.yaml +76 -74
- package/assets/translations/zh-hans.yaml +25 -23
- package/babel.config.js +1 -7
- package/chart/gatekeeper.vue +11 -2
- package/chart/istio.vue +10 -1
- package/chart/logging/index.vue +11 -2
- package/chart/monitoring/alerting/index.vue +21 -7
- package/chart/monitoring/grafana/index.vue +2 -57
- package/chart/monitoring/index.vue +26 -52
- package/chart/monitoring/prometheus/index.vue +43 -37
- package/chart/rancher-backup/index.vue +10 -3
- package/cloud-credential/azure.vue +17 -4
- package/components/AsyncButton.vue +0 -9
- package/components/Carousel.vue +0 -1
- package/components/ChartPsp.vue +76 -0
- package/components/ClusterIconMenu.vue +9 -24
- package/components/CodeMirror.vue +16 -75
- package/components/CopyCode.vue +2 -6
- package/components/CopyToClipboard.vue +1 -2
- package/components/CopyToClipboardText.vue +9 -14
- package/components/CruResource.vue +0 -1
- package/components/EtcdInfoBanner.vue +5 -5
- package/components/ExplorerProjectsNamespaces.vue +1 -25
- package/components/FixedBanner.vue +0 -1
- package/components/IconOrSvg.vue +1 -1
- package/components/Markdown.vue +12 -16
- package/components/Questions/index.vue +1 -1
- package/components/ResourceDetail/Masthead.vue +9 -25
- package/components/ResourceDetail/index.vue +4 -1
- package/components/ResourceList/Masthead.vue +18 -1
- package/components/ResourceTable.vue +2 -14
- package/components/ResourceYaml.vue +5 -34
- package/components/SideNav.vue +65 -43
- package/components/SortableTable/THead.vue +9 -7
- package/components/SortableTable/index.vue +2 -1
- package/components/StatusTable.vue +1 -5
- package/components/TabTitle.vue +84 -0
- package/components/Tabbed/index.vue +0 -12
- package/components/YamlEditor.vue +0 -1
- package/components/__tests__/ChartPsp.test.ts +75 -0
- package/components/__tests__/CopyCode.test.ts +4 -5
- package/components/fleet/FleetBundles.vue +11 -5
- package/components/fleet/FleetRepos.vue +27 -62
- package/components/fleet/FleetResources.vue +1 -6
- package/components/fleet/FleetStatus.vue +3 -3
- package/components/fleet/FleetSummary.vue +30 -35
- package/components/form/ArrayList.vue +8 -1
- package/components/form/ArrayListSelect.vue +9 -9
- package/components/form/BannerSettings.vue +0 -3
- package/components/form/FileSelector.vue +0 -1
- package/components/form/KeyValue.vue +0 -2
- package/components/form/LabeledSelect.vue +0 -4
- package/components/form/Password.vue +1 -3
- package/components/form/Select.vue +1 -1
- package/components/form/SelectOrCreateAuthSecret.vue +4 -4
- package/components/form/__tests__/KeyValue.test.ts +1 -1
- package/components/formatter/Checked.vue +3 -11
- package/components/formatter/ClusterProvider.vue +18 -1
- package/components/formatter/FleetSummaryGraph.vue +11 -23
- package/components/formatter/LiveDate.vue +16 -0
- package/components/formatter/LiveDuration.vue +1 -1
- package/components/formatter/PercentageBar.vue +1 -1
- package/components/formatter/WorkloadDetailEndpoints.vue +22 -12
- package/components/formatter/__tests__/ClusterProvider.test.ts +28 -0
- package/components/nav/Group.vue +2 -2
- package/components/nav/Header.vue +2 -2
- package/components/nav/Jump.vue +9 -19
- package/components/nav/TopLevelMenu.vue +18 -66
- package/components/nav/Type.vue +7 -16
- package/components/nav/WindowManager/ContainerLogs.vue +19 -120
- package/components/nav/WindowManager/ContainerShell.vue +1 -6
- package/components/nav/WindowManager/index.vue +10 -11
- package/components/nav/__tests__/TopLevelMenu.test.ts +1 -34
- package/components/nav/__tests__/Type.test.ts +1 -31
- package/components/nuxt/nuxt-child.js +78 -14
- package/components/nuxt/nuxt.js +1 -1
- package/components/user.retention/user-retention-header.vue +34 -0
- package/composables/useI18n.ts +26 -0
- package/composables/useStore.ts +16 -0
- package/config/harvester-manager-types.js +0 -2
- package/config/home-links.js +32 -2
- package/config/private-label.js +0 -22
- package/config/product/explorer.js +4 -4
- package/config/product/fleet.js +1 -6
- package/config/product/legacy.js +1 -84
- package/config/product/manager.js +15 -8
- package/config/query-params.js +0 -1
- package/config/router.js +368 -385
- package/config/settings.ts +9 -2
- package/config/store.js +1 -1
- package/config/system-namespaces.js +0 -3
- package/config/table-headers.js +27 -47
- package/config/types.js +5 -0
- package/config/uiplugins.js +1 -1
- package/core/plugin-helpers.js +5 -3
- package/core/plugin-routes.ts +114 -56
- package/core/plugin.ts +10 -16
- package/core/plugins-loader.js +9 -7
- package/core/plugins.js +3 -0
- package/core/types-provisioning.ts +0 -7
- package/creators/app/init +0 -19
- package/detail/fleet.cattle.io.bundle.vue +1 -1
- package/detail/fleet.cattle.io.cluster.vue +1 -11
- package/detail/node.vue +0 -42
- package/detail/pod.vue +1 -68
- package/detail/provisioning.cattle.io.cluster.vue +8 -25
- package/detail/workload/index.vue +1 -15
- package/dialog/ScaleMachineDownDialog.vue +17 -34
- package/edit/auth/googleoauth.vue +5 -1
- package/edit/catalog.cattle.io.clusterrepo.vue +7 -20
- package/edit/cloudcredential.vue +0 -2
- package/edit/fleet.cattle.io.gitrepo.vue +4 -3
- package/edit/management.cattle.io.project.vue +52 -1
- package/edit/management.cattle.io.setting.vue +2 -32
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/opsgenie.vue +1 -1
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/pagerduty.vue +2 -1
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/slack.vue +1 -1
- package/edit/monitoring.coreos.com.prometheusrule/AlertingRule.vue +3 -12
- package/edit/monitoring.coreos.com.prometheusrule/GroupRules.vue +1 -2
- package/edit/networking.k8s.io.networkpolicy/__tests__/PolicyRuleTarget.spec.ts +1 -1
- package/edit/provisioning.cattle.io.cluster/{tabs/Basics.vue → Basics.vue} +125 -106
- package/edit/provisioning.cattle.io.cluster/{tabs/MachinePool.vue → MachinePool.vue} +7 -1
- package/edit/provisioning.cattle.io.cluster/SelectCredential.vue +7 -15
- package/edit/provisioning.cattle.io.cluster/__tests__/Basics.tests.ts +237 -0
- package/edit/provisioning.cattle.io.cluster/__tests__/{CustomCommand.test.ts → CustomCommand.tests.ts} +0 -6
- package/edit/provisioning.cattle.io.cluster/__tests__/DrainOptions.test.ts +1 -1
- package/edit/provisioning.cattle.io.cluster/__tests__/rke2.test.ts +1 -7
- package/edit/provisioning.cattle.io.cluster/import.vue +2 -2
- package/edit/provisioning.cattle.io.cluster/index.vue +40 -109
- package/edit/provisioning.cattle.io.cluster/rke2.vue +689 -152
- package/edit/service.vue +0 -12
- package/edit/token.vue +0 -1
- package/edit/workload/Upgrading.vue +2 -3
- package/edit/workload/index.vue +1 -2
- package/edit/workload/mixins/workload.js +1 -1
- package/initialize/App.js +71 -25
- package/initialize/client.js +162 -21
- package/initialize/index.js +124 -47
- package/initialize/layouts.ts +26 -0
- package/{components/templates → layouts}/blank.vue +1 -1
- package/{components/templates → layouts}/default.vue +98 -8
- package/{components/templates → layouts}/error.vue +19 -10
- package/{components/templates → layouts}/home.vue +1 -4
- package/{components/templates → layouts}/plain.vue +1 -4
- package/{components/templates → layouts}/standalone.vue +1 -1
- package/{components/templates → layouts}/unauthenticated.vue +1 -1
- package/list/catalog.cattle.io.app.vue +0 -1
- package/list/management.cattle.io.feature.vue +7 -1
- package/list/management.cattle.io.setting.vue +0 -1
- package/list/management.cattle.io.user.vue +25 -1
- package/list/node.vue +0 -1
- package/machine-config/__tests__/vmwarevsphere.test.ts +161 -56
- package/machine-config/azure.vue +37 -21
- package/machine-config/vmwarevsphere.vue +47 -42
- package/middleware/authenticated.js +19 -14
- package/mixins/auth-config.js +7 -2
- package/mixins/brand.js +41 -29
- package/mixins/fetch.server.js +73 -0
- package/mixins/labeled-form-element.ts +1 -6
- package/models/__tests__/management.cattle.io.node.ts +0 -85
- package/models/__tests__/namespace.test.ts +9 -49
- package/models/cluster/node.js +4 -4
- package/models/cluster.x-k8s.io.machine.js +1 -1
- package/models/cluster.x-k8s.io.machinedeployment.js +0 -14
- package/models/fleet.cattle.io.cluster.js +0 -4
- package/models/fleet.cattle.io.gitrepo.js +13 -56
- package/models/management.cattle.io.cluster.js +3 -11
- package/models/management.cattle.io.kontainerdriver.js +0 -1
- package/models/management.cattle.io.node.js +14 -18
- package/models/management.cattle.io.nodepool.js +0 -17
- package/models/management.cattle.io.project.js +36 -0
- package/models/management.cattle.io.setting.js +7 -11
- package/models/management.cattle.io.user.js +65 -0
- package/models/namespace.js +1 -1
- package/models/pod.js +0 -20
- package/models/provisioning.cattle.io.cluster.js +9 -91
- package/models/secret.js +18 -126
- package/models/storage.k8s.io.storageclass.js +1 -1
- package/models/workload.js +0 -16
- package/models/workload.service.js +0 -18
- package/package.json +10 -12
- package/pages/about.vue +1 -0
- package/pages/account/create-key.vue +1 -0
- package/pages/account/index.vue +1 -0
- package/pages/auth/login.vue +1 -0
- package/pages/auth/logout.vue +2 -0
- package/pages/auth/setup.vue +4 -37
- package/pages/auth/verify.vue +8 -14
- package/pages/c/_cluster/apps/charts/__tests__/install.helper.test.ts +17 -2
- package/pages/c/_cluster/apps/charts/index.vue +58 -64
- package/pages/c/_cluster/apps/charts/install.helpers.js +13 -2
- package/pages/c/_cluster/apps/charts/install.vue +5 -5
- package/pages/c/_cluster/apps/index.vue +2 -0
- package/pages/c/_cluster/auth/index.vue +2 -0
- package/pages/c/_cluster/auth/user.retention/index.vue +384 -0
- package/pages/c/_cluster/ecm/index.vue +2 -0
- package/pages/c/_cluster/explorer/index.vue +53 -56
- package/pages/c/_cluster/explorer/tools/index.vue +3 -171
- package/pages/c/_cluster/fleet/index.vue +1 -1
- package/pages/c/_cluster/index.vue +2 -0
- package/pages/c/_cluster/manager/pages/_page.vue +5 -4
- package/pages/c/_cluster/monitoring/index.vue +1 -17
- package/pages/c/_cluster/settings/DefaultLinksEditor.vue +1 -1
- package/pages/c/_cluster/settings/banners.vue +2 -0
- package/pages/c/_cluster/settings/brand.vue +2 -3
- package/pages/c/_cluster/settings/index.vue +2 -0
- package/pages/c/_cluster/settings/links.vue +3 -2
- package/pages/c/_cluster/settings/performance.vue +1 -0
- package/pages/c/_cluster/uiplugins/CatalogList/CatalogLoadDialog.vue +1 -2
- package/pages/c/_cluster/uiplugins/CatalogList/index.vue +46 -10
- package/pages/c/_cluster/uiplugins/index.vue +2 -0
- package/pages/c/index.vue +9 -0
- package/pages/diagnostic.vue +2 -1
- package/pages/fail-whale.vue +1 -0
- package/pages/prefs.vue +1 -0
- package/pages/rio/mesh.vue +508 -0
- package/pages/support/index.vue +8 -2
- package/pkg/auto-import.js +1 -1
- package/plugins/axios.js +36 -0
- package/plugins/back-button.js +5 -3
- package/plugins/clean-html-directive.js +19 -1
- package/plugins/clean-tooltip-directive.js +1 -1
- package/plugins/codemirror-loader.js +1 -1
- package/plugins/codemirror.js +0 -41
- package/plugins/dashboard-store/__tests__/{mutations.test.ts → mutations.spec.ts} +1 -1
- package/plugins/dashboard-store/actions.js +17 -16
- package/plugins/dashboard-store/classify.js +18 -1
- package/plugins/dashboard-store/getters.js +7 -70
- package/plugins/dashboard-store/index.js +12 -0
- package/plugins/dashboard-store/mutations.js +4 -0
- package/plugins/dashboard-store/resource-class.js +20 -65
- package/plugins/i18n.js +1 -1
- package/plugins/steve/__tests__/getters.spec.ts +48 -26
- package/plugins/steve/__tests__/subscribe.spec.ts +106 -0
- package/plugins/steve/actions.js +37 -3
- package/plugins/steve/getters.js +24 -7
- package/plugins/steve/mutations.js +5 -2
- package/plugins/steve/norman-class.js +0 -19
- package/plugins/steve/steve-class.js +0 -22
- package/plugins/steve/subscribe.js +34 -13
- package/plugins/transitions.js +4 -0
- package/plugins/vue-clipboard2.js +4 -0
- package/rancher-components/Accordion/Accordion.vue +3 -2
- package/rancher-components/BadgeState/BadgeState.vue +3 -3
- package/rancher-components/Banner/Banner.test.ts +1 -5
- package/rancher-components/Banner/Banner.vue +2 -2
- package/rancher-components/Card/Card.vue +4 -4
- package/rancher-components/Form/Checkbox/Checkbox.vue +4 -3
- package/rancher-components/Form/LabeledInput/LabeledInput.test.ts +1 -1
- package/rancher-components/Form/LabeledInput/LabeledInput.vue +55 -24
- package/rancher-components/Form/Radio/RadioButton.test.ts +1 -3
- package/rancher-components/Form/Radio/RadioButton.vue +13 -7
- package/rancher-components/Form/Radio/RadioGroup.vue +4 -3
- package/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +7 -5
- package/rancher-components/Form/ToggleSwitch/ToggleSwitch.vue +7 -4
- package/rancher-components/LabeledTooltip/LabeledTooltip.vue +9 -4
- package/rancher-components/StringList/StringList.vue +8 -8
- package/rancher-components/components/Accordion/Accordion.vue +3 -2
- package/rancher-components/components/BadgeState/BadgeState.test.ts +12 -0
- package/rancher-components/components/Form/LabeledInput/LabeledInput.test.ts +2 -19
- package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +14 -11
- package/rancher-components/components/Form/TextArea/TextAreaAutoGrow.vue +1 -1
- package/rancher-components/components/StringList/StringList.test.ts +0 -270
- package/rancher-components/components/StringList/StringList.vue +18 -57
- package/scripts/extension/bundle +7 -19
- package/scripts/extension/helm/scripts/package +3 -11
- package/scripts/extension/parse-tag-name +4 -4
- package/scripts/extension/publish +9 -20
- package/scripts/publish-shell.sh +1 -11
- package/scripts/test-plugins-build.sh +9 -85
- package/store/catalog.js +1 -1
- package/store/features.js +0 -1
- package/store/i18n.js +0 -11
- package/store/index.js +13 -11
- package/store/prefs.js +38 -33
- package/store/type-map.js +82 -157
- package/tsconfig.default.json +46 -0
- package/tsconfig.json +9 -35
- package/types/shell/index.d.ts +407 -468
- package/utils/axios.js +19 -0
- package/utils/create-yaml.js +1 -5
- package/utils/custom-validators.js +2 -0
- package/utils/error.js +1 -16
- package/utils/monitoring.js +2 -37
- package/utils/nuxt.js +39 -18
- package/utils/object.js +0 -24
- package/utils/router.scrollBehavior.js +14 -12
- package/utils/socket.js +1 -0
- package/utils/time.js +1 -1
- package/utils/title.ts +3 -0
- package/utils/url.ts +1 -1
- package/utils/validators/formRules/__tests__/index.test.ts +4 -49
- package/utils/validators/formRules/index.ts +9 -12
- package/utils/validators/setting.js +10 -6
- package/vue.config.js +3 -24
- package/chart/monitoring/steps/uninstall-v1.vue +0 -135
- package/components/Certificates.vue +0 -164
- package/components/__tests__/CodeMirror.spec.ts +0 -99
- package/components/fleet/__tests__/FleetSummary.test.ts +0 -316
- package/components/formatter/FleetClusterSummaryGraph.vue +0 -27
- package/components/formatter/__tests__/Checked.test.ts +0 -19
- package/components/formatter/__tests__/WorkloadDetailEndpoints.test.ts +0 -81
- package/components/nav/WindowManager/__tests__/ContainerLogs.test.ts +0 -186
- package/composables/useCompactInput.ts +0 -20
- package/composables/useLabeledFormElement.ts +0 -138
- package/creators/app/files/.gitlab-ci.yml +0 -14
- package/detail/__tests__/provisioning.cattle.io.cluster.test.ts +0 -77
- package/edit/__tests__/service.test.ts +0 -89
- package/edit/provisioning.cattle.io.cluster/__tests__/Advanced.test.ts +0 -112
- package/edit/provisioning.cattle.io.cluster/__tests__/Basics.test.ts +0 -473
- package/edit/provisioning.cattle.io.cluster/__tests__/index.test.ts +0 -73
- package/edit/provisioning.cattle.io.cluster/__tests__/utils/cluster.ts +0 -386
- package/edit/provisioning.cattle.io.cluster/tabs/AddOnConfig.vue +0 -137
- package/edit/provisioning.cattle.io.cluster/tabs/Advanced.vue +0 -157
- package/edit/provisioning.cattle.io.cluster/tabs/etcd/index.vue +0 -135
- package/edit/provisioning.cattle.io.cluster/tabs/networking/index.vue +0 -189
- package/edit/provisioning.cattle.io.cluster/tabs/registries/index.vue +0 -147
- package/edit/provisioning.cattle.io.cluster/tabs/upgrade/index.vue +0 -76
- package/mixins/v1-workload-metrics.js +0 -43
- package/models/__tests__/management.cattle.io.cluster.test.ts +0 -23
- package/models/__tests__/management.cattle.io.nodepool.ts +0 -83
- package/models/__tests__/provisioning.cattle.io.cluster.test.ts +0 -241
- package/models/__tests__/secret.test.ts +0 -37
- package/models/__tests__/storage.k8s.io.storageclass.test.ts +0 -22
- package/models/__tests__/workload.test.ts +0 -91
- package/plugins/clean-html.js +0 -53
- package/plugins/dashboard-store/__tests__/resource-class.test.ts +0 -49
- package/plugins/dashboard-store/__tests__/utils/store-mocks.ts +0 -7
- package/plugins/index.js +0 -11
- package/plugins/steve/__tests__/resource-utils.test.ts +0 -159
- package/plugins/steve/__tests__/steve-class.spec.ts +0 -59
- package/plugins/steve/__tests__/utils/steve-mocks.ts +0 -31
- package/plugins/steve/resource-utils.ts +0 -38
- package/scripts/.gitlab/workflows/build-extension-catalog.gitlab-ci.yml +0 -50
- package/server/har-file.js +0 -183
- package/store/__tests__/type-map.test.ts +0 -1122
- package/tsconfig.paths.json +0 -18
- package/utils/azure.js +0 -24
- package/utils/clipboard.js +0 -5
- /package/components/form/__tests__/{NameNsDescription.test.ts → NameNsDescription.ts} +0 -0
- /package/edit/networking.k8s.io.networkpolicy/__tests__/utils/{selectors.test.ts → selectors.ts} +0 -0
- /package/edit/provisioning.cattle.io.cluster/{tabs/networking/ACE.vue → ACE.vue} +0 -0
- /package/edit/provisioning.cattle.io.cluster/{tabs/AgentConfiguration.vue → AgentConfiguration.vue} +0 -0
- /package/edit/provisioning.cattle.io.cluster/{tabs/upgrade/DrainOptions.vue → DrainOptions.vue} +0 -0
- /package/edit/provisioning.cattle.io.cluster/{tabs/MemberRoles.vue → MemberRoles.vue} +0 -0
- /package/edit/provisioning.cattle.io.cluster/{tabs/registries/RegistryConfigs.vue → RegistryConfigs.vue} +0 -0
- /package/edit/provisioning.cattle.io.cluster/{tabs/registries/RegistryMirrors.vue → RegistryMirrors.vue} +0 -0
- /package/edit/provisioning.cattle.io.cluster/{tabs/etcd/S3Config.vue → S3Config.vue} +0 -0
- /package/plugins/dashboard-store/__tests__/{actions.test.ts → actions.spec.ts} +0 -0
- /package/plugins/dashboard-store/__tests__/{getters.test.ts → getters.spec.ts} +0 -0
- /package/rancher-components/BadgeState/{BadgeState.spec.ts → BadgeState.test.ts} +0 -0
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import ProvCluster from '@shell/models/provisioning.cattle.io.cluster';
|
|
2
|
-
|
|
3
|
-
describe('class ProvCluster', () => {
|
|
4
|
-
const importedClusterInfo = {
|
|
5
|
-
clusterName: 'test', provisioner: 'imported', mgmt: { spec: { gkeConfig: {} } }, spec: {}
|
|
6
|
-
};
|
|
7
|
-
const importedGkeClusterInfo = {
|
|
8
|
-
clusterName: 'test', provisioner: 'rke2', mgmt: { spec: { gkeConfig: { imported: true } } }
|
|
9
|
-
};
|
|
10
|
-
const importedAksClusterInfo = {
|
|
11
|
-
clusterName: 'test', provisioner: 'rke2', mgmt: { spec: { aksConfig: { imported: true } } }
|
|
12
|
-
};
|
|
13
|
-
const importedEksClusterInfo = {
|
|
14
|
-
clusterName: 'test', provisioner: 'rke2', mgmt: { spec: { eksConfig: { imported: true } } }
|
|
15
|
-
};
|
|
16
|
-
const notImportedGkeClusterInfo = {
|
|
17
|
-
clusterName: 'test', provisioner: 'rke2', mgmt: { spec: { gkeConfig: { imported: false } }, rkeConfig: {} }
|
|
18
|
-
};
|
|
19
|
-
const importedClusterInfoWithProviderForEmberParam = {
|
|
20
|
-
clusterName: 'test', provisioner: 'rke2', mgmt: { providerForEmberParam: 'import' }
|
|
21
|
-
};
|
|
22
|
-
const localClusterInfo = {
|
|
23
|
-
clusterName: 'test', provisioner: 'imported', mgmt: { isLocal: true, spec: { gkeConfig: {} } }, spec: {}
|
|
24
|
-
};
|
|
25
|
-
const doRke2Info = {
|
|
26
|
-
clusterName: 'test', provisioner: 'rke2', mgmt: { isLocal: false, providerForEmberParam: 'import' }, spec: { rkeConfig: {} }
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const gkeClusterWithPrivateEndpoint = {
|
|
30
|
-
clusterName: 'test',
|
|
31
|
-
provisioner: 'GKE',
|
|
32
|
-
spec: { rkeConfig: {} },
|
|
33
|
-
mgmt: { spec: { gkeConfig: { privateClusterConfig: { enablePrivateEndpoint: true } } } }
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const eksClusterWithPrivateEndpoint = {
|
|
37
|
-
clusterName: 'test',
|
|
38
|
-
provisioner: 'EKS',
|
|
39
|
-
spec: { rkeConfig: {} },
|
|
40
|
-
mgmt: { spec: { eksConfig: { privateAccess: true } } }
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const aksClusterWithPrivateEndpoint = {
|
|
44
|
-
clusterName: 'test',
|
|
45
|
-
provisioner: 'AKS',
|
|
46
|
-
spec: { rkeConfig: {} },
|
|
47
|
-
mgmt: { spec: { aksConfig: { privateCluster: true } } }
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// Related to https://github.com/rancher/dashboard/issues/9402
|
|
51
|
-
describe('isHostedKubernetesProvider + isPrivateHostedProvider', () => {
|
|
52
|
-
const testCases = [
|
|
53
|
-
[gkeClusterWithPrivateEndpoint, true],
|
|
54
|
-
[eksClusterWithPrivateEndpoint, true],
|
|
55
|
-
[aksClusterWithPrivateEndpoint, true],
|
|
56
|
-
];
|
|
57
|
-
const resetMocks = () => {
|
|
58
|
-
// Clear all mock function calls:
|
|
59
|
-
jest.clearAllMocks();
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
it.each(testCases)('should return the isHostedKubernetesProvider and isPrivateHostedProvider values properly based on the props data', (clusterData: Object, expected: Boolean) => {
|
|
63
|
-
const cluster = new ProvCluster({ spec: clusterData.spec });
|
|
64
|
-
|
|
65
|
-
jest.spyOn(cluster, 'mgmt', 'get').mockReturnValue(
|
|
66
|
-
clusterData.mgmt
|
|
67
|
-
);
|
|
68
|
-
jest.spyOn(cluster, 'provisioner', 'get').mockReturnValue(
|
|
69
|
-
clusterData.provisioner
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
expect(cluster.isRke2).toBe(expected);
|
|
73
|
-
expect(cluster.isHostedKubernetesProvider).toBe(expected);
|
|
74
|
-
expect(cluster.isPrivateHostedProvider).toBe(expected);
|
|
75
|
-
resetMocks();
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe('isImported', () => {
|
|
80
|
-
const testCases = [
|
|
81
|
-
[importedClusterInfo, true],
|
|
82
|
-
[importedGkeClusterInfo, true],
|
|
83
|
-
[importedAksClusterInfo, true],
|
|
84
|
-
[importedEksClusterInfo, true],
|
|
85
|
-
[notImportedGkeClusterInfo, false],
|
|
86
|
-
[importedClusterInfoWithProviderForEmberParam, true],
|
|
87
|
-
[localClusterInfo, false],
|
|
88
|
-
[doRke2Info, false],
|
|
89
|
-
[{}, false],
|
|
90
|
-
];
|
|
91
|
-
const resetMocks = () => {
|
|
92
|
-
// Clear all mock function calls:
|
|
93
|
-
jest.clearAllMocks();
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
it.each(testCases)('should return the isImported value properly based on the props data', (clusterData: Object, expected: Boolean) => {
|
|
97
|
-
const cluster = new ProvCluster({ spec: clusterData.spec });
|
|
98
|
-
|
|
99
|
-
jest.spyOn(cluster, 'mgmt', 'get').mockReturnValue(
|
|
100
|
-
clusterData.mgmt
|
|
101
|
-
);
|
|
102
|
-
jest.spyOn(cluster, 'provisioner', 'get').mockReturnValue(
|
|
103
|
-
clusterData.provisioner
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
expect(cluster.isImported).toBe(expected);
|
|
107
|
-
resetMocks();
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
describe('mgmt', () => {
|
|
113
|
-
const testCases = [
|
|
114
|
-
[importedClusterInfo, importedClusterInfo.mgmt],
|
|
115
|
-
[importedGkeClusterInfo, importedGkeClusterInfo.mgmt],
|
|
116
|
-
[importedAksClusterInfo, importedAksClusterInfo.mgmt],
|
|
117
|
-
[importedEksClusterInfo, importedEksClusterInfo.mgmt],
|
|
118
|
-
[notImportedGkeClusterInfo, notImportedGkeClusterInfo.mgmt],
|
|
119
|
-
[importedClusterInfoWithProviderForEmberParam, importedClusterInfoWithProviderForEmberParam.mgmt],
|
|
120
|
-
[localClusterInfo, localClusterInfo.mgmt],
|
|
121
|
-
[doRke2Info, doRke2Info.mgmt],
|
|
122
|
-
[{}, null],
|
|
123
|
-
];
|
|
124
|
-
|
|
125
|
-
const resetMocks = () => {
|
|
126
|
-
// Clear all mock function calls:
|
|
127
|
-
jest.clearAllMocks();
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
it.each(testCases)('should return the isImported value properly based on the props data', (clusterData: Object, expected: Object) => {
|
|
131
|
-
const clusterMock = jest.fn(() => clusterData.mgmt);
|
|
132
|
-
const ctx = { rootGetters: { 'management/byId': clusterMock } };
|
|
133
|
-
const cluster = new ProvCluster({ status: { clusterName: clusterData.clusterName } }, ctx);
|
|
134
|
-
|
|
135
|
-
expect(cluster.mgmt).toBe(expected);
|
|
136
|
-
resetMocks();
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
describe('hasError', () => {
|
|
141
|
-
const conditionsWithoutError = [
|
|
142
|
-
{
|
|
143
|
-
error: false,
|
|
144
|
-
lastUpdateTime: '2022-10-17T23:09:15Z',
|
|
145
|
-
status: 'True',
|
|
146
|
-
transitioning: false,
|
|
147
|
-
type: 'Ready'
|
|
148
|
-
},
|
|
149
|
-
];
|
|
150
|
-
|
|
151
|
-
const conditionsWithoutReady = [
|
|
152
|
-
{
|
|
153
|
-
error: true,
|
|
154
|
-
lastUpdateTime: '2022-10-17T23:09:15Z',
|
|
155
|
-
status: 'False',
|
|
156
|
-
message: 'some-error-message',
|
|
157
|
-
transitioning: false,
|
|
158
|
-
type: 'Pending'
|
|
159
|
-
},
|
|
160
|
-
];
|
|
161
|
-
|
|
162
|
-
const noConditions:[] = [];
|
|
163
|
-
|
|
164
|
-
const conditionsWithReadyLatest = [
|
|
165
|
-
{
|
|
166
|
-
error: true,
|
|
167
|
-
lastUpdateTime: '2022-10-17T23:09:15Z',
|
|
168
|
-
status: 'False',
|
|
169
|
-
message: 'some-error-message',
|
|
170
|
-
transitioning: false,
|
|
171
|
-
type: 'Pending'
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
error: false,
|
|
175
|
-
lastUpdateTime: '2023-10-17T23:09:15Z',
|
|
176
|
-
status: 'True',
|
|
177
|
-
transitioning: false,
|
|
178
|
-
type: 'Ready'
|
|
179
|
-
}
|
|
180
|
-
];
|
|
181
|
-
|
|
182
|
-
const conditionsWithErrorLatest = [
|
|
183
|
-
{
|
|
184
|
-
error: false,
|
|
185
|
-
lastUpdateTime: '2022-10-17T23:09:15Z',
|
|
186
|
-
status: 'True',
|
|
187
|
-
transitioning: false,
|
|
188
|
-
type: 'Ready'
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
error: true,
|
|
192
|
-
lastUpdateTime: '2023-10-17T23:09:15Z',
|
|
193
|
-
status: 'False',
|
|
194
|
-
message: 'some-error-message',
|
|
195
|
-
transitioning: false,
|
|
196
|
-
type: 'Pending'
|
|
197
|
-
}
|
|
198
|
-
];
|
|
199
|
-
|
|
200
|
-
const conditionsWithProblemInLastUpdateTimeProp = [
|
|
201
|
-
{
|
|
202
|
-
error: true,
|
|
203
|
-
lastUpdateTime: '',
|
|
204
|
-
status: 'False',
|
|
205
|
-
message: 'some-error-message',
|
|
206
|
-
transitioning: false,
|
|
207
|
-
type: 'Pending'
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
error: false,
|
|
211
|
-
lastUpdateTime: '2023-10-17T23:09:15Z',
|
|
212
|
-
status: 'True',
|
|
213
|
-
transitioning: false,
|
|
214
|
-
type: 'Ready'
|
|
215
|
-
}
|
|
216
|
-
];
|
|
217
|
-
|
|
218
|
-
const testCases = [
|
|
219
|
-
['conditionsWithoutError', conditionsWithoutError, false],
|
|
220
|
-
['conditionsWithoutReady', conditionsWithoutReady, true],
|
|
221
|
-
['noConditions', noConditions, false],
|
|
222
|
-
['conditionsWithReadyLatest', conditionsWithReadyLatest, false],
|
|
223
|
-
['conditionsWithErrorLatest', conditionsWithErrorLatest, true],
|
|
224
|
-
['conditionsWithProblemInLastUpdateTimeProp', conditionsWithProblemInLastUpdateTimeProp, false],
|
|
225
|
-
];
|
|
226
|
-
|
|
227
|
-
const resetMocks = () => {
|
|
228
|
-
// Clear all mock function calls
|
|
229
|
-
jest.clearAllMocks();
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
it.each(testCases)('should return the hasError value properly based on the "status.conditions" props data for testcase %p', (testName: string, conditions: Array, expected: Boolean) => {
|
|
233
|
-
const ctx = { rootGetters: { 'management/byId': jest.fn() } };
|
|
234
|
-
const cluster = new ProvCluster({ status: { conditions } }, ctx);
|
|
235
|
-
|
|
236
|
-
expect(cluster.hasError).toBe(expected);
|
|
237
|
-
resetMocks();
|
|
238
|
-
}
|
|
239
|
-
);
|
|
240
|
-
});
|
|
241
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import Secret from '@shell/models/secret';
|
|
2
|
-
|
|
3
|
-
describe('class Secret', () => {
|
|
4
|
-
it('should contains the type attribute if cleanForDownload', async() => {
|
|
5
|
-
const secret = new Secret({});
|
|
6
|
-
const yaml = `apiVersion: v1
|
|
7
|
-
kind: Secret
|
|
8
|
-
metadata:
|
|
9
|
-
name: my-secret
|
|
10
|
-
type: Opaque
|
|
11
|
-
`;
|
|
12
|
-
const cleanYaml = await secret.cleanForDownload(yaml);
|
|
13
|
-
|
|
14
|
-
expect(cleanYaml).toBe(yaml);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should remove id, links and actions keys if cleanForDownload', async() => {
|
|
18
|
-
const secret = new Secret({});
|
|
19
|
-
const expectedYamlStr = `apiVersion: v1
|
|
20
|
-
kind: Secret
|
|
21
|
-
metadata:
|
|
22
|
-
name: my-secret
|
|
23
|
-
namespace: default
|
|
24
|
-
type: Opaque
|
|
25
|
-
`;
|
|
26
|
-
const part = `id: test_id
|
|
27
|
-
links:
|
|
28
|
-
view: https://example.com
|
|
29
|
-
actions:
|
|
30
|
-
remove: https://example.com`;
|
|
31
|
-
const yaml = `${ expectedYamlStr }
|
|
32
|
-
${ part }`;
|
|
33
|
-
const cleanYaml = await secret.cleanForDownload(yaml);
|
|
34
|
-
|
|
35
|
-
expect(cleanYaml).toBe(expectedYamlStr);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import StorageClass, { PROVISIONER_OPTIONS } from '@shell/models/storage.k8s.io.storageclass';
|
|
2
|
-
|
|
3
|
-
describe('class StorageClass', () => {
|
|
4
|
-
describe('checking if provisionerDisplay', () => {
|
|
5
|
-
it.each([
|
|
6
|
-
['kubernetes.io/azure-disk', true],
|
|
7
|
-
['kubernetes.io/portworx-volume', true],
|
|
8
|
-
['rancher.io/local-path', false],
|
|
9
|
-
['some-random-string-as-provisioner', false],
|
|
10
|
-
])('should NOT show a suffix IF they are built-in (on the PROVISIONER_OPTIONS list)', (provisioner, expectation) => {
|
|
11
|
-
const storageClass = new StorageClass({
|
|
12
|
-
metadata: {},
|
|
13
|
-
spec: {},
|
|
14
|
-
provisioner
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
jest.spyOn(storageClass, '$rootGetters', 'get').mockReturnValue({ 'i18n/t': jest.fn() });
|
|
18
|
-
|
|
19
|
-
expect(!!PROVISIONER_OPTIONS.find((opt) => opt.value === provisioner)).toBe(expectation);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
});
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import Workload from '@shell/models/workload.js';
|
|
2
|
-
import { steveClassJunkObject } from '@shell/plugins/steve/__tests__/utils/steve-mocks';
|
|
3
|
-
|
|
4
|
-
describe('class: Workload', () => {
|
|
5
|
-
describe('given custom workload keys', () => {
|
|
6
|
-
const customContainerImage = 'image';
|
|
7
|
-
const customContainer = {
|
|
8
|
-
image: customContainerImage,
|
|
9
|
-
__active: 'whatever',
|
|
10
|
-
active: 'whatever',
|
|
11
|
-
_init: 'whatever',
|
|
12
|
-
error: 'whatever',
|
|
13
|
-
};
|
|
14
|
-
const customWorkload = {
|
|
15
|
-
...steveClassJunkObject,
|
|
16
|
-
type: '123abv',
|
|
17
|
-
__rehydrate: 'whatever',
|
|
18
|
-
__clone: 'whatever',
|
|
19
|
-
spec: {
|
|
20
|
-
template: {
|
|
21
|
-
spec: {
|
|
22
|
-
containers: [customContainer],
|
|
23
|
-
initContainers: [customContainer],
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
customWorkload.metadata.name = 'abc';
|
|
30
|
-
|
|
31
|
-
it('should keep internal keys', () => {
|
|
32
|
-
const workload = new Workload(customWorkload, {
|
|
33
|
-
getters: { schemaFor: () => ({ linkFor: jest.fn() }) },
|
|
34
|
-
dispatch: jest.fn(),
|
|
35
|
-
rootGetters: { 'i18n/t': jest.fn() },
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
expect({ ...workload }).toStrictEqual(customWorkload);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe('method: save', () => {
|
|
42
|
-
it('should remove all the internal keys', async() => {
|
|
43
|
-
const dispatch = jest.fn();
|
|
44
|
-
const workload = new Workload(customWorkload, {
|
|
45
|
-
getters: { schemaFor: () => ({ linkFor: jest.fn() }) },
|
|
46
|
-
dispatch,
|
|
47
|
-
rootGetters: {
|
|
48
|
-
'i18n/t': jest.fn(),
|
|
49
|
-
'i18n/exists': () => true,
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
const expectation = {
|
|
53
|
-
metadata: {
|
|
54
|
-
name: 'abc',
|
|
55
|
-
fields: 'whatever',
|
|
56
|
-
resourceVersion: 'whatever',
|
|
57
|
-
clusterName: 'whatever',
|
|
58
|
-
deletionGracePeriodSeconds: 'whatever',
|
|
59
|
-
generateName: 'whatever',
|
|
60
|
-
},
|
|
61
|
-
spec: {
|
|
62
|
-
template: {
|
|
63
|
-
spec: {
|
|
64
|
-
containers: [{ image: customContainerImage }],
|
|
65
|
-
initContainers: [{ image: customContainerImage }]
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
await workload.save();
|
|
72
|
-
|
|
73
|
-
const opt = {
|
|
74
|
-
data: expectation,
|
|
75
|
-
headers: {
|
|
76
|
-
accept: 'application/json',
|
|
77
|
-
'content-type': 'application/json',
|
|
78
|
-
},
|
|
79
|
-
method: 'post',
|
|
80
|
-
url: undefined,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// Data sent should have been cleaned
|
|
84
|
-
expect(dispatch).toHaveBeenCalledWith('request', { opt, type: customWorkload.type });
|
|
85
|
-
|
|
86
|
-
// Original workload model should remain unchanged
|
|
87
|
-
expect({ ...workload }).toStrictEqual(customWorkload);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
});
|
package/plugins/clean-html.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import DOMPurify from 'dompurify';
|
|
2
|
-
import { uniq } from '@shell/utils/array';
|
|
3
|
-
|
|
4
|
-
const ALLOWED_TAGS = [
|
|
5
|
-
'code',
|
|
6
|
-
'li',
|
|
7
|
-
'a',
|
|
8
|
-
'p',
|
|
9
|
-
'b',
|
|
10
|
-
'br',
|
|
11
|
-
'ul',
|
|
12
|
-
'pre',
|
|
13
|
-
'span',
|
|
14
|
-
'div',
|
|
15
|
-
'i',
|
|
16
|
-
'em',
|
|
17
|
-
'strong',
|
|
18
|
-
'h1',
|
|
19
|
-
'h2',
|
|
20
|
-
'h3',
|
|
21
|
-
'h4',
|
|
22
|
-
'h5',
|
|
23
|
-
'h6',
|
|
24
|
-
'table',
|
|
25
|
-
'thead',
|
|
26
|
-
'tr',
|
|
27
|
-
'th',
|
|
28
|
-
'tbody',
|
|
29
|
-
'td',
|
|
30
|
-
'blockquote'
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
// Allow 'A' tags to keep the target=_blank attribute if they have it
|
|
34
|
-
DOMPurify.addHook('uponSanitizeAttribute', (node, data) => {
|
|
35
|
-
if (node.tagName === 'A' && data.attrName === 'target' && data.attrValue === '_blank') {
|
|
36
|
-
data.forceKeepAttr = true;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Ensure if an 'A' tag has target=_blank that we add noopener, noreferrer and nofollow to the 'rel' attribute
|
|
41
|
-
DOMPurify.addHook('afterSanitizeAttributes', (node) => {
|
|
42
|
-
if (node.tagName === 'A' && node?.target === '_blank') {
|
|
43
|
-
const rel = ['noopener', 'noreferrer', 'nofollow'];
|
|
44
|
-
const existingRel = node.rel?.length ? node.rel.split(' ') : [];
|
|
45
|
-
const combined = uniq([...rel, ...existingRel]);
|
|
46
|
-
|
|
47
|
-
node.setAttribute('rel', combined.join(' '));
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
export const purifyHTML = (value, options = { ALLOWED_TAGS }) => {
|
|
52
|
-
return DOMPurify.sanitize(value, options);
|
|
53
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import Resource from '@shell/plugins/dashboard-store/resource-class.js';
|
|
2
|
-
import { resourceClassJunkObject } from '@shell/plugins/dashboard-store/__tests__/utils/store-mocks';
|
|
3
|
-
|
|
4
|
-
describe('class: Resource', () => {
|
|
5
|
-
describe('given custom resource keys', () => {
|
|
6
|
-
const customResource = resourceClassJunkObject;
|
|
7
|
-
|
|
8
|
-
it('should keep internal keys', () => {
|
|
9
|
-
const resource = new Resource(customResource, {
|
|
10
|
-
getters: { schemaFor: () => ({ linkFor: jest.fn() }) },
|
|
11
|
-
dispatch: jest.fn(),
|
|
12
|
-
rootGetters: { 'i18n/t': jest.fn() },
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
expect({ ...resource }).toStrictEqual(customResource);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
describe('method: save', () => {
|
|
19
|
-
it('should remove all the internal keys', async() => {
|
|
20
|
-
const dispatch = jest.fn();
|
|
21
|
-
const resource = new Resource(customResource, {
|
|
22
|
-
getters: { schemaFor: () => ({ linkFor: jest.fn() }) },
|
|
23
|
-
dispatch,
|
|
24
|
-
rootGetters: { 'i18n/t': jest.fn() },
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const expectation = { type: customResource.type };
|
|
28
|
-
|
|
29
|
-
await resource.save();
|
|
30
|
-
|
|
31
|
-
const opt = {
|
|
32
|
-
data: expectation,
|
|
33
|
-
headers: {
|
|
34
|
-
accept: 'application/json',
|
|
35
|
-
'content-type': 'application/json',
|
|
36
|
-
},
|
|
37
|
-
method: 'post',
|
|
38
|
-
url: undefined,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// Data sent should have been cleaned
|
|
42
|
-
expect(dispatch).toHaveBeenCalledWith('request', { opt, type: customResource.type });
|
|
43
|
-
|
|
44
|
-
// Original workload model should remain unchanged
|
|
45
|
-
expect({ ...resource }).toStrictEqual(customResource);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
});
|
package/plugins/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Load the directives
|
|
3
|
-
*
|
|
4
|
-
* These are included in a function that can be explictly called, so that we can be sure
|
|
5
|
-
* of the execution order, rather than importing them at the top of a file.
|
|
6
|
-
*/
|
|
7
|
-
export function loadDirectives() {
|
|
8
|
-
import('./clean-html-directive');
|
|
9
|
-
import('./clean-tooltip-directive');
|
|
10
|
-
import('./directives');
|
|
11
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { steveCleanForDownload } from '@shell/plugins/steve/resource-utils';
|
|
2
|
-
|
|
3
|
-
describe('steve: ressource-utils', () => {
|
|
4
|
-
it('should do nothing if the yaml is not passed', () => {
|
|
5
|
-
const r = steveCleanForDownload();
|
|
6
|
-
|
|
7
|
-
expect(r).toBeUndefined();
|
|
8
|
-
});
|
|
9
|
-
it('should remove all default rootKeys', () => {
|
|
10
|
-
const expectedYamlStr = `apiVersion: v1
|
|
11
|
-
kind: ConfigMap
|
|
12
|
-
metadata:
|
|
13
|
-
name: my-configmap
|
|
14
|
-
`;
|
|
15
|
-
const yamlStr = `
|
|
16
|
-
id: test_id
|
|
17
|
-
links:
|
|
18
|
-
view: https://example.com2
|
|
19
|
-
type: test_type
|
|
20
|
-
actions:
|
|
21
|
-
remove: https://example.com
|
|
22
|
-
${ expectedYamlStr }
|
|
23
|
-
`;
|
|
24
|
-
const cleanedYamlStr = steveCleanForDownload(yamlStr);
|
|
25
|
-
|
|
26
|
-
expect(cleanedYamlStr).toBe(expectedYamlStr);
|
|
27
|
-
});
|
|
28
|
-
it('should remove all the specified root keys', () => {
|
|
29
|
-
const part = `apiVersion: v1
|
|
30
|
-
kind: Secret
|
|
31
|
-
metadata:
|
|
32
|
-
name: my-secret`;
|
|
33
|
-
|
|
34
|
-
const rootKeyToYamlStringMap = {
|
|
35
|
-
id: 'id: test_id',
|
|
36
|
-
links: `links:
|
|
37
|
-
view: https://example.com`,
|
|
38
|
-
actions: `actions:
|
|
39
|
-
remove: https://example.com`,
|
|
40
|
-
type: 'type: Opaque'
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const entries = Object.entries(rootKeyToYamlStringMap);
|
|
44
|
-
const yamlStr = `${ part }
|
|
45
|
-
${ entries.map(([_, str]) => str).join('\n') }`;
|
|
46
|
-
|
|
47
|
-
entries.forEach(([key, str]) => {
|
|
48
|
-
const expectedYamlStr = `${ part }
|
|
49
|
-
${ entries.filter(([k]) => k !== key).map(([_, str]) => str).join('\n') }\n`;
|
|
50
|
-
const cleanedYamlStr = steveCleanForDownload(yamlStr, { rootKeys: [key] });
|
|
51
|
-
|
|
52
|
-
expect(cleanedYamlStr).toBe(expectedYamlStr);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
it('should remove all default metadata keys', () => {
|
|
56
|
-
const expectedYamlStr = `apiVersion: v1
|
|
57
|
-
kind: ConfigMap
|
|
58
|
-
metadata:
|
|
59
|
-
name: my-configmap
|
|
60
|
-
`;
|
|
61
|
-
const yamlStr = `apiVersion: v1
|
|
62
|
-
kind: ConfigMap
|
|
63
|
-
metadata:
|
|
64
|
-
name: my-configmap
|
|
65
|
-
fields:
|
|
66
|
-
- kube-root-ca.crt
|
|
67
|
-
- 1
|
|
68
|
-
- 7d23h
|
|
69
|
-
relationships:
|
|
70
|
-
- rel: 'owner'
|
|
71
|
-
state: 'active'
|
|
72
|
-
`;
|
|
73
|
-
const cleanedYamlStr = steveCleanForDownload(yamlStr);
|
|
74
|
-
|
|
75
|
-
expect(cleanedYamlStr).toBe(expectedYamlStr);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('should remove all the specified metadata keys', () => {
|
|
79
|
-
const part = `apiVersion: v1
|
|
80
|
-
kind: ConfigMap
|
|
81
|
-
metadata:
|
|
82
|
-
name: my-configmap`;
|
|
83
|
-
|
|
84
|
-
const metadataKeyToYamlStringMap = {
|
|
85
|
-
fields:
|
|
86
|
-
` fields:
|
|
87
|
-
- kube-root-ca.crt
|
|
88
|
-
- 1
|
|
89
|
-
- 7d23h`,
|
|
90
|
-
relationships:
|
|
91
|
-
` relationships:
|
|
92
|
-
- rel: owner`,
|
|
93
|
-
state: ` state: active`
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const entries = Object.entries(metadataKeyToYamlStringMap);
|
|
97
|
-
const yamlStr = `${ part }
|
|
98
|
-
${ entries.map(([_, str]) => str).join('\n') }`;
|
|
99
|
-
|
|
100
|
-
entries.forEach(([key, str]) => {
|
|
101
|
-
const expectedYamlStr = `${ part }
|
|
102
|
-
${ entries.filter(([k]) => k !== key).map(([_, str]) => str).join('\n') }\n`;
|
|
103
|
-
const cleanedYamlStr = steveCleanForDownload(yamlStr, { metadataKeys: [key] });
|
|
104
|
-
|
|
105
|
-
expect(cleanedYamlStr).toBe(expectedYamlStr);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
it('should remove all defalut condition keys', () => {
|
|
109
|
-
const expectedYamlStr = `apiVersion: v1
|
|
110
|
-
kind: ConfigMap
|
|
111
|
-
metadata:
|
|
112
|
-
name: my-configmap
|
|
113
|
-
status:
|
|
114
|
-
conditions:
|
|
115
|
-
- {}
|
|
116
|
-
- {}
|
|
117
|
-
- message: message
|
|
118
|
-
`;
|
|
119
|
-
const yamlStr = `apiVersion: v1
|
|
120
|
-
kind: ConfigMap
|
|
121
|
-
metadata:
|
|
122
|
-
name: my-configmap
|
|
123
|
-
status:
|
|
124
|
-
conditions:
|
|
125
|
-
- error: 'error'
|
|
126
|
-
- transitioning: false
|
|
127
|
-
- message: message
|
|
128
|
-
`;
|
|
129
|
-
const cleanedYamlStr = steveCleanForDownload(yamlStr);
|
|
130
|
-
|
|
131
|
-
expect(cleanedYamlStr).toBe(expectedYamlStr);
|
|
132
|
-
});
|
|
133
|
-
it('should remove all the specified condition keys', () => {
|
|
134
|
-
const part = `apiVersion: v1
|
|
135
|
-
kind: ConfigMap
|
|
136
|
-
metadata:
|
|
137
|
-
name: my-configmap
|
|
138
|
-
status:
|
|
139
|
-
conditions:
|
|
140
|
-
- message: message`;
|
|
141
|
-
|
|
142
|
-
const conditionKeyToYamlStringMap = {
|
|
143
|
-
error: ' - error: error',
|
|
144
|
-
transitioning: ' - transitioning: false'
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const entries = Object.entries(conditionKeyToYamlStringMap);
|
|
148
|
-
const yamlStr = `${ part }
|
|
149
|
-
${ entries.map(([_, str]) => str).join('\n') }`;
|
|
150
|
-
|
|
151
|
-
entries.forEach(([key, str]) => {
|
|
152
|
-
const expectedYamlStr = `${ part }
|
|
153
|
-
${ entries.map(([k, str]) => k === key ? ' - {}' : str).join('\n') }\n`;
|
|
154
|
-
const cleanedYamlStr = steveCleanForDownload(yamlStr, { conditionKeys: [key] });
|
|
155
|
-
|
|
156
|
-
expect(cleanedYamlStr).toBe(expectedYamlStr);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
});
|