github.com/octohelm/cuemod@v0.9.4/README.md (about) 1 # CUE Mod 2 3 [![GoDoc Widget](https://godoc.org/github.com/octohelm/cuemod?status.svg)](https://pkg.go.dev/github.com/octohelm/cuemod) 4 [![Go Report Card](https://goreportcard.com/badge/github.com/octohelm/cuemod)](https://goreportcard.com/report/github.com/octohelm/cuemod) 5 6 **ALPHA VERSION** 7 8 **May deprecated when [cue modules official supported](https://github.com/cue-lang/cue/issues/851)** 9 10 dependency management for [CUE](https://cuelang.org/) without committing `cue.mod` 11 12 ## Requirements 13 14 * `git` or other vcs tool supported by go for vcs downloading. 15 16 ## Install 17 18 ```shell 19 go install github.com/octohelm/cuemod/cmd/cuem@latest 20 ``` 21 22 ## Usage 23 24 ### Quick Start 25 26 ```bash 27 mkdir -p ./demo && cd ./demo 28 29 cat << EOT > kube.cue 30 package kube 31 32 import ( 33 apps_v1 "k8s.io/api/apps/v1" 34 ) 35 36 deployment: [string]: apps_v1.#Deployment 37 38 _labels: { "app": "nginx" } 39 40 deployment: nginx: spec: selector: matchLabels: _labels 41 deployment: nginx: spec: template: metadata: labels: _labels 42 deployment: nginx: spec: template: spec: { 43 containers: [{ 44 name: "nginx" 45 image: "nginx:1.11.10-alpine" 46 }] 47 } 48 EOT 49 50 cuem eval -o kube.yaml ./kube.cue 51 # build, will automately install deps if not exists or generator if needed. 52 53 cuem eval -o ./kube.single-file.cue ./kube.cue 54 # will bundle to one single cue file 55 ``` 56 57 ### Dependency management 58 59 ```bash 60 # auto added deps 61 cuem get ./... 62 63 # upgrade deps 64 cuem get -u ./... 65 66 # install dep with special version 67 cuem get github.com/grafana/jsonnet-libs@latest 68 ``` 69 70 ## Features 71 72 * Dependency management based on go modules 73 * all dependency codes will download under `$(go env GOMODCACHE)` 74 * `GOPROXY` supported to speed up downloading 75 * Extract to cue pkg from other language or schema spec. 76 * `golang` supported 77 * k8s `crd` json supported 78 79 ## Spec `cue.mod/module.cue` 80 81 ```cue 82 // module name 83 // for sub mod import, <module>/path/to/sub 84 // NOTICE: the module name should be a valid repo name 85 module: "github.com/octohelm/cuemod" 86 87 require: { 88 "dagger.io": "v0.2.8-0.20220512005159-64cb4f755695" 89 "k8s.io/api": "v0.24.0" 90 "universe.dagger.io": "v0.2.8-0.20220512005159-64cb4f755695" 91 } 92 93 require: { 94 "k8s.io/apimachinery": "v0.24.0" @indirect() 95 } 96 97 replace: { 98 // replace module with spec version 99 "dagger.io": "github.com/morlay/dagger/pkg/dagger.io@#release-main" 100 "universe.dagger.io": "github.com/morlay/dagger/pkg/universe.dagger.io@#release-main" 101 102 // **notice** only works for current mod 103 "github.com/x/a": "../a" 104 } 105 106 replace: { 107 "k8s.io/api": "" @import("go") 108 "k8s.io/apimachinery": "" @import("go") 109 } 110 111 ``` 112 113 ### Known issues 114 115 #### pkg name may not same as path 116 117 Some path like `github.com/istio/istio/manifests/charts/istio-operator`, the `istio-operator` is not a valid identifier 118 in `cue-lang`. Should import with `github.com/istio/istio/manifests/charts/istio-operator:istio_operator`