-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(managers): yaml schema checks (#26811)
- Loading branch information
Showing
14 changed files
with
229 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { z } from 'zod'; | ||
|
||
export const KubernetesResource = z.object({ | ||
apiVersion: z.string(), | ||
}); | ||
|
||
export const ApplicationSource = z.object({ | ||
chart: z.string().optional(), | ||
repoURL: z.string(), | ||
targetRevision: z.string(), | ||
}); | ||
export type ApplicationSource = z.infer<typeof ApplicationSource>; | ||
|
||
export const ApplicationSpec = z.object({ | ||
source: ApplicationSource.optional(), | ||
sources: z.array(ApplicationSource).optional(), | ||
}); | ||
export type ApplicationSpec = z.infer<typeof ApplicationSpec>; | ||
|
||
export const Application = KubernetesResource.extend({ | ||
kind: z.literal('Application'), | ||
spec: ApplicationSpec, | ||
}); | ||
|
||
export const ApplicationSet = KubernetesResource.extend({ | ||
kind: z.literal('ApplicationSet'), | ||
spec: z.object({ | ||
template: z.object({ | ||
spec: ApplicationSpec, | ||
}), | ||
}), | ||
}); | ||
|
||
export const ApplicationDefinition = Application.or(ApplicationSet); | ||
export type ApplicationDefinition = z.infer<typeof ApplicationDefinition>; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { z } from 'zod'; | ||
|
||
const DockerComposeService = z.object({ | ||
image: z.string().optional(), | ||
build: z | ||
.object({ | ||
context: z.string().optional(), | ||
dockerfile: z.string().optional(), | ||
}) | ||
.optional(), | ||
}); | ||
|
||
const DockerComposeFileV1 = z.record(DockerComposeService); | ||
const DockerComposeFileModern = z.object({ | ||
// compose does not use this strictly, so we shouldn't be either | ||
// https://docs.docker.com/compose/compose-file/04-version-and-name/#version-top-level-element | ||
version: z.string().optional(), | ||
services: z.record(DockerComposeService), | ||
}); | ||
|
||
export const DockerComposeFile = | ||
DockerComposeFileModern.or(DockerComposeFileV1); | ||
export type DockerComposeFile = z.infer<typeof DockerComposeFile>; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { z } from 'zod'; | ||
|
||
const FleetHelmBlock = z.object({ | ||
chart: z.string().optional(), | ||
repo: z.string().optional(), | ||
version: z.string().optional(), | ||
}); | ||
export type FleetHelmBlock = z.infer<typeof FleetHelmBlock>; | ||
|
||
const FleetFileHelm = FleetHelmBlock.extend({ | ||
releaseName: z.string(), | ||
}); | ||
|
||
/** | ||
Represent a GitRepo Kubernetes manifest of Fleet. | ||
@link https://fleet.rancher.io/gitrepo-add/#create-gitrepo-instance | ||
*/ | ||
export const GitRepo = z.object({ | ||
metadata: z.object({ | ||
name: z.string(), | ||
}), | ||
kind: z.string(), | ||
spec: z.object({ | ||
repo: z.string().optional(), | ||
revision: z.string().optional(), | ||
}), | ||
}); | ||
export type GitRepo = z.infer<typeof GitRepo>; | ||
|
||
/** | ||
Represent a Bundle configuration of Fleet, which is located in `fleet.yaml` files. | ||
@link https://fleet.rancher.io/gitrepo-structure/#fleetyaml | ||
*/ | ||
export const FleetFile = z.object({ | ||
helm: FleetFileHelm, | ||
targetCustomizations: z | ||
.array( | ||
z.object({ | ||
name: z.string(), | ||
helm: FleetHelmBlock.partial().optional(), | ||
}), | ||
) | ||
.optional(), | ||
}); | ||
export type FleetFile = z.infer<typeof FleetFile>; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.