chore: add cicd legacy cleanup precheck
This commit is contained in:
@@ -71,6 +71,22 @@ function optionalStringArrayFromRecord(value: Record<string, unknown>, key: stri
|
||||
return stringArrayFromRecord(value, key, path);
|
||||
}
|
||||
|
||||
function optionalArtifactSourceFromRecord(repository: Record<string, unknown>, path: string): MicroserviceConfig["repository"]["artifactSource"] {
|
||||
const field = repository.artifactSource;
|
||||
if (field === undefined) return undefined;
|
||||
const source = asRecord(field, `${path}.artifactSource`);
|
||||
const kind = stringFromRecord(source, "kind", `${path}.artifactSource`);
|
||||
if (kind !== "upstream-image") throw new Error(`${path}.artifactSource.kind must be upstream-image`);
|
||||
return {
|
||||
kind,
|
||||
imageRef: stringFromRecord(source, "imageRef", `${path}.artifactSource`),
|
||||
digestPinRequired: booleanFromRecord(source, "digestPinRequired", `${path}.artifactSource`),
|
||||
mirrorRepository: stringFromRecord(source, "mirrorRepository", `${path}.artifactSource`),
|
||||
ciDockerfileBuild: booleanFromRecord(source, "ciDockerfileBuild", `${path}.artifactSource`),
|
||||
pullOnlyCd: booleanFromRecord(source, "pullOnlyCd", `${path}.artifactSource`),
|
||||
};
|
||||
}
|
||||
|
||||
function parseMicroserviceConfig(value: unknown, index: number): MicroserviceConfig {
|
||||
const path = `MICROSERVICES_JSON[${index}]`;
|
||||
const item = asRecord(value, path);
|
||||
@@ -92,6 +108,7 @@ function parseMicroserviceConfig(value: unknown, index: number): MicroserviceCon
|
||||
url: stringFromRecord(repository, "url", `${path}.repository`),
|
||||
commitId: stringFromRecord(repository, "commitId", `${path}.repository`),
|
||||
dockerfile: stringFromRecord(repository, "dockerfile", `${path}.repository`),
|
||||
artifactSource: optionalArtifactSourceFromRecord(repository, `${path}.repository`),
|
||||
composeFile: stringFromRecord(repository, "composeFile", `${path}.repository`),
|
||||
composeService: stringFromRecord(repository, "composeService", `${path}.repository`),
|
||||
containerName: stringFromRecord(repository, "containerName", `${path}.repository`),
|
||||
|
||||
@@ -57,11 +57,24 @@ pub struct MicroserviceRepositoryConfig {
|
||||
pub url: String,
|
||||
pub commit_id: String,
|
||||
pub dockerfile: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub artifact_source: Option<ArtifactSourceConfig>,
|
||||
pub compose_file: String,
|
||||
pub compose_service: String,
|
||||
pub container_name: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ArtifactSourceConfig {
|
||||
pub kind: String,
|
||||
pub image_ref: String,
|
||||
pub digest_pin_required: bool,
|
||||
pub mirror_repository: String,
|
||||
pub ci_dockerfile_build: bool,
|
||||
pub pull_only_cd: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct MicroserviceBackendConfig {
|
||||
|
||||
@@ -40,6 +40,14 @@ export interface MicroserviceConfig {
|
||||
url: string;
|
||||
commitId: string;
|
||||
dockerfile: string;
|
||||
artifactSource?: {
|
||||
kind: "upstream-image";
|
||||
imageRef: string;
|
||||
digestPinRequired: boolean;
|
||||
mirrorRepository: string;
|
||||
ciDockerfileBuild: boolean;
|
||||
pullOnlyCd: boolean;
|
||||
};
|
||||
composeFile: string;
|
||||
composeService: string;
|
||||
containerName: string;
|
||||
|
||||
Reference in New Issue
Block a user