Skip to content

How to write and use templates with package #1028

Answered by cueckoo
cueckoo asked this question in Q&A
Discussion options

You must be logged in to vote

Original reply by @owulveryck in cuelang/cue#1028 (comment)

Here is a working example:

package event

// Definition of the envelop
#Envelop: {
	subject:          =~"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" // a uuid
	source:           =~"^net.mycompany.+"
	type:             =~"^net.mycompany.+:[cud]" // c : create u : update d : delete
	dataContentType?: string
}

#Data: {}

#Event: {
	envelop: #Envelop
	data:    #Data
}

and the schema for the producer:

package sample1

import (
	"github.com/mycompany/masterschema/schemas/event:event"
)

#Schema: {
	envelop: event.#Envelop & {
		source: "net.mycompany.sample1"
	}
	data: {
		data1: string
	}
}

And a …

Replies: 3 comments 2 replies

Comment options

cueckoo
Jul 3, 2021
Collaborator Author

You must be logged in to vote
1 reply
@cueckoo
Comment options

cueckoo Jul 3, 2021
Collaborator Author

Comment options

cueckoo
Jul 3, 2021
Collaborator Author

You must be logged in to vote
0 replies
Comment options

cueckoo
Jul 3, 2021
Collaborator Author

You must be logged in to vote
1 reply
@cueckoo
Comment options

cueckoo Jul 3, 2021
Collaborator Author

Answer selected by cueckoo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant