cuemod

module
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 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
pkg
cli
modutil/internal/cmd/go/internals/auth
Package auth provides access to user-provided authentication credentials.
Package auth provides access to user-provided authentication credentials.
modutil/internal/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.
modutil/internal/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.
modutil/internal/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.
modutil/internal/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.
modutil/internal/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.
modutil/internal/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.
modutil/internal/cmd/go/internals/mvs
Package mvs implements Minimal Version Selection.
Package mvs implements Minimal Version Selection.
modutil/internal/cmd/go/internals/par
Package par implements parallel execution helpers.
Package par implements parallel execution helpers.
modutil/internal/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.
modutil/internal/cmd/go/internals/str
Package str provides string manipulation utilities.
Package str provides string manipulation utilities.
modutil/internal/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.
modutil/internal/cmd/internals/browser
Package browser provides utilities for interacting with users' browsers.
Package browser provides utilities for interacting with users' browsers.
modutil/internal/cmd/internals/quoted
Package quoted provides string manipulation utilities.
Package quoted provides string manipulation utilities.
modutil/internal/cmd/internals/traceviewer
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.
modutil/internal/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.
modutil/internal/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.
modutil/internal/internals/execabs
Package execabs is a drop-in replacement for os/exec that requires PATH lookups to find absolute paths.
Package execabs is a drop-in replacement for os/exec that requires PATH lookups to find absolute paths.
modutil/internal/internals/goexperiment
Package goexperiment implements support for toolchain experiments.
Package goexperiment implements support for toolchain experiments.
modutil/internal/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.
modutil/internal/internals/singleflight
Package singleflight provides a duplicate function call suppression mechanism.
Package singleflight provides a duplicate function call suppression mechanism.
modutil/internal/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.
modutil/internal/internals/unsafeheader
Package unsafeheader contains header declarations for the Go runtime's slice and string implementations.
Package unsafeheader contains header declarations for the Go runtime's slice and string implementations.
tool

Jump to

Keyboard shortcuts

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