Skip to main content
czerasz.com: notes
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

CUE

Validate

  • validate CUE file

    cue vet cue/templates/video.cue --out yaml
    
  • validate deployment.yml against Object in schema.cue

    cue vet schema.cue -d Object deployment.yml
    

Output

  • YAML

    cue export cue/templates/video.cue --out yaml
    
  • JSON

    cue export cue/templates/video.cue --out json
    

Examples

  • load external files

    package kube
    
    import ( "encoding/yaml", "tool/file" )
    
    globYAML: file.Glob & { glob: "*.yaml" }
    
    open: {
      for _, f in globYAML.files {
        (f): file.Read & {
          filename: f                              // input
          contents: _                              // output
          _objList: yaml.UnmarshalStream(contents) // user field
        }
      }
    }
    
    import "strings"
    
    // Collate Kubernetes objects by kind and name.
    objByKind: {
      for _, v in open for _, obj in v._objList {
        (strings.ToCamel(obj.kind)): (obj.metadata.name): obj
      }
    }
    
    // convenience
    allObjects: [ for x in objByKind for y in x {y} ]