Skip to content

Proposal: Create a cue.mod/dagger.cue file #2431

Closed

Description

@helderco

Overview

Upstream

As per #2163 we plan on adopting the upcoming solution from upstream CUE for package management. That solution is modeled closely to how it works in Go. Right now we only have one module field in cue.mod/module.cue, but in the future that file will include everything from a go.mod file, e.g., require, replace, retract, etc.. but with a CUE syntax. It will also have a cue.mod/sum.cue file for checksums, also mirroring go.sum but with a CUE syntax.

cue.mod/module.cue schema
#ModuleDef: {
	module: string
	
	// The cue directive sets the expected CUE version for the module
	cue: string

	// A require directive declares a minimum required version of a given module dependency
	require: [...#Require]

	// An exclude directive prevents a module version from being loaded by the loader.
	exclude: [string]: string

	// A replace directive replaces the contents of a specific version of a module, or all 
	// versions of a module, with contents found elsewhere.
	replace: [...#Replace]
	
	// A retract directive indicates that a version or range of versions of the module 
	// defined by go.mod should not be depended upon.
	retract: [...#Retract]
}

#Require: {
	path:     string
	version:  string
	indirect: bool	
}

#Replace: {
	old: #Module
	new: #Module
}

#Module: {
	path:    string
	version: string
}

#Retract: {
	low:       string
	high:      string
	rationale: string
}
cue.mod/sum.cue schema
#Sum: [...#SumEntry]

#SumEntry: {
	// path is the module path
	path: string 

	// what is the aspect of the module for which we have a cryptographic sum
	// e.g. "v1.1.0" means the sum represents the sum of the module itself, 
	// "v1.1.0/go.mod" means the sum refers to the go.mod file only
	what: string  
	
	// sum is the crytographic sum. The format of the sum is described in 
	// https://golang.org/ref/mod#go
	sum: string
}

Dagger

We have implemented a stop-gap solution that's able to manage external packages right now using the files cue.mod/dagger.{mod,sum}. When the time comes, we will migrate dagger.{mod,sum} files to {module,sum}.cue files transparently and automatically.

Still, there are things we need for Dagger that won't be in upstream. One example right now is a setting for requiring a module compatibility with a dagger version. With #2321, we added a cue.mod/version.txt file for ensuring this for our built-in modules.

Proposal

Replace version.txt with a dagger.cue file, and add everything that's specific to dagger and not in upstream package management.

// cue.mod/dagger.cue
#DaggerDef: {
	// The dagger version this module is compatible with
	version: string
}

Activity

  1. morlay commented on May 13, 2022

    @morlay
    Contributor

    if just a version.
    it should be safe to use require from require of cue.mod/module.cue

    module: "dagger-project"
    
    require: {
       "dagger.io": "v0.2.10" 
    }
  2. helderco commented on May 26, 2022

    @helderco
    ContributorAuthor

    You may be right @morlay. I've described how this would work in #2506. Haven't found another need for adding to this file, and I'd rather avoid adding stuff on top of the upstream solution if possible.

    So I'm closing this unless something else comes up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions