Lingon is a collection of libraries and tools for building platforms using Go.

  • By Volvo Cars
  • Last update: Apr 6, 2023
  • Comments: 7

Go Reference GoReportCard example License

Lingon 🍒 - Libraries for building platforms with Go

What is this?

Lingon is a collection of libraries and tools for building platforms using Go.

In short, we write Terraform (HCL) and Kubernetes (YAML) in Go. see Rationale for more details.

Lingon is not a platform, it is a library meant to be consumed in a Go application that platform engineers write to manage their platforms. It is a tool to build and automate the creation and the management of platforms regardless of the target infrastructure and services.

The following technologies are currently supported:

The only dependencies you need are:

  • Go
  • Terraform CLI
  • kubectl

Who is this for?

Lingon is aimed at people who need to automate the lifecycle of their cloud infrastructure and have suffered the pain of configuration languages and complexity of gluing tools together with more tools.

Project status

This project is in beta. The APIs are stable, but we do not promise backward compatibility at this point. We will eventually promise backward compatibility when the project is more battle tested.

See FAQ for more details.

Getting started

Note that in the terraform case, the code generation is fast. Compiling all the generated resources will take a while. Thankfully, Go is fast at compiling and keeps a cache of compiled packages. Expect to wait a few minutes the first time you run go build after generating the code.

Examples

All the Examples are in the documentation.

There is a web app to showcase the conversion from kubernetes manifests from YAML to Go .

A big example is Platypus which shows how the kubernetes and terraform libraries can be used together.

Motivation

See Rationale for more details.

Lingon was developed to achieve the following goals:

Reduce cognitive load

Building a platform within a single context (i.e. Go) will reduce cognitive load by decreasing the number of tools and context switching in the process. It provides a better developer experience with out-of-the-box IDE support and a single language to learn with smooth learning curve.

Type safety

Detect misconfigurations in your text editor by using type-safe Go structs to exchange values across tool boundaries. This "shifts left" the majority of errors that occur to the earliest possible point in time.

Error handling

Go's error handling enables propagating meaningful errors to the user. This significantly reduces the effort in finding the root cause of errors and provides a better developer experience.

Limitless automation

We are only limited by what a programming language can do. We can reuse part of what we build in libraries without external tooling. That is not possible with YAML as doesn't support "includes", therefore we need a tool for that. Configuration languages are limited by the features they provide. Gluing tools together with more tools and configuration to manage more tools and configuration is not a sustainable approach. We do use a limited set of tools that we learn well and can extend, but we automate them and test them together using Go.

Note that we are in a particular situation where we need custom automation of the lifecycle of our cloud infrastructure.

Why Go?

Because most outages are caused by a configuration error.

Similar projects

See Comparison for more details.

License

This code is released under the Apache-2.0 License.

Download

lingon.zip

