Skip to content

Commit

Permalink
Gke provisioning (#11025)
Browse files Browse the repository at this point in the history
* gke provisioning without validation or tests

* move version from config tab to location tab, rename config networking and location config

* add form validation

* sort en-us

mock gcp data

networking tests

config tests

fix upgrade np version  checkbox

fix account access on edit

typescript errors

authscopes util tests

* add private nodes warning banner and fix accountaccess on create

* lint

* update yarn lock to include ipaddr.js

* fix e2e test

* testing credential bug

* fix selectcredential not allowing new credential to be created

* automatically use project id when a new gcp credential is created; block saving cluster until project id is authenticated

* logging banner

* fix networking when subnet ha sno secondary ip ranges

* add svc account fetch and some node pool tests

* fix auth scopes styling and view config mode

* review feedback and ts errors

* no auto-authenticate

* fix lint

* update networking input placement

* add loading component to crugke, crueks, cruaks; shuffle gke node pool component inputs

* fix lint and loading import

* fix extra zone checkboxes on edit and add unit test

* fix gke node pool version checkbox when adding pools

* fix lint

* fix extrazoneoptions display in view config mode

* clean up extraZoneOptions
  • Loading branch information
mantis-toboggan-md authored Jun 21, 2024
1 parent 374a839 commit ae9d1cb
Show file tree
Hide file tree
Showing 33 changed files with 5,642 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/blueprints/manager/clusterProviderUrlCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export const providersList = [
conditions: [
{
rkeType: 'rke2',
loads: 'rke1'
loads: 'rke2'
},
{
rkeType: 'rke1',
loads: 'rke1'
loads: 'rke2'
},
]
},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"identicon.js": "2.3.3",
"intl-messageformat": "7.8.4",
"ip": "^2.0.1",
"ipaddr.js": "2.2.0",
"is-base64": "^1.1.0",
"is-url": "1.2.4",
"jexl": "2.2.2",
Expand Down Expand Up @@ -214,4 +215,4 @@
"merge": ">=2.1.1",
"semver": ">=7.5.2"
}
}
}
7 changes: 6 additions & 1 deletion pkg/aks/components/CruAks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Tab from '@shell/components/Tabbed/Tab.vue';
import Tabbed from '@shell/components/Tabbed/index.vue';
import Accordion from '@components/Accordion/Accordion.vue';
import Banner from '@components/Banner/Banner.vue';
import Loading from '@shell/components/Loading.vue';
import ClusterMembershipEditor, { canViewClusterMembershipEditor } from '@shell/components/form/Members/ClusterMembershipEditor.vue';
import AksNodePool from '@pkg/aks/components/AksNodePool.vue';
Expand Down Expand Up @@ -116,7 +117,8 @@ export default defineComponent({
Tabbed,
Tab,
Accordion,
Banner
Banner,
Loading
},
mixins: [CreateEditView, FormValidation],
Expand Down Expand Up @@ -1023,7 +1025,10 @@ export default defineComponent({
</script>

<template>
<Loading v-if="$fetchState.pending" />

<CruResource
v-else
ref="cruresource"
:resource="value"
:mode="mode"
Expand Down
7 changes: 6 additions & 1 deletion pkg/eks/components/CruEKS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Tabbed from '@shell/components/Tabbed/index.vue';
import Accordion from '@components/Accordion/Accordion.vue';
import Banner from '@components/Banner/Banner.vue';
import ClusterMembershipEditor, { canViewClusterMembershipEditor } from '@shell/components/form/Members/ClusterMembershipEditor.vue';
import Loading from '@shell/components/Loading.vue';
import { EKSConfig, EKSNodeGroup, AWS, NormanCluster } from '../types';
import NodeGroup from './NodeGroup.vue';
Expand Down Expand Up @@ -89,7 +90,8 @@ export default defineComponent({
Tab,
Accordion,
Banner,
AgentConfiguration
AgentConfiguration,
Loading
},
mixins: [CreateEditView, FormValidation],
Expand Down Expand Up @@ -505,7 +507,10 @@ export default defineComponent({
</script>

<template>
<Loading v-if="$fetchState.pending" />

<CruResource
v-else
ref="cruresource"
:resource="value"
:mode="mode"
Expand Down
10 changes: 10 additions & 0 deletions pkg/gke/assets/gke-black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions pkg/gke/assets/gke.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions pkg/gke/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./.shell/pkg/babel.config.js');
205 changes: 205 additions & 0 deletions pkg/gke/components/AccountAccess.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { _CREATE, _VIEW } from '@shell/config/query-params';
import LabeledInput from '@components/Form/LabeledInput/LabeledInput.vue';
import SelectCredential from '@shell/edit/provisioning.cattle.io.cluster/SelectCredential.vue';
import AsyncButton from '@shell/components/AsyncButton.vue';
import { mapGetters, Store } from 'vuex';
import { getGKEZones } from '../util/gcp';
export default defineComponent({
name: 'GKEAccountAccess',
components: {
LabeledInput,
SelectCredential,
AsyncButton
},
props: {
mode: {
type: String,
default: _CREATE
},
credential: {
type: String,
default: null
},
project: {
type: String,
default: ''
},
isAuthenticated: {
type: Boolean,
default: false
},
},
created() {
if (this.mode === _VIEW) {
this.$emit('update:isAuthenticated', true);
}
},
computed: {
...mapGetters({ t: 'i18n/t' }),
CREATE(): string {
return _CREATE;
},
VIEW(): string {
return _VIEW;
},
isView():boolean {
return this.mode === _VIEW;
}
},
methods: {
async testProjectId(cb: (success: Boolean)=>{}) {
const store = this.$store as Store<any>;
try {
await getGKEZones(store, this.credential, this.project, {});
this.$emit('update:isAuthenticated', true);
// eslint-disable-next-line standard/no-callback-literal, node/no-callback-literal
return cb(true);
} catch (e) {
this.$emit('error', e?.data || e);
this.$emit('update:isAuthenticated', false);
// eslint-disable-next-line standard/no-callback-literal, node/no-callback-literal
return cb(false);
}
},
// gcp credentials include a project id - we can grab that and auto-fill to save users having to manually enter it
// this only applies to new credentials because of the way credential data is stored
parseNewCredential(e) {
const authJson = e?.googlecredentialConfig?.authEncodedJson;
if (authJson) {
try {
// eslint-disable-next-line camelcase
const { project_id:projectId } = JSON.parse(authJson);
if (projectId) {
this.$emit('update:project', projectId);
}
} catch (e) {
}
}
}
},
});
</script>

<template>
<div
:class="{'showing-form': !credential}"
class="credential-project"
>
<div
v-show="!!credential"
class="project mb-10"
>
<LabeledInput
:disabled="isAuthenticated"
:value="project"
label-key="gke.project.label"
required
@input="$emit('update:project', $event)"
/>
</div>
<div
:class="{'view': isView}"
class="select-credential-container mb-10"
>
<SelectCredential
:value="credential"
data-testid="crugke-select-credential"
:mode="(isView|| isAuthenticated) ? VIEW : CREATE"
provider="gcp"
:default-on-cancel="true"
:showing-form="!credential"
class="select-credential"
:cancel="()=>$emit('cancel-credential')"
@input="$emit('update:credential', $event)"
@credential-created="parseNewCredential"
/>
</div>
<template v-if="!isView">
<div
v-show="!!credential"
class="auth-button-container mb-10"
>
<AsyncButton
:disabled="!credential || !project || isAuthenticated"
type="button"
class="btn"
mode="authenticate"
@click="testProjectId"
/>
</div>
</template>
</div>
</template>

<style scoped lang="scss">
.credential-project {
display: flex;
min-width: 150px;
.project {
flex-basis: 50%;
flex-grow: 0;
margin: 0 1.75% 0 0;
}
&.showing-form {
flex-grow:1;
flex-direction: column;
&>.project {
margin: 0;
}
&>.select-credential-container{
display:flex;
flex-direction: column;
flex-grow: 1;
}
}
&>.select-credential-container{
flex-basis: 50%;
margin: 0 1.75% 0 0;
&.view{
margin: 0;
}
&>.select-credential{
flex-grow: 1;
}
}
}
.auth-button-container {
align-content: center;
min-width: 150px;
display: flex;
align-items: center;
justify-content: center;
}
</style>
Loading

0 comments on commit ae9d1cb

Please sign in to comment.