Skip to content

Repository files navigation

Kavun Cloud Go Runtime

go-runtime is a Go helper package for accessing runtime information for a Kavun Cloud (hereinafter referred to as "KC") application instance.

It reads the immutable runtime manifest exposed to managed services and provides equivalent defaults for local development, allowing programs to be tested outside KC.

Usage is fairly simple. As the library is intended to be "dumb", it does not know whether it is actually running on KC. Instead, you must specify that explicitly through the Mode field of kavuncloud.Options.

Usually, selecting between kavuncloud.Managed and kavuncloud.Development is done based on a user-specified production boolean.

We did not want to "assume KC if runtime.json exists" or silently fall back to something else, which is why the Managed vs Development distinction is manual.

Managed mode

environment, err:=kavuncloud.Load(kavuncloud.Options{
Mode: kavuncloud.Managed,
})
iferr!=nil {
returnerr
}
listener, err:=environment.Listener("http")
secret, err:=environment.GetSecret("ApiKey")

Managed mode requires the runtime manifest at /run/kavuncloud/runtime.json.

Development mode

Development mode lets you provide local equivalents for resources that KC would normally supply.

environment, err:=kavuncloud.Load(kavuncloud.Options{
Mode: kavuncloud.Development,
Development: kavuncloud.DevelopmentOptions{
ProjectName: "Passport",
ApplicationName: "Passport API",
Drives: map[string]kavuncloud.Drive{
"data": {Path: ".data"},
},
},
})

Unless explicitly overridden, development mode uses the following defaults:

  • System: the current working directory
  • Runtime: .data/runtime/
  • Temporary: the operating system's temporary directory
  • Secrets: .env/ (yes, as a directory, not a file)

About

Kavun Cloud runtime library for Go

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages