diff --git a/dashboard/pkg/epinio/config/epinio.ts b/dashboard/pkg/epinio/config/epinio.ts index 18896a0..9b28341 100644 --- a/dashboard/pkg/epinio/config/epinio.ts +++ b/dashboard/pkg/epinio/config/epinio.ts @@ -2,7 +2,7 @@ import { AGE, NAME, RAM, SIMPLE_NAME, STATE } from '@shell/config/table-headers'; import { createEpinioRoute, rootEpinioRoute } from '../utils/custom-routing'; -import { EPINIO_PRODUCT_NAME, EPINIO_STANDALONE_CLUSTER_NAME, EPINIO_TYPES } from '../types'; +import { EpinioGitConfig, EPINIO_PRODUCT_NAME, EPINIO_STANDALONE_CLUSTER_NAME, EPINIO_TYPES } from '../types'; import EpinioDiscovery from '../utils/epinio-discovery'; import { MULTI_CLUSTER } from '@shell/store/features'; @@ -150,6 +150,16 @@ export function init($plugin: any, store: any) { showListMasthead: false // Disable default masthead because we provide a custom one. }); + // Catalog Service + configureType(EPINIO_TYPES.GIT_CONFIG, { + isCreatable: true, + isEditable: false, + isRemovable: true, + showState: false, + canYaml: false, + customRoute: createEpinioRoute('c-cluster-resource', { resource: EPINIO_TYPES.GIT_CONFIG }), + }); + virtualType({ label: store.getters['i18n/t']('epinio.intro.about'), icon: 'dashboard', @@ -188,6 +198,7 @@ export function init($plugin: any, store: any) { EPINIO_TYPES.DASHBOARD, EPINIO_TYPES.APP, EPINIO_TYPES.NAMESPACE, + EPINIO_TYPES.GIT_CONFIG, SERVICE_GROUP, ADVANCED_GROUP, ABOUT @@ -408,4 +419,52 @@ export function init($plugin: any, store: any) { }, AGE ]); + + headers(EPINIO_TYPES.GIT_CONFIG, [ + NAME, + { + name: 'provider', + labelKey: 'epinio.gitconfigs.tableHeaders.provider.label', + tooltip: 'epinio.gitconfigs.tableHeaders.provider.tooltip', + value: 'provider', + sort: ['provider'], + }, + { + name: 'url', + labelKey: 'epinio.gitconfigs.tableHeaders.url.label', + tooltip: 'epinio.gitconfigs.tableHeaders.url.tooltip', + value: 'url', + sort: ['url'], + }, + { + name: 'userorg', + labelKey: 'epinio.gitconfigs.tableHeaders.userorg.label', + tooltip: 'epinio.gitconfigs.tableHeaders.userorg.tooltip', + value: 'userorg', + sort: ['userorg'], + }, + { + name: 'repository', + labelKey: 'epinio.gitconfigs.tableHeaders.repository.label', + tooltip: 'epinio.gitconfigs.tableHeaders.repository.tooltip', + value: 'repository', + sort: ['repository'], + }, + { + name: 'skipssl', + labelKey: 'epinio.gitconfigs.tableHeaders.skipssl.label', + tooltip: 'epinio.gitconfigs.tableHeaders.skipssl.tooltip', + getValue: (row: EpinioGitConfig) => !!row.skipssl, + sort: ['skipssl'], + formatter: 'Checked' // TODO: RC test + }, + { + name: 'username', + labelKey: 'epinio.gitconfigs.tableHeaders.username.label', + tooltip: 'epinio.gitconfigs.tableHeaders.username.tooltip', + value: 'username', + sort: ['username'], + }, + AGE + ]); } diff --git a/dashboard/pkg/epinio/edit/gitconfigs.vue b/dashboard/pkg/epinio/edit/gitconfigs.vue new file mode 100644 index 0000000..a5a5915 --- /dev/null +++ b/dashboard/pkg/epinio/edit/gitconfigs.vue @@ -0,0 +1,264 @@ + + + + + diff --git a/dashboard/pkg/epinio/l10n/en-us.yaml b/dashboard/pkg/epinio/l10n/en-us.yaml index 9ed006e..7fb6adb 100644 --- a/dashboard/pkg/epinio/l10n/en-us.yaml +++ b/dashboard/pkg/epinio/l10n/en-us.yaml @@ -33,6 +33,11 @@ typeLabel: one { Catalog } other { Catalog } } + "gitconfigs": |- + {count, plural, + one { Git Configs } + other { Git Configs } + } typeDescription: namespaces: Namespaces group your applications, services and other resources. Deleting a namespace will delete all of it's resources. applications: Epinio uses Applications to transition your code, through build, to being deployed. @@ -40,6 +45,7 @@ typeDescription: configurations: Configurations are a way to provide data to applications. The data becomes available once the configuration is bound to them. appcharts: Application Charts define kube resources created by your application. Templates for active applications cannot be changed catalogservices: Catalog Services provide additional, common functionality to applications. For example an instance of a database Catalog Service can be bound to an application. + gitconfigs: Git Configs provide a way for Epinio to access private and enterprise Github/Gitlab repositories asyncButton: export: action: Export @@ -381,6 +387,38 @@ epinio: login: Log in genericProvider: Log in with Auth Provider useGenericProvider: Use Auth Provider + gitconfigs: + providers: + GIT: 'Git' + GITHUB: 'Github' + GITHUB_ENTERPRISE: 'Github Enterprise' + GITLAB: 'Gitlab' + GITLAB_ENTERPRISE: 'Gitlab Enterprise' + tableHeaders: + provider: + label: Provider + tooltip: '# TODO: RC' + url: + label: Git URL + tooltip: '# TODO: RC' + userorg: + label: User/Org # TODO: RC gitlab + tooltip: '# TODO: RC' + repository: + label: Repository + tooltip: '# TODO: RC' + skipssl: + label: Skip SSL + tooltip: '# TODO: RC' + username: + label: Username + tooltip: '# TODO: RC' + password: + label: Password / API Key + tooltip: '# TODO: RC' + sections: + git: Git Details + credentials: Credentials model: authConfig: provider: diff --git a/dashboard/pkg/epinio/list/gitconfigs.vue b/dashboard/pkg/epinio/list/gitconfigs.vue new file mode 100644 index 0000000..ddb631e --- /dev/null +++ b/dashboard/pkg/epinio/list/gitconfigs.vue @@ -0,0 +1,39 @@ + + + diff --git a/dashboard/pkg/epinio/models/gitconfigs.js b/dashboard/pkg/epinio/models/gitconfigs.js new file mode 100644 index 0000000..237817e --- /dev/null +++ b/dashboard/pkg/epinio/models/gitconfigs.js @@ -0,0 +1,59 @@ +import EpinioMetaResource from './epinio-namespaced-resource'; + +export default class EpinioGitConfigModel extends EpinioMetaResource { + get links() { + return { + update: this.getUrl(), + self: this.getUrl(), + remove: this.getUrl(), + create: this.getUrl(null), // ensure name is null + }; + } + + getUrl(name = this.meta?.name) { + // Add baseUrl in a generic way + return this.$getters['urlFor'](this.type, this.id, { url: `/api/v1/gitconfigs/${ name || '' }` }); + } + + // ------------------------------------------------------------------ + + async create() { + await this.followLink('create', { + method: 'post', + headers: { + 'content-type': 'application/json', + accept: 'application/json' + }, + data: { + id: this.meta.name, + password: this.password, + provider: this.provider, + repository: this.repository, + skipssl: this.skipssl, + url: this.url, + username: this.username, + userorg: this.userorg + } + }); + } + + // async update() { + // await this.followLink('update', { + // method: 'put', + // headers: { + // 'content-type': 'application/json', + // accept: 'application/json' + // }, + // data: { + // id: this.meta.name, + // password: this.password, + // provider: this.provider, + // repository: this.repository, + // skipssl: this.skipssl, + // url: this.url, + // username: this.username, + // userorg: this.userorg + // } + // }); + // } +} diff --git a/dashboard/pkg/epinio/store/epinio-store/actions.ts b/dashboard/pkg/epinio/store/epinio-store/actions.ts index 5c6f392..e76c9a5 100644 --- a/dashboard/pkg/epinio/store/epinio-store/actions.ts +++ b/dashboard/pkg/epinio/store/epinio-store/actions.ts @@ -229,6 +229,12 @@ export default { collectionMethods: ['get', 'post'], resourceFields: { }, attributes: { namespaced: true } + }, { + product: EPINIO_PRODUCT_NAME, + id: EPINIO_TYPES.GIT_CONFIG, + type: 'schema', + links: { collection: '/api/v1/gitconfigs' }, + collectionMethods: ['get', 'post'], }] }; diff --git a/dashboard/pkg/epinio/types.ts b/dashboard/pkg/epinio/types.ts index 75d0923..bf39c7f 100644 --- a/dashboard/pkg/epinio/types.ts +++ b/dashboard/pkg/epinio/types.ts @@ -19,6 +19,7 @@ export const EPINIO_TYPES = { CONFIGURATION: 'configurations', CATALOG_SERVICE: 'catalogservices', SERVICE_INSTANCE: 'services', + GIT_CONFIG: 'gitconfigs', // Internal DASHBOARD: 'dashboard', ABOUT: 'about', @@ -235,3 +236,21 @@ export interface EpinioNamespace extends EpinioMetaProperty { } export type EpinioCompRecord = Record + +export interface EpinioGitConfig extends EpinioMetaProperty { + // Get & Post + provider?: string, + url: string, + skipssl?: boolean, + + username?: string, + + repository?: string, + userorg?: string, + + // Post + password?: string, + // "certs": [ + // 0 + // ], TODO: RC +}