Revert "fix: Have modules extend Module and we use a union of Module and CustomModule for module-v1"
This reverts commit 98d48fe2e1.
This commit is contained in:
parent
f6ec61d31e
commit
47e3fc81ff
2 changed files with 94 additions and 96 deletions
|
|
@ -21,16 +21,15 @@ for (const module of modules) {
|
||||||
text = text // add `...ModuleDefaults;` after the model type
|
text = text // add `...ModuleDefaults;` after the model type
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.flatMap(line => {
|
.flatMap(line => {
|
||||||
return line.replace(/model ([A-Za-z]+) {/, "model $1 extends Module {");
|
if (line.trimStart().startsWith(`type: "${module.name}"`)) {
|
||||||
// if (line.trimStart().startsWith(`type: "${module.name}"`)) {
|
return [
|
||||||
// return [
|
line,
|
||||||
// line,
|
'',
|
||||||
// '',
|
' ...ModuleDefaults; // added by fetchModuleSchemas.js',
|
||||||
// ' ...ModuleDefaults; // added by fetchModuleSchemas.js',
|
]
|
||||||
// ]
|
} else {
|
||||||
// } else {
|
return line;
|
||||||
// return line;
|
}
|
||||||
// }
|
|
||||||
})
|
})
|
||||||
.join('\n')
|
.join('\n')
|
||||||
|
|
||||||
|
|
@ -43,4 +42,4 @@ for (const module of modules) {
|
||||||
fs.writeFileSync(`${modulesDir}/index.tsp`,
|
fs.writeFileSync(`${modulesDir}/index.tsp`,
|
||||||
moduleImports.map(m => `import "./${m}";`).join("\n") + `
|
moduleImports.map(m => `import "./${m}";`).join("\n") + `
|
||||||
alias RepoModule = ${moduleModels.map(m => `${m}Module`).join(" | ")};`
|
alias RepoModule = ${moduleModels.map(m => `${m}Module`).join(" | ")};`
|
||||||
)
|
)
|
||||||
169
src-tsp/main.tsp
169
src-tsp/main.tsp
|
|
@ -5,124 +5,123 @@ using TypeSpec.JsonSchema;
|
||||||
|
|
||||||
@jsonSchema("recipe-v1.json")
|
@jsonSchema("recipe-v1.json")
|
||||||
model Recipe {
|
model Recipe {
|
||||||
/**
|
/**
|
||||||
* The image name. Used when publishing to GHCR as `ghcr.io/user/name`.
|
* The image name. Used when publishing to GHCR as `ghcr.io/user/name`.
|
||||||
*/
|
*/
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The image description. Published to GHCR in the image metadata.
|
* The image description. Published to GHCR in the image metadata.
|
||||||
*/
|
*/
|
||||||
description: string;
|
description: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows setting custom tags on the recipe’s final image.
|
* Allows setting custom tags on the recipe’s final image.
|
||||||
* Adding tags to this property will override the `latest` and timestamp tags.
|
* Adding tags to this property will override the `latest` and timestamp tags.
|
||||||
*/
|
*/
|
||||||
`alt-tags`?: Array<string>;
|
`alt-tags`?: Array<string>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The [OCI](https://opencontainers.org/) image to base your custom image on.
|
* The [OCI](https://opencontainers.org/) image to base your custom image on.
|
||||||
* Only atomic Fedora images and those based on them are officially supported.
|
* Only atomic Fedora images and those based on them are officially supported.
|
||||||
* Universal Blue is recommended. [A list of Universal Blue's images](https://universal-blue.org/images/) can be found on their website
|
* Universal Blue is recommended. [A list of Universal Blue's images](https://universal-blue.org/images/) can be found on their website
|
||||||
* BlueBuild-built images can be used as well.
|
* BlueBuild-built images can be used as well.
|
||||||
*/
|
*/
|
||||||
`base-image`: string;
|
`base-image`: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The tag of the base image to build on.
|
* The tag of the base image to build on.
|
||||||
* Used to select a version explicitly (`40`) or to always use the latest stable version (`latest`).
|
* Used to select a version explicitly (`40`) or to always use the latest stable version (`latest`).
|
||||||
* A list of all available tags can be viewed by pasting your `base-image` url into your browser.
|
* A list of all available tags can be viewed by pasting your `base-image` url into your browser.
|
||||||
*/
|
*/
|
||||||
`image-version`: string | integer;
|
`image-version`: string | integer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The tag to pull for the bluebuild cli. This is mostly used for
|
* The tag to pull for the bluebuild cli. This is mostly used for
|
||||||
* trying out specific versions of the cli without compiling it locally.
|
* trying out specific versions of the cli without compiling it locally.
|
||||||
**/
|
**/
|
||||||
`blue-build-tag`?: string;
|
`blue-build-tag`?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of [stages](https://blue-build.org/reference/stages/) that are executed before the build of the final image.
|
* A list of [stages](https://blue-build.org/reference/stages/) that are executed before the build of the final image.
|
||||||
* This is useful for compiling programs from source without polluting the final bootable image.
|
* This is useful for compiling programs from source without polluting the final bootable image.
|
||||||
*/
|
*/
|
||||||
stages?: Array<Stage | ImportedModule>;
|
stages?: Array<Stage>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of [modules](https://blue-build.org/reference/module/) that is executed in order. Multiple of the same module can be included.
|
* A list of [modules](https://blue-build.org/reference/module/) that is executed in order. Multiple of the same module can be included.
|
||||||
*
|
*
|
||||||
* Each item in this list should have at least a `type:` or be specified to be included from an external file in the `recipes/` directory with `from-file:`.
|
* Each item in this list should have at least a `type:` or be specified to be included from an external file in the `recipes/` directory with `from-file:`.
|
||||||
*/
|
*/
|
||||||
modules: Array<Module | ImportedModule>;
|
modules: Array<Module>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@jsonSchema("stage-list-v1.json")
|
@jsonSchema("stage-list-v1.json")
|
||||||
model StageList {
|
model StageList {
|
||||||
stages: Array<Stage | ImportedModule>;
|
stages: Array<Stage>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@jsonSchema("stage-v1.json")
|
@jsonSchema("stage-v1.json")
|
||||||
model Stage {
|
model StageFull {
|
||||||
/**
|
...Record<Stage>;
|
||||||
* The name of the stage. This is used when referencing
|
}
|
||||||
* the stage when using the from: property in the [`copy` module](https://blue-build.org/reference/modules/copy/).
|
|
||||||
*/
|
|
||||||
name: string;
|
|
||||||
|
|
||||||
/** The full image ref (image name + tag). This will be set in the FROM statement of the stage. */
|
alias Stage = StageDefault | ImportedModule;
|
||||||
from: string;
|
|
||||||
|
|
||||||
/** Allows a user to pass in an array of strings that are passed directly into the [`SHELL` instruction](https://docs.docker.com/reference/dockerfile/#shell). */
|
model StageDefault {
|
||||||
shell?: string;
|
/**
|
||||||
|
* The name of the stage. This is used when referencing
|
||||||
|
* the stage when using the from: property in the [`copy` module](https://blue-build.org/reference/modules/copy/).
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
|
||||||
/**
|
/** The full image ref (image name + tag). This will be set in the FROM statement of the stage. */
|
||||||
* The list of modules to execute. The exact same syntax used by the main recipe `modules:` property.
|
from: string;
|
||||||
*/
|
|
||||||
modules: Array<Module | ImportedModule>;
|
/** Allows a user to pass in an array of strings that are passed directly into the [`SHELL` instruction](https://docs.docker.com/reference/dockerfile/#shell). */
|
||||||
|
shell?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of modules to execute. The exact same syntax used by the main recipe `modules:` property.
|
||||||
|
*/
|
||||||
|
modules: Array<Module>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@jsonSchema("module-list-v1.json")
|
@jsonSchema("module-list-v1.json")
|
||||||
model ModuleList {
|
model ModuleList {
|
||||||
modules: Array<Module | ImportedModule>;
|
modules: Array<Module>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@jsonSchema("module-v1.json")
|
@jsonSchema("module-v1.json")
|
||||||
union ModuleType {
|
model ModuleFull {
|
||||||
normal: Module,
|
...Record<Module>;
|
||||||
custom: CustomModule,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@discriminator("type")
|
alias Module = RepoModule | CustomModule | ImportedModule;
|
||||||
model Module {
|
|
||||||
/** This is not a built-in module. */
|
|
||||||
type: string;
|
|
||||||
|
|
||||||
/** Whether to disabling caching for this layer.
|
model ModuleDefaults {
|
||||||
* https://blue-build.org/reference/module/#no-cache-optional
|
/** Whether to disabling caching for this layer.
|
||||||
*/
|
* https://blue-build.org/reference/module/#no-cache-optional
|
||||||
`no-cache`?: boolean = false;
|
*/
|
||||||
|
`no-cache`?: boolean = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
model CustomModule {
|
model CustomModule {
|
||||||
/** This is not a built-in module. */
|
/** This is not a built-in module. */
|
||||||
type: string;
|
type: string;
|
||||||
|
|
||||||
/** Whether to disabling caching for this layer.
|
/** The URL of the module repository (an OCI image) to pull the module from.
|
||||||
* https://blue-build.org/reference/module/#no-cache-optional
|
* https://blue-build.org/reference/module/#source-optional
|
||||||
*/
|
*/
|
||||||
`no-cache`?: boolean = false;
|
source?: string;
|
||||||
|
|
||||||
/** The URL of the module repository (an OCI image) to pull the module from.
|
...ModuleDefaults;
|
||||||
* https://blue-build.org/reference/module/#source-optional
|
...Record<unknown>;
|
||||||
*/
|
|
||||||
source?: string;
|
|
||||||
|
|
||||||
...Record<unknown>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model ImportedModule {
|
model ImportedModule {
|
||||||
/** The path to another file containing module configuration to import here.
|
/** The path to another file containing module configuration to import here.
|
||||||
* https://blue-build.org/how-to/multiple-files/
|
* https://blue-build.org/how-to/multiple-files/
|
||||||
*/
|
*/
|
||||||
`from-file`: string;
|
`from-file`: string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue