Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Annotate example #153

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion examples/dna-store/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ type Metadata struct {
Tags map[string]string `pulumi:"tags,optional"`
}

// Annotate the nested fields for the Metadata receiver
func (m *Metadata) Annotate(a infer.Annotator) {
a.Describe(&m.SampleType, "sample type of the dna")
a.Describe(&m.Tags, "optional tags associated with the dna sample")
}

type DNAStoreArgs struct {
Data []Molecule `pulumi:"data"`
Storage string `pulumi:"filedir"`
Expand Down Expand Up @@ -171,7 +177,6 @@ func (*DNAStore) Read(ctx p.Context, id string, inputs DNAStoreArgs, state DNASt
}
}

file, err = os.Open(path + ".metadata")
state = DNAStoreArgs{
Data: molecules,
Storage: filepath.Dir(id),
Expand All @@ -180,6 +185,12 @@ func (*DNAStore) Read(ctx p.Context, id string, inputs DNAStoreArgs, state DNASt
return path, state, state, nil
}

// Annotate the nested fields for the DNAStoreArgs receiver
func (d *DNAStoreArgs) Annotate(a infer.Annotator) {
a.Describe(&d.Data, "molecule data")
a.Describe(&d.Metadata, "stores information related to a particular dna")
}

func main() {
err := p.RunProvider("dna-store", "0.1.0",
infer.Provider(infer.Options{
Expand Down
Loading