diff --git a/frontend/package.json b/frontend/package.json index 87b14d200fc..d2a413ef710 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -9,8 +9,8 @@ ], "scripts": { "clean": "rm -rf ./public/dist", - "dev": "yarn clean && yarn plugin-stats && ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack --mode development --watch --progress", - "build": "yarn clean && yarn plugin-stats && NODE_ENV=production ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack --mode=production", + "dev": "yarn clean && ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack --mode development --watch --progress", + "build": "yarn clean && NODE_ENV=production ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack --mode=production", "coverage": "jest --coverage .", "lint": "eslint --ext .js,.jsx,.ts,.tsx --color .", "test": "jest", diff --git a/frontend/packages/console-app/package.json b/frontend/packages/console-app/package.json index 55fbfe046b2..e95c106f3b5 100644 --- a/frontend/packages/console-app/package.json +++ b/frontend/packages/console-app/package.json @@ -10,6 +10,7 @@ "dependencies": { "@console/dev-console": "0.0.0-fixed", "@console/internal": "0.0.0-fixed", + "@console/knative-plugin": "0.0.0-fixed", "@console/metal3-plugin": "0.0.0-fixed", "@console/plugin-sdk": "0.0.0-fixed", "@console/shared": "0.0.0-fixed" diff --git a/frontend/packages/dev-console/package.json b/frontend/packages/dev-console/package.json index c2d06821e9b..2856e978515 100644 --- a/frontend/packages/dev-console/package.json +++ b/frontend/packages/dev-console/package.json @@ -4,6 +4,7 @@ "description": "OpenShift Developer Perspective", "private": true, "dependencies": { + "@console/knative-plugin": "0.0.0-fixed", "@console/plugin-sdk": "0.0.0-fixed" }, "consolePlugin": { diff --git a/frontend/packages/dev-console/src/models/index.ts b/frontend/packages/dev-console/src/models/index.ts index 429b11c5dbc..dd4093e028e 100644 --- a/frontend/packages/dev-console/src/models/index.ts +++ b/frontend/packages/dev-console/src/models/index.ts @@ -1,2 +1 @@ export * from './pipelines'; -export * from './knative'; diff --git a/frontend/packages/dev-console/src/models/knative.ts b/frontend/packages/dev-console/src/models/knative.ts deleted file mode 100644 index 377c655ac0a..00000000000 --- a/frontend/packages/dev-console/src/models/knative.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { K8sKind } from '@console/internal/module/k8s'; - -export const KsServiceModel: K8sKind = { - apiGroup: 'serving.knative.dev', - apiVersion: 'v1alpha1', - label: 'Service', - labelPlural: 'Services', - plural: 'services', - abbr: 'KS', - namespaced: true, - kind: 'Service', - id: 'service', - crd: true, -}; diff --git a/frontend/packages/dev-console/src/utils/create-knative-utils.ts b/frontend/packages/dev-console/src/utils/create-knative-utils.ts index 778d878a5a8..82193720dc6 100644 --- a/frontend/packages/dev-console/src/utils/create-knative-utils.ts +++ b/frontend/packages/dev-console/src/utils/create-knative-utils.ts @@ -1,5 +1,5 @@ import { k8sCreate, K8sResourceKind } from '@console/internal/module/k8s'; -import { KsServiceModel } from '../models'; +import { ServiceModel } from '@console/knative-plugin'; export const createKnativeService = ( name: string, @@ -37,5 +37,5 @@ export const createKnativeService = ( }, }; - return k8sCreate(KsServiceModel, knativeDeployResource); + return k8sCreate(ServiceModel, knativeDeployResource); }; diff --git a/frontend/packages/knative-plugin/OWNERS b/frontend/packages/knative-plugin/OWNERS new file mode 100644 index 00000000000..d63feb1fbea --- /dev/null +++ b/frontend/packages/knative-plugin/OWNERS @@ -0,0 +1,15 @@ +reviewers: + - abhinandan13jan + - debsmita1 + - divyanshiGupta + - christianvogt + - joshuawilson + - invincibleJai + - karthikjeeyar + - rohitkrai03 + - sahil143 + - vikram-raj +approvers: + - christianvogt + - joshuawilson + - rohitkrai03 diff --git a/frontend/packages/knative-plugin/package.json b/frontend/packages/knative-plugin/package.json new file mode 100644 index 00000000000..b7f1d9b4c48 --- /dev/null +++ b/frontend/packages/knative-plugin/package.json @@ -0,0 +1,13 @@ +{ + "name": "@console/knative-plugin", + "version": "0.0.0-fixed", + "description": "Knative - Kubernetes-based platform to build, deploy, and manage modern serverless workloads", + "private": true, + "main": "src/index.ts", + "dependencies": { + "@console/plugin-sdk": "0.0.0-fixed" + }, + "consolePlugin": { + "entry": "src/plugin.tsx" + } +} diff --git a/frontend/packages/knative-plugin/src/const.ts b/frontend/packages/knative-plugin/src/const.ts new file mode 100644 index 00000000000..1f34937cf42 --- /dev/null +++ b/frontend/packages/knative-plugin/src/const.ts @@ -0,0 +1 @@ +export const FLAG_KNATIVE_SERVING = 'KNATIVE_SERVING'; diff --git a/frontend/packages/knative-plugin/src/index.ts b/frontend/packages/knative-plugin/src/index.ts new file mode 100644 index 00000000000..270b75fb351 --- /dev/null +++ b/frontend/packages/knative-plugin/src/index.ts @@ -0,0 +1,2 @@ +export * from './const'; +export * from './models'; diff --git a/frontend/packages/knative-plugin/src/models.ts b/frontend/packages/knative-plugin/src/models.ts new file mode 100644 index 00000000000..f55b1c9d4b2 --- /dev/null +++ b/frontend/packages/knative-plugin/src/models.ts @@ -0,0 +1,66 @@ +import { K8sKind } from '@console/internal/module/k8s'; + +export const ConfigurationModel: K8sKind = { + apiGroup: 'serving.knative.dev', + apiVersion: 'v1alpha1', + kind: 'Configuration', + plural: 'configurations', + label: 'Configuration', + labelPlural: 'Configurations', + id: 'configuration', + abbr: 'C', + namespaced: true, + crd: true, +}; + +export const KnativeServingModel: K8sKind = { + apiGroup: 'serving.knative.dev', + apiVersion: 'v1alpha1', + kind: 'KnativeServing', + label: 'Knative Serving', + labelPlural: 'Knative Servings', + plural: 'knativeservings', + id: 'knativeserving', + abbr: 'KS', + namespaced: true, + crd: true, +}; + +export const RevisionModel: K8sKind = { + apiGroup: 'serving.knative.dev', + apiVersion: 'v1alpha1', + kind: 'Revision', + label: 'Revision', + labelPlural: 'Revisions', + plural: 'revisions', + id: 'revision', + abbr: 'R', + namespaced: true, + crd: true, +}; + +export const RouteModel: K8sKind = { + apiGroup: 'serving.knative.dev', + apiVersion: 'v1alpha1', + kind: 'Route', + label: 'Route', + labelPlural: 'Routes', + plural: 'routes', + id: 'route', + abbr: 'R', + namespaced: true, + crd: true, +}; + +export const ServiceModel: K8sKind = { + apiGroup: 'serving.knative.dev', + apiVersion: 'v1alpha1', + kind: 'Service', + label: 'Service', + labelPlural: 'Services', + plural: 'services', + id: 'service', + abbr: 'S', + namespaced: true, + crd: true, +}; diff --git a/frontend/packages/knative-plugin/src/plugin.tsx b/frontend/packages/knative-plugin/src/plugin.tsx new file mode 100644 index 00000000000..9b76ebead4b --- /dev/null +++ b/frontend/packages/knative-plugin/src/plugin.tsx @@ -0,0 +1,58 @@ +import * as _ from 'lodash'; +import { Plugin, ResourceNSNavItem, ModelFeatureFlag, ModelDefinition } from '@console/plugin-sdk'; +import { referenceForModel } from '@console/internal/module/k8s'; +import * as models from './models'; +import { FLAG_KNATIVE_SERVING } from './const'; + +type ConsumedExtensions = ResourceNSNavItem | ModelFeatureFlag | ModelDefinition; + +const plugin: Plugin = [ + { + type: 'ModelDefinition', + properties: { + models: _.values(models), + }, + }, + { + type: 'FeatureFlag/Model', + properties: { + model: models.KnativeServingModel, + flag: FLAG_KNATIVE_SERVING, + }, + }, + { + type: 'NavItem/ResourceNS', + properties: { + section: 'Serverless', + componentProps: { + name: models.ServiceModel.labelPlural, + resource: referenceForModel(models.ServiceModel), + required: FLAG_KNATIVE_SERVING, + }, + }, + }, + { + type: 'NavItem/ResourceNS', + properties: { + section: 'Serverless', + componentProps: { + name: models.RevisionModel.labelPlural, + resource: referenceForModel(models.RevisionModel), + required: FLAG_KNATIVE_SERVING, + }, + }, + }, + { + type: 'NavItem/ResourceNS', + properties: { + section: 'Serverless', + componentProps: { + name: models.ConfigurationModel.labelPlural, + resource: referenceForModel(models.ConfigurationModel), + required: FLAG_KNATIVE_SERVING, + }, + }, + }, +]; + +export default plugin; diff --git a/frontend/public/components/nav/admin-nav.tsx b/frontend/public/components/nav/admin-nav.tsx index 1a4dd669226..35a4e086178 100644 --- a/frontend/public/components/nav/admin-nav.tsx +++ b/frontend/public/components/nav/admin-nav.tsx @@ -143,6 +143,10 @@ const AdminNav = () => ( + { /* Temporary addition of Knative Serverless section until extensibility allows for section ordering + and admin-nav gets contributed through extensions. */ } + +