#hof & @attributes



The #hof definition is how generators, datamodels, and workflows are discovered and configured. Several attributes allow you to write shorthand for common settings.

The Attributes

By now, you have seen hof’s attributes in the previous getting-started sections. Hof turns these CUE attributes into #hof configuration.

  • @gen(<name>) - the root of a generator
  • @datamodel(<name>) - the root of a datamodel
  • @flow(<name>) - the root of a workflow

Datamodels and workflows have attributes that can be used under their root and are covered in their respective sections.

Other attributes:

  • @userfiles(<glob>) - load file contents into a struct as strings, the key is the filepath. This works with CUE based commands.

Schema

The following is the schema for #hof. Many generators, workflows, and datamodels you import and use will fill this in for you.

You can embed the following schema in order to reference the content. Hof will automatically inject it during the loading process to ensure correctness.

hof/schema.Hof

package schema

// Hof is used to embed #hof and include the needed metadata
// for hof's core functionality (gen,datamodel,flow)
// val: { schema.Hof, ... }
Hof: {

	// schema for #hof: ...
	#hof: {
		// #hof version
		apiVersion: "v1beta1"

		// typical metadata
		metadata: Metadata

		// hof/datamodel
		datamodel?: {
			// define the root of a datamodel
			root: bool | *false

			// instruct history to be tracked
			history: bool | *false

			// instruct ordrered version of the fields
			// to be injected as a peer value
			ordered: bool | *false

			// tell hof this is a node of interest for
			// the inspection commands (list,info)
			node: bool | *false

			// tell hof to track this as a raw CUE value
			// (partially implemented)
			cue: bool | *false
		}

		// hof/gen
		gen?: {
			// define the root of a generator
			root: bool | *false

			// name of the generator
			name: string | *""
		}

		// hof/flow, used for both flows & tasks
		flow?: {
			// define the root of a workflow
			root: bool | *false

			// name of the flow or task
			name: string | *""

			// if op is empty, it is a flow value
			// if op is not empty, it is a task value
			op: string | *""
		}
	}
}

// LabelNames is for embedding, so that the metadata name
// is filled in from the struct they are embedded in
// See the datamodel schemas for examples.
LabelNames: [N=string]: {#hof: metadata: name: N}

// Typical metadata useful in many places
Metadata: {
	id?:      string
	name?:    string
	package?: string
	labels?: [string]: string
}

// depreciated
DHof: Hof