cuemod

module
v0.9.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2024 License: MIT

README

CUE Mod

GoDoc Widget Go Report Card

ALPHA VERSION

May deprecated when cue modules official supported

dependency management for CUE without committing cue.mod

Requirements

  • git or other vcs tool supported by go for vcs downloading.

Install

go install github.com/octohelm/cuemod/cmd/cuem@latest

Usage

Quick Start
mkdir -p ./demo && cd ./demo

cat << EOT > kube.cue
package kube

import (
   apps_v1 "k8s.io/api/apps/v1"
)

deployment: [string]: apps_v1.#Deployment

_labels: { "app": "nginx" }

deployment: nginx: spec: selector: matchLabels: _labels
deployment: nginx: spec: template: metadata: labels: _labels
deployment: nginx: spec: template: spec: {
	containers: [{
		name: "nginx"
		image: "nginx:1.11.10-alpine"
	}]
}
EOT
 
cuem eval -o kube.yaml ./kube.cue
# build, will automately install deps if not exists or generator if needed.

cuem eval -o ./kube.single-file.cue ./kube.cue
# will bundle to one single cue file
Dependency management
# auto added deps
cuem get ./...

# upgrade deps
cuem get -u ./...

# install dep with special version
cuem get github.com/grafana/jsonnet-libs@latest

Features

  • Dependency management based on go modules
    • all dependency codes will download under $(go env GOMODCACHE)
    • GOPROXY supported to speed up downloading
  • Extract to cue pkg from other language or schema spec.
    • golang supported
    • k8s crd json supported

Spec cue.mod/module.cue

// module name
// for sub mod import, <module>/path/to/sub
// NOTICE: the module name should be a valid repo name
module: "github.com/octohelm/cuemod"

require: {
	"dagger.io":          "v0.2.8-0.20220512005159-64cb4f755695" 
	"k8s.io/api":         "v0.24.0" 
	"universe.dagger.io": "v0.2.8-0.20220512005159-64cb4f755695"
}

require: {
	"k8s.io/apimachinery": "v0.24.0" @indirect() 
}

replace: {
	// replace module with spec version
	"dagger.io":          "github.com/morlay/dagger/pkg/dagger.io@#release-main"
	"universe.dagger.io": "github.com/morlay/dagger/pkg/universe.dagger.io@#release-main"
	
	 // **notice** only works for current mod
    "github.com/x/a": "../a"
}

replace: {
	"k8s.io/api": "" @import("go")
	"k8s.io/apimachinery": "" @import("go")
}

Known issues
pkg name may not same as path

Some path like github.com/istio/istio/manifests/charts/istio-operator, the istio-operator is not a valid identifier in cue-lang. Should import with github.com/istio/istio/manifests/charts/istio-operator:istio_operator

Directories

Path Synopsis
cmd
internal
cmd/go/internals/auth
Package auth provides access to user-provided authentication credentials.
Package auth provides access to user-provided authentication credentials.
cmd/go/internals/base
Package base defines shared basic pieces of the go command, in particular logging and the Command structure.
Package base defines shared basic pieces of the go command, in particular logging and the Command structure.
cmd/go/internals/cache
Package cache implements a build artifact cache.
Package cache implements a build artifact cache.
cmd/go/internals/cfg
Package cfg holds configuration shared by multiple parts of the go command.
Package cfg holds configuration shared by multiple parts of the go command.
cmd/go/internals/fsys
Package fsys is an abstraction for reading files that allows for virtual overlays on top of the files on disk.
Package fsys is an abstraction for reading files that allows for virtual overlays on top of the files on disk.
cmd/go/internals/gover
Package gover implements support for Go toolchain versions like 1.21.0 and 1.21rc1.
Package gover implements support for Go toolchain versions like 1.21.0 and 1.21rc1.
cmd/go/internals/lockedfile
Package lockedfile creates and manipulates files whose contents should only change atomically.
Package lockedfile creates and manipulates files whose contents should only change atomically.
cmd/go/internals/lockedfile/internals/filelock
Package filelock provides a platform-independent API for advisory file locking.
Package filelock provides a platform-independent API for advisory file locking.
cmd/go/internals/mmap
The mmap package provides an abstraction for memory mapping files on different platforms.
The mmap package provides an abstraction for memory mapping files on different platforms.
cmd/go/internals/modfetch/codehost
Package codehost defines the interface implemented by a code hosting source, along with support code for use by implementations.
Package codehost defines the interface implemented by a code hosting source, along with support code for use by implementations.
cmd/go/internals/mvs
Package mvs implements Minimal Version Selection.
Package mvs implements Minimal Version Selection.
cmd/go/internals/par
Package par implements parallel execution helpers.
Package par implements parallel execution helpers.
cmd/go/internals/robustio
Package robustio wraps I/O functions that are prone to failure on Windows, transparently retrying errors up to an arbitrary timeout.
Package robustio wraps I/O functions that are prone to failure on Windows, transparently retrying errors up to an arbitrary timeout.
cmd/go/internals/str
Package str provides string manipulation utilities.
Package str provides string manipulation utilities.
cmd/go/internals/web
Package web defines minimal helper routines for accessing HTTP/HTTPS resources without requiring external dependencies on the net package.
Package web defines minimal helper routines for accessing HTTP/HTTPS resources without requiring external dependencies on the net package.
cmd/internals/browser
Package browser provides utilities for interacting with users' browsers.
Package browser provides utilities for interacting with users' browsers.
cmd/internals/quoted
Package quoted provides string manipulation utilities.
Package quoted provides string manipulation utilities.
internals/bisect
Package bisect can be used by compilers and other programs to serve as a target for the bisect debugging tool.
Package bisect can be used by compilers and other programs to serve as a target for the bisect debugging tool.
internals/buildcfg
Package buildcfg provides access to the build configuration described by the current environment.
Package buildcfg provides access to the build configuration described by the current environment.
internals/cfg
Package cfg holds configuration shared by the Go command and internal/testenv.
Package cfg holds configuration shared by the Go command and internal/testenv.
internals/godebug
Package godebug makes the settings in the $GODEBUG environment variable available to other packages.
Package godebug makes the settings in the $GODEBUG environment variable available to other packages.
internals/godebugs
Package godebugs provides a table of known GODEBUG settings, for use by a variety of other packages, including internal/godebug, runtime, runtime/metrics, and cmd/go/internal/load.
Package godebugs provides a table of known GODEBUG settings, for use by a variety of other packages, including internal/godebug, runtime, runtime/metrics, and cmd/go/internal/load.
internals/goexperiment
Package goexperiment implements support for toolchain experiments.
Package goexperiment implements support for toolchain experiments.
internals/gover
Package gover implements support for Go toolchain versions like 1.21.0 and 1.21rc1.
Package gover implements support for Go toolchain versions like 1.21.0 and 1.21rc1.
internals/lazyregexp
Package lazyregexp is a thin wrapper over regexp, allowing the use of global regexp variables without forcing them to be compiled at init.
Package lazyregexp is a thin wrapper over regexp, allowing the use of global regexp variables without forcing them to be compiled at init.
internals/singleflight
Package singleflight provides a duplicate function call suppression mechanism.
Package singleflight provides a duplicate function call suppression mechanism.
internals/syscall/windows/sysdll
Package sysdll is an internal leaf package that records and reports which Windows DLL names are used by Go itself.
Package sysdll is an internal leaf package that records and reports which Windows DLL names are used by Go itself.
internals/trace/traceviewer/format
Package traceviewer provides definitions of the JSON data structures used by the Chrome trace viewer.
Package traceviewer provides definitions of the JSON data structures used by the Chrome trace viewer.
pkg
cli
tool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL