@eclipse-che/che-devworkspace-generator
Advanced tools
Comparing version 0.0.1-58f79fb to 0.0.1-602dcb4
@@ -16,2 +16,3 @@ /********************************************************************** | ||
generateContent(devfileContent: string, editorContent: string, injectDefaultComponent?: string, defaultComponentImage?: string): Promise<DevfileContext>; | ||
private createDevWorkspaceMetadata; | ||
} |
@@ -114,3 +114,3 @@ "use strict"; | ||
editorDevfile = jsYaml.load(editorContent); | ||
metadata = editorDevfile.metadata; | ||
metadata = this.createDevWorkspaceMetadata(editorDevfile); | ||
// add sufix | ||
@@ -126,3 +126,3 @@ metadata.name = metadata.name + "-" + suffix; | ||
}; | ||
devfileMetadata = devfile.metadata; | ||
devfileMetadata = this.createDevWorkspaceMetadata(devfile, true); | ||
devfileCopy = Object.assign({}, devfile); | ||
@@ -143,2 +143,3 @@ delete devfileCopy.schemaVersion; | ||
started: true, | ||
routingClass: 'che', | ||
template: devfileCopy, | ||
@@ -175,2 +176,19 @@ contributions: [editorSpecContribution] | ||
}; | ||
Generate.prototype.createDevWorkspaceMetadata = function (devfile, addDevfileContent) { | ||
if (addDevfileContent === void 0) { addDevfileContent = false; } | ||
var devWorkspaceMetadata = {}; | ||
var devfileMetadata = devfile.metadata; | ||
if (devfileMetadata.name) { | ||
devWorkspaceMetadata.name = devfileMetadata.name; | ||
} | ||
if (devfileMetadata.generateName) { | ||
devWorkspaceMetadata.generateName = devfileMetadata.generateName; | ||
} | ||
if (addDevfileContent) { | ||
devWorkspaceMetadata.annotations = { | ||
'che.eclipse.org/devfile': jsYaml.dump(devfile) | ||
}; | ||
} | ||
return devWorkspaceMetadata; | ||
}; | ||
var Generate_1; | ||
@@ -177,0 +195,0 @@ Generate.MERGE_CONTRIBUTION = 'controller.devfile.io/merge-contribution'; |
{ | ||
"name": "@eclipse-che/che-devworkspace-generator", | ||
"version": "0.0.1-58f79fb", | ||
"version": "0.0.1-602dcb4", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Generates DevWorkspaces by transforming existing devfiles", |
@@ -12,3 +12,6 @@ /********************************************************************** | ||
import { | ||
V221Devfile, | ||
V221DevfileMetadata, | ||
V1alpha2DevWorkspace, | ||
V1alpha2DevWorkspaceMetadata, | ||
V1alpha2DevWorkspaceSpecContributions, | ||
@@ -25,2 +28,8 @@ V1alpha2DevWorkspaceSpecTemplateComponents, | ||
type DevfileLike = V221Devfile & { | ||
metadata: V221DevfileMetadata & { | ||
generateName?: string; | ||
}; | ||
}; | ||
@injectable() | ||
@@ -78,3 +87,3 @@ export class Generate { | ||
// transform it into a devWorkspace template | ||
const metadata = editorDevfile.metadata; | ||
const metadata = this.createDevWorkspaceMetadata(editorDevfile); | ||
// add sufix | ||
@@ -92,3 +101,3 @@ metadata.name = `${metadata.name}-${suffix}`; | ||
// transform it into a devWorkspace | ||
const devfileMetadata = devfile.metadata; | ||
const devfileMetadata = this.createDevWorkspaceMetadata(devfile, true); | ||
const devfileCopy = Object.assign({}, devfile); | ||
@@ -109,2 +118,3 @@ delete devfileCopy.schemaVersion; | ||
started: true, | ||
routingClass: 'che', | ||
template: devfileCopy, | ||
@@ -145,2 +155,21 @@ contributions: [editorSpecContribution], | ||
} | ||
private createDevWorkspaceMetadata(devfile: DevfileLike, addDevfileContent = false): V1alpha2DevWorkspaceMetadata { | ||
const devWorkspaceMetadata = {} as V1alpha2DevWorkspaceMetadata; | ||
const devfileMetadata = devfile.metadata; | ||
if (devfileMetadata.name) { | ||
devWorkspaceMetadata.name = devfileMetadata.name; | ||
} | ||
if (devfileMetadata.generateName) { | ||
devWorkspaceMetadata.generateName = devfileMetadata.generateName; | ||
} | ||
if (addDevfileContent) { | ||
devWorkspaceMetadata.annotations = { | ||
'che.eclipse.org/devfile': jsYaml.dump(devfile), | ||
}; | ||
} | ||
return devWorkspaceMetadata; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
131643
2242