create resources with _type as type

This commit is contained in:
Nancy Butler 2020-01-31 11:59:33 -07:00
parent 38f7b7a360
commit 1dea6553b2
4 changed files with 31 additions and 18 deletions

View File

@ -131,10 +131,11 @@ export const AGE = {
export const CREATED = { export const CREATED = {
name: 'created', name: 'created',
label: 'Created', label: 'Created',
value: 'created', value: 'metadata.creationTimestamp',
sort: ['created', 'name'], sort: ['created', 'name'],
search: false, search: false,
formatter: 'LiveDate', formatter: 'LiveDate',
align: 'right'
}; };
export const IMAGE = { export const IMAGE = {

View File

@ -29,13 +29,17 @@ export default {
dockerRows() { dockerRows() {
const auths = JSON.parse(this.dataRows[0].value).auths; const auths = JSON.parse(this.dataRows[0].value).auths;
const rows = [];
const address = Object.keys(auths)[0]; for (const address in auths) {
const { username, url } = auths[address]; rows.push({
address,
username: auths[address].username,
password: auths[address].password
});
}
return [{ return rows;
address, username, url
}];
}, },
dockerHeaders() { dockerHeaders() {
@ -53,14 +57,6 @@ export default {
} }
]; ];
if (this.dockerRows[0].url) {
headers.push({
name: 'url',
label: 'url(for artifactory/custom)',
value: 'url'
});
}
return headers; return headers;
}, },

View File

@ -1,6 +1,6 @@
<script> <script>
import { DOCKER_JSON, OPAQUE, TLS } from '@/models/core.v1.secret'; import { DOCKER_JSON, OPAQUE, TLS } from '@/models/core.v1.secret';
import { base64Encode } from '@/utils/crypto'; import { base64Encode, base64Decode } from '@/utils/crypto';
import { get } from '@/utils/object'; import { get } from '@/utils/object';
import { ANNOTATION, NAMESPACE } from '@/config/types'; import { ANNOTATION, NAMESPACE } from '@/config/types';
import CreateEditView from '@/mixins/create-edit-view'; import CreateEditView from '@/mixins/create-edit-view';
@ -34,15 +34,30 @@ export default {
]; ];
const isNamespaced = !!this.value.metadata.namespace; const isNamespaced = !!this.value.metadata.namespace;
let username;
let password;
let registryFQDN;
if (this.value._type === DOCKER_JSON) {
const json = base64Decode(this.value.data['.dockerconfigjson']);
const { auths } = JSON.parse(json);
registryFQDN = Object.keys(auths)[0];
username = auths[registryFQDN].username;
password = auths[registryFQDN].password;
}
return { return {
types, types,
isNamespaced, isNamespaced,
registryAddresses, registryAddresses,
newNS: false, newNS: false,
registryProvider: registryAddresses[0], registryProvider: registryAddresses[0],
username: '', username,
password: '', password,
registryFQDN: null, registryFQDN,
toUpload: null, toUpload: null,
key: null, key: null,
cert: null cert: null

View File

@ -458,6 +458,7 @@ export default {
opt.headers['accept'] = 'application/json'; opt.headers['accept'] = 'application/json';
} }
this.type = this._type;
opt.data = this; opt.data = this;
const res = await this.$dispatch('request', opt); const res = await this.$dispatch('request', opt);