Comments(7)

  • 1

    Bump mvdan.cc/gofumpt from 0.4.0 to 0.5.0

    Bumps mvdan.cc/gofumpt from 0.4.0 to 0.5.0.

    Release notes

    Sourced from mvdan.cc/gofumpt's releases.

    v0.5.0

    This release is based on Go 1.20's gofmt, and requires Go 1.19 or later.

    The biggest change in this release is that we now vendor copies of the packages go/format, go/printer, and go/doc/comment on top of cmd/gofmt itself. This allows for each gofumpt release to format code in exactly the same way no matter what Go version is used to build it, as Go versions can change those three packages in ways that alter formatting behavior.

    This vendoring adds a small amount of duplication when using the mvdan.cc/gofumpt/format library, but it's the only way to make gofumpt versions consistent in their behavior and formatting, just like gofmt.

    The jump to Go 1.20's go/printer should also bring a small performance improvement, as we contributed patches to make printing about 25% faster:

    The following changes are included as well:

    • Skip testdata dirs by default like we already do for vendor - #260
    • Avoid inserting newlines incorrectly in some func signatures - #235
    • Avoid joining some comments with the previous line - #256
    • Fix gofumpt -version for release archives - #253

    Binaries built on go version go1.20.3 linux/amd64 with:

    CGO_ENABLED=0 go build -trimpath -ldflags="-w -s -X=main.version=v0.5.0"

    Consider becoming a sponsor if you benefit from the work that went into this release!

    #235: mvdan/gofumpt#235 #253: mvdan/gofumpt#253 #256: mvdan/gofumpt#256 #260: mvdan/gofumpt#260

    Changelog

    Sourced from mvdan.cc/gofumpt's changelog.

    [v0.5.0] - 2023-04-09

    This release is based on Go 1.20's gofmt, and requires Go 1.19 or later.

    The biggest change in this release is that we now vendor copies of the packages go/format, go/printer, and go/doc/comment on top of cmd/gofmt itself. This allows for each gofumpt release to format code in exactly the same way no matter what Go version is used to build it, as Go versions can change those three packages in ways that alter formatting behavior.

    This vendoring adds a small amount of duplication when using the mvdan.cc/gofumpt/format library, but it's the only way to make gofumpt versions consistent in their behavior and formatting, just like gofmt.

    The jump to Go 1.20's go/printer should also bring a small performance improvement, as we contributed patches to make printing about 25% faster:

    The following changes are included as well:

    • Skip testdata dirs by default like we already do for vendor - #260
    • Avoid inserting newlines incorrectly in some func signatures - #235
    • Avoid joining some comments with the previous line - #256
    • Fix gofumpt -version for release archives - #253
    Commits
    • fd93f1d add release notes for v0.5.0
    • e2f1a6e skip over testdata dirs like we do with vendor
    • 48add90 add broken test case which reorders and separates imports
    • 05ac8b3 fix a case where we joined a comment with the previous line
    • 8b01b13 relax rule to insert newlines in func signatures
    • 4af70f1 remove obsolete build tags and Go version checks
    • d5451f0 support -ldflags=main.version= again
    • 92e2be6 internal/govendor: undo upstream change to use strings.CutPrefix
    • 04a7ba7 update deps
    • 086496c update cmd/gofmt source with Go 1.20
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • 2

    Bump github.com/dave/jennifer from 1.6.0 to 1.6.1

    Bumps github.com/dave/jennifer from 1.6.0 to 1.6.1.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • 3

    Bump github.com/fatih/color from 1.14.1 to 1.15.0

    Bumps github.com/fatih/color from 1.14.1 to 1.15.0.

    Release notes

    Sourced from github.com/fatih/color's releases.

    v1.15.0

    What's Changed

    New Contributors

    Full Changelog: https://github.com/fatih/color/compare/v1.14.1...v1.15.0

    Commits
    • 12126ed Merge pull request #188 from pellared/patch-1
    • 770038b Merge branch 'main' into patch-1
    • c5d9a2b Merge pull request #189 from fatih/dependabot/go_modules/golang.org/x/sys-0.6.0
    • 1ceb746 Bump golang.org/x/sys from 0.5.0 to 0.6.0
    • 66a1b89 Merge pull request #191 from fatih/update-ci-deps
    • 3228f5a ci: update dependencies
    • 0226ec9 Refactor color_windows.go
    • d080a5b Merge pull request #186 from martinlindhe/main
    • 02ab2ea windows: enable virtual terminal processing, fixes #169
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • 4

    Refactor `kube.Export` and `terra.Export` to use function-option pattern

    Replace kube.Export and kube.ExportWriter with kube.Export that uses function options, to declare an out directory or io.Writer. Same for terra.Export.

    Reason is for maintaining backwards compatibility in the long run.

  • 5

    Add terra documentation to `doc.go` in root of project

    Currently the doc.go in the root of the project only mentions Kubernetes.

    Perhaps we should have:

    • docs/kubernetes/doc.go
    • docs/terra/doc.go

    And doc.go in the root references those.

  • 6

    Generate secrets/certs on the fly for example

    It serves as a great example of what NOT to do. 😉 It is just an example and we don't have a better way to store secrets securely for that. Also, it would be very difficult for people just trying things out.

    It is not impossible but would require more work to generate one in Go on the fly.

  • 7

    Improved CI chores

    • [x] automatically generates files (license, SBOM, ....) and commit
    • [x] generate releases for binaries #47
    • [x] run git diff and fail if there is a difference
    • [ ] organize mage and its dependency to be usable in CI
    • [x] homebrew tap https://github.com/volvo-cars/lingon/commit/e3eff89ebb9d136f8f0037f579720ee42f822181