Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .moon/proto/cue.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name = "cue"
type = "cli"

[platform.macos]
download-file = "cue_v{version}_darwin_{arch}.tar.gz"
exe-path = "cue"

[platform.linux]
download-file = "cue_v{version}_linux_{arch}.tar.gz"
exe-path = "cue"

[platform.windows]
download-file = "cue_v{version}_windows_{arch}.zip"
exe-path = "cue.exe"

[install]
download-url = "https://github.com/cue-lang/cue/releases/download/v{version}/{download_file}"

[install.arch]
aarch64 = "arm64"
x86_64 = "amd64"

[resolve]
git-url = "https://github.com/cue-lang/cue"
2 changes: 2 additions & 0 deletions .prototools
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
cue = "=0.16.1"
golangci-lint = "=2.11.4"

[plugins.tools]
cue = "file://.moon/proto/cue.toml"
golangci-lint = "file://.moon/proto/golangci-lint.toml"
59 changes: 59 additions & 0 deletions moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ fileGroups:
go-sources:
- 'cmd/**/*.go'
- 'internal/**/*.go'
schema-config:
- '.prototools'
- '.moon/proto/cue.toml'
- 'schemas/go.mod'
- 'schemas/go.sum'
- 'schemas/cue.mod/**/*.cue'
schema-go-sources:
- 'schemas/**/*.go'
schema-sources:
- 'schemas/**/*.cue'
lint-config:
- '.golangci.yml'
- '.prototools'
Expand Down Expand Up @@ -67,12 +77,61 @@ tasks:
- '@group(go-config)'
- '@group(go-sources)'

schemas-mod-check:
script: 'cd schemas && proto run cue -- mod tidy --check'
inputs:
- '@group(schema-config)'
- '@group(schema-sources)'
options:
cache: false

schemas-vet:
script: 'cd schemas && proto run cue -- vet -c=false ./...'
inputs:
- '@group(schema-config)'
- '@group(schema-sources)'
options:
cache: false

schemas-generate:
script: 'cd schemas && proto run cue -- exp gengotypes ./... && gofmt -w $(find . -name "*.go" -type f)'
inputs:
- '@group(schema-config)'
- '@group(schema-sources)'
outputs:
- 'schemas/**/*.go'
options:
cache: false

schemas-generate-check:
script: 'cd schemas && proto run cue -- exp gengotypes ./... && gofmt -w $(find . -name "*.go" -type f) && git -C .. diff --exit-code -- "schemas/**/*.go"'
inputs:
- '@group(schema-config)'
- '@group(schema-sources)'
- '@group(schema-go-sources)'
options:
cache: false

schemas-test:
deps:
- 'root:schemas-generate-check'
script: 'cd schemas && go test ./...'
toolchains: ['go']
inputs:
- '@group(schema-config)'
- '@group(schema-go-sources)'
options:
cache: false

check:
deps:
- 'root:format'
- 'root:lint'
- 'root:build'
- 'root:test'
- 'root:schemas-mod-check'
- 'root:schemas-vet'
- 'root:schemas-test'
options:
cache: false
runInCI: true
101 changes: 101 additions & 0 deletions schemas/core/cue_types_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 89 additions & 0 deletions schemas/core/schema.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package core

#Name: =~"^[a-z0-9][a-z0-9._-]*[a-z0-9]$" | error("name must start and end with lowercase alphanumeric characters and contain only lowercase letters, digits, dots, underscores, or hyphens")

#VariantName: =~"^[A-Za-z0-9][A-Za-z0-9._-]*$" | error("variant name must start with an alphanumeric character and contain only letters, digits, dots, underscores, or hyphens")

#ArtifactKey: =~"^[A-Za-z0-9][A-Za-z0-9._-]*$" | error("artifact key must start with an alphanumeric character and contain only letters, digits, dots, underscores, or hyphens")

#Architecture: "amd64" | "arm64" | error("architecture must be one of: amd64, arm64")

#ArtifactFormat: "raw" | "raw.gz" | "qcow2" | "qcow2.gz" | "iso" | error("artifact format must be one of: raw, raw.gz, qcow2, qcow2.gz, iso")

#ProviderName: "incusos" | error("provider must be incusos")

#Image: {
name: #Name

description?: string

labels?: [string]: string
annotations?: [string]: string
}

#OutputDefaults: {
// Defaults to ./dist unless overridden by CLI flag or config.
dir?: string | *"dist"
}

#PublishIntent: {
// Optional override if imgsrv image identity should differ from image.name.
imageName?: #Name

labels?: [string]: string
annotations?: [string]: string
}

#ArtifactIntent: {
variant: #VariantName

provider: #ProviderName
os: string

architecture: #Architecture
format: #ArtifactFormat

mediaType?: string
filename?: string

labels?: [string]: string
annotations?: [string]: string
}

#ResolvedArtifact: {
artifactKey: #ArtifactKey

imageName: string
version?: string

variant: #VariantName
provider: #ProviderName
os: string
architecture: #Architecture
format: #ArtifactFormat

mediaType: string
path: string

labels?: [string]: string
annotations?: [string]: string

// Populated after build.
digest?: string
size?: int
}

#ResolvedPlan: {
image: #Image

// Supplied by CLI or release environment. Not required in the config file.
version?: string

outputDir: string

artifacts: {
[ArtifactKey=#ArtifactKey]: #ResolvedArtifact & {
artifactKey: ArtifactKey
}
} @go(,type=map[ArtifactKey]ResolvedArtifact)
}
4 changes: 4 additions & 0 deletions schemas/cue.mod/module.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module: "github.com/meigma/imgcli/schemas@v0"
language: {
version: "v0.16.1"
}
44 changes: 44 additions & 0 deletions schemas/cue_types_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading