A tool to generate Pulumi Package schemas from Go type definitions

MkSchema

A tool to generate Pulumi Package schemas from Go type definitions.

This tool translates annotated Go files into Pulumi component schema metadata, which is in JSON Schema. This allows a component author to begin by writing the same Go structures, which is often more natural. It also has the benefit of using these same structures in the implementation of the component itself.

To use the tool, first install it:

go get -u github.com/joeduffy/pulumi-mkschema

It accepts two arguments: the Pulumi Package name and the Go package path to generate types from:

pulumi-mkschema [PULUMI-PKG-NAME] [GO-SOURCE-PKG]

How it works

MkSchema will parse and semantically analyze the Go package's metadata. It looks for publicly exported types that are annotated as either resources or complex types.

Resource types are any structs that embed the pulumi.ResourceState resource:

type MyComponent struct {
    pulumi.ResourceState
    ...
}

Complex types are any structs that have pulumi:"..." annotated fields within them:

type MyStateStruct struct {
    Name string `pulumi:"name"`
    ...
}

Pulumi tag options

The pulumi:"..." tags can be used to control schema generation behavior. Similar to familiar Go tags like json:"...", the first element is the Pulumi name, followed by optional comma-delimited options.

These options include:

  • optional: mark that the property is optional (default is required)
  • replaces: indicate that a property, if changed, implies replacement behavior
  • in: indicate that a property is input-only
  • out: indicate that a property is output-only
  • ref: reference an externally defined type, rather than intra-package (which is the default)
Owner
Joe Duffy
Founder/CEO Pulumi • Cloud, languages, and developer tools • Eat, sleep, code, repeat
Joe Duffy
Similar Resources

Type-safe atomic values for Go

Type-safe atomic values for Go One issue with Go's sync/atomic package is that there is no guarantee from the type system that operations on an intege

Apr 8, 2022

A command line tool to generate sequence diagrams

A command line tool to generate sequence diagrams

goseq - text based sequence diagrams A small command line utility used to generate UML sequence diagrams from a text-base definition file. Inspired by

Dec 22, 2022

CLI tool to generate preview images from a zmk .keymap file

CLI tool to generate preview images from a zmk .keymap file

ZMK viewer A work in progress Cli tool to generate preview images from a zmk .keymap file. Installation You can download a pre compiled binary directl

Jan 3, 2023

HTTP service to generate PDF from Json requests

pdfgen HTTP service to generate PDF from Json requests Install and run The recommended method is to use the docker container by mounting your template

Dec 2, 2022

Automatically generate Go test boilerplate from your source code.

Automatically generate Go test boilerplate from your source code.

gotests gotests makes writing Go tests easy. It's a Golang commandline tool that generates table driven tests based on its target source files' functi

Jan 3, 2023

generate fake data in go

Faker for Go Usage package main import ( "github.com/manveru/faker" ) func main() { fake, err := faker.New("en") if err != nil { panic(err

Sep 29, 2022

:runner:runs go generate recursively on a specified path or environment variable and can filter by regex

Package generate Package generate runs go generate recursively on a specified path or environment variable like $GOPATH and can filter by regex Why wo

Sep 27, 2022

generate my_github status using GitHub Actions

generate my_github status using GitHub Actions

generate my_github status using GitHub Actions

Sep 21, 2022

Generate spreadsheets based on GitHub contributions

pullsheet generates a CSV (comma separated values) & HTML output about GitHub activity across a series of repositories.

Oct 17, 2022
Comments
  • Fix module package, upgrade to go 1.18

    Fix module package, upgrade to go 1.18

    • Upgrade to Go 1.18
    • go get --> go install
    • module github.com/pulumi/pulumi-mkschema --> github.com/joeduffy/pulumi-mkschema

    Module path is for github.com/pulumi/pulumi-mkschema, so go install fails:

    $ go install github.com/joeduffy/pulumi-mkschema@latest
    go: github.com/joeduffy/pulumi-mkschema@latest: github.com/joeduffy/[email protected]: parsing go.mod:
            module declares its path as: github.com/pulumi/pulumi-mkschema
                    but was required as: github.com/joeduffy/pulumi-mkschema
    
  • Go Get

    Go Get

    go get: github.com/joeduffy/[email protected]: parsing go.mod: module declares its path as: github.com/pulumi/pulumi-mkschema but was required as: github.com/joeduffy/pulumi-mkschema

Generate type-safe Go converters by simply defining an interface

goverter a "type-safe Go converter" generator goverter is a tool for creating type-safe converters. All you have to do is create an interface and exec

Jan 4, 2023
Deploy TiDB with Pulumi effortlessly.

TiDB ❤️ Pulumi Deploy TiDB with Pulumi effortlessly. It should be easy to spin up some virtual machines, and deploy a TiDB cluster there for developme

Jun 24, 2022
A boilerplate showing how to create a Pulumi component provider written in Go

xyz Pulumi Component Provider (Go) This repo is a boilerplate showing how to create a Pulumi component provider written in Go. You can search-replace

Mar 4, 2022
Pulumi Terraform provider for Artifactory

Terraform Bridge Provider Boilerplate This repository contains boilerplate code for building a new Pulumi provider which wraps an existing Terraform p

Aug 11, 2022
Go package and associated command line utility to generate random yet human-readable names and identifiers
Go package and associated command line utility to generate random yet human-readable names and identifiers

namegen | What's this? Go package and associated command line utility to generate random yet human-readable names and identifiers. Somewhat inspired b

Oct 19, 2022
Type-safe Prometheus metrics builder library for golang

gotoprom A Prometheus metrics builder gotoprom offers an easy to use declarative API with type-safe labels for building and using Prometheus metrics.

Dec 5, 2022
safe and easy casting from one type to another in Go

cast Easy and safe casting from one type to another in Go Don’t Panic! ... Cast What is Cast? Cast is a library to convert between different go types

Jan 7, 2023
Analyze the binary outputted by `go build` to get type information etc.

Analyze the binary outputted by go build to get type information etc.

Oct 5, 2022
IBus Engine for GoVarnam. An easy way to type Indian languages on GNU/Linux systems.

IBus Engine For GoVarnam An easy way to type Indian languages on GNU/Linux systems. goibus - golang implementation of libibus Thanks to sarim and haun

Feb 10, 2022
Lithia is an experimental functional programming language with an implicit but strong and dynamic type system.

Lithia is an experimental functional programming language with an implicit but strong and dynamic type system. Lithia is designed around a few core concepts in mind all language features contribute to.

Dec 24, 2022