trim

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Overview

Package trim removes some redundant values from CUE sources.

The most common use of trim is to remove duplicate values from data where a definition now provides the same value. For example:

servers: [
	{role: "web", cpus: 1},
	{role: "db", cpus: 1},
	{role: "proxy", cpus: 1},
]

#server: {
	role: string
	cpus: 1
}

servers: [...#server]

Trim will simplify this to:

servers: [
	{role: "web"},
	{role: "db"},
	{role: "proxy"},
]

#server: {
	role: string
	cpus: 1
}

servers: [...#server]

This works with defaults too. Given:

servers: [
	{role: "web", cpus: 1},
	{role: "db", cpus: 4},
	{role: "proxy", cpus: 1},
]

#server: {
	role: string
	cpus: *1 | int
}

servers: [...#server]

Trim will simplify this to:

servers: [
	{role: "web"},
	{role: "db", cpus: 4},
	{role: "proxy"},
]

#server: {
	role: string
	cpus: *1 | int
}

servers: [...#server]

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Files

func Files(files []*ast.File, inst cue.InstanceOrValue, cfg *Config) error

Types

type Config

type Config struct {
	Trace       bool
	TraceWriter io.Writer
}

Config configures trim options.

Jump to

Keyboard shortcuts

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