pipelines

package
v0.0.0-test Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

package pipelines has functions and types that orchestrate containers.

Index

Constants

This section is empty.

Variables

View Source
var IntegrationDatabases = []string{"sqlite", "mysql", "postgres"}
View Source
var PackagedPaths = []string{
	"Dockerfile",
	"LICENSE",
	"NOTICE.md",
	"README.md",
	"VERSION",
	"bin/",
	"conf/",
	"docs/sources/",
	"packaging/deb",
	"packaging/rpm",
	"packaging/docker",
	"packaging/wrappers",
	"plugins-bundled/",
	"public/",
	"npm-artifacts/",
}

PackagedPaths are paths that are included in the grafana tarball.

Functions

func CDN

func CDN(ctx context.Context, d *dagger.Client, args PipelineArgs) error

func Deb

func Deb(ctx context.Context, d *dagger.Client, args PipelineArgs) error

Deb uses the grafana package given by the '--package' argument and creates a .deb installer. It accepts publish args, so you can place the file in a local or remote destination.

func Docker

func Docker(ctx context.Context, d *dagger.Client, args PipelineArgs) error

Docker is a pipeline that uses a grafana.tar.gz as input and creates a Docker image using that same Grafana's Dockerfile. Grafana's Dockerfile should support supplying a tar.gz using a --build-arg.

func GrafanaBackendBuild

func GrafanaBackendBuild(ctx context.Context, d *dagger.Client, src *dagger.Directory, args PipelineArgs) error

GrafanaBackendBuild builds all of the distributions in the '--distros' argument and places them in the 'bin' directory of the PWD.

func GrafanaBackendBuildDirectories

func GrafanaBackendBuildDirectories(ctx context.Context, d *dagger.Client, opts *GrafanaCompileOpts, distros []executil.Distribution) (map[executil.Distribution]*dagger.Directory, error)

GrafanaBackendBuildDirectories builds multiple distributions and returns the directories for each one. The returned map of directories will be keyed by the distribution that the directory corresponds to.

func GrafanaBackendBuildDirectory

func GrafanaBackendBuildDirectory(ctx context.Context, d *dagger.Client, opts *GrafanaCompileOpts) (*dagger.Directory, error)

GrafanaBackendBuildDirectory returns a directory with the compiled backend binaries for the given distribution.

func GrafanaBackendTestIntegration

func GrafanaBackendTestIntegration(ctx context.Context, d *dagger.Client, src *dagger.Directory, args PipelineArgs) error

GrafanaBackendTestIntegration runs the Grafana backend test containers for short (unit) and integration tests.

func GrafanaBackendTests

func GrafanaBackendTests(ctx context.Context, d *dagger.Client, src *dagger.Directory, args PipelineArgs) error

GrafanaBackendTests runs the Grafana backend test containers for short (unit) and integration tests.

func GrafanaImageTags

func GrafanaImageTags(base BaseImage, registry string, opts TarFileOpts) []string

GrafanaImageTag returns the name of the grafana docker image based on the tar package name. To maintain backwards compatibility, we must keep this the same as it was before.

func ImageTag

func ImageTag(registry, org, repo, version string) string

func NPM

func NPM(ctx context.Context, d *dagger.Client, args PipelineArgs) error

NPM publishes the NPM packages in the grafana.tar.gz(s)

func Package

func Package(ctx context.Context, d *dagger.Client, opts PackageOpts) error

Package builds and packages Grafana into a tar.gz for each distribution provided.

func PackageFiles

func PackageFiles(ctx context.Context, d *dagger.Client, opts PackageOpts) (map[executil.Distribution]*dagger.File, error)

PackageFile builds and packages Grafana into a tar.gz for each dsitrbution and returns a map of the dagger file that holds each tarball, keyed by the distribution it corresponds to.

func PackageInstaller

func PackageInstaller(ctx context.Context, d *dagger.Client, args PipelineArgs, opts InstallerOpts) error

Uses the grafana package given by the '--package' argument and creates a installer. It accepts publish args, so you can place the file in a local or remote destination.

func PathsWithRoot

func PathsWithRoot(root string, paths []string) []string

func ProImage

func ProImage(ctx context.Context, dc *dagger.Client, args PipelineArgs) error

func PublishDirFunc

func PublishDirFunc(ctx context.Context, sm *semaphore.Weighted, d *dagger.Client, dir *dagger.Directory, opts *containers.GCPOpts, dst string) func() error

func PublishFileFunc

func PublishFileFunc(ctx context.Context, sm *semaphore.Weighted, d *dagger.Client, opts *containers.PublishFileOpts) func() error

func PublishPackage

func PublishPackage(ctx context.Context, d *dagger.Client, src *dagger.Directory, args PipelineArgs) error

PublishPackage creates a package and publishes it to a Google Cloud Storage bucket.

func RPM

func RPM(ctx context.Context, d *dagger.Client, args PipelineArgs) error

RPM uses the grafana package given by the '--package' argument and creates a .rpm installer. It accepts publish args, so you can place the file in a local or remote destination.

func ReplaceExt

func ReplaceExt(original, extension string) string

ReplaceExt replaces the extension of the given package name. For example, if the input package name (original) is grafana_v1.0.0_linux-arm64_1.tar.gz, then derivatives should have the same name, but with a different extension. This function also removes the leading directory and removes the URL scheme prefix.

func TarFilename

func TarFilename(opts TarFileOpts) string

TarFilename returns a file name that matches this format: {grafana|grafana-enterprise}_{version}_{os}_{arch}_{build_number}.tar.gz

func ValidatePackage

func ValidatePackage(ctx context.Context, d *dagger.Client, src *dagger.Directory, args PipelineArgs) error

ValidatePackage downloads a package and validates from a Google Cloud Storage bucket.

func ValidatePackageSignature

func ValidatePackageSignature(ctx context.Context, d *dagger.Client, src *dagger.Directory, args PipelineArgs) error

func ValidatePackageUpgrade

func ValidatePackageUpgrade(ctx context.Context, d *dagger.Client, src *dagger.Directory, args PipelineArgs) error

func WindowsInstaller

func WindowsInstaller(ctx context.Context, d *dagger.Client, args PipelineArgs) error

WindowsInstaller uses a debian image with 'nsis' installed to create the Windows installer. The WindowsInstaller also uses "winsw", or "Windows Service Wrapper" (https://github.com/winsw/winsw) to handle the status, start, and stop functions of the windows service so that Grafana doesn't have to implement it.

func WithoutExt

func WithoutExt(name string) string

func WriteToStdout

func WriteToStdout(v []string)

func Zip

func Zip(ctx context.Context, d *dagger.Client, args PipelineArgs) error

Types

type BaseImage

type BaseImage int
const (
	BaseImageUbuntu BaseImage = iota
	BaseImageAlpine
)

type ConcurrencyOpts

type ConcurrencyOpts struct {
	Parallel int64
}

func ConcurrencyOptsFromFlags

func ConcurrencyOptsFromFlags(c cliutil.CLIContext) *ConcurrencyOpts

type GrafanaCompileOpts

type GrafanaCompileOpts struct {
	// Source is the source tree of Grafana, ideally retrieved from a git clone. This argument is required.
	Source *dagger.Directory

	// Distribution is the target distribution to compile for. This argument is required.
	Distribution executil.Distribution

	// Platform is the dagger platform to run the containers on. Unless there's a specific requirement, this should be left empty to match the current running docker platform.
	Platform dagger.Platform

	// Version is the semver version number to insert into the binary via build arguments.
	Version string

	// Env is an optional map of environment variables (keyed by literal variable name to value) to set in the build container(s).
	Env    map[string]string
	GoTags []string

	// Edition is just used for logging / visualization purposes
	Edition string

	YarnCacheHostDir string
}

GrafanaCompileOpts are the options that must be supplied from the user to build Grafana.

func (*GrafanaCompileOpts) BackendCompileOpts

func (*GrafanaCompileOpts) BuildInfo

type InstallerOpts

type InstallerOpts struct {
	PackageType  string
	ConfigFiles  [][]string
	AfterInstall string
	BeforeRemove string
	Depends      []string
	EnvFolder    string
	ExtraArgs    []string
	RPMSign      bool
	Container    *dagger.Container
}

type PackageOpts

type PackageOpts struct {
	*GrafanaCompileOpts
	Distributions []executil.Distribution

	BuildID         string
	Edition         string
	NodeCacheVolume *dagger.CacheVolume
}

The PackageOpts command requires all of the options to build Grafana, but supports a list of distros instead of just one. It also requires extra options for determining the package name. While this struct embeds GrafanaCompileOpts, it ignores the 'Distribution' field in favor of the 'Distributions' list.

type PipelineArgs

type PipelineArgs struct {
	// These arguments are ones that are available at the global level.
	Verbose bool

	// Platform, where applicable, specifies what platform (linux/arm64, for example) to run the dagger containers on.
	// This should really only be used if you know what you're doing. misusing this flag can result in really slow builds.
	// Some example scenarios where you might want to use this:
	// * You're on linux/amd64 and you're building a docker image for linux/armv7 or linux/arm64
	// * You're on linux/arm64 and you're building a package for linux/arm64
	Platform dagger.Platform

	// Context is available for all sub-commands that define their own flags.
	Context cliutil.CLIContext

	// GrafanaOpts will be populated if the GrafanaFlags are enabled on the current sub-command.
	GrafanaOpts *containers.GrafanaOpts

	// PackageOpts will be populated if the PackageFlags are enabled on the current sub-command.
	PackageOpts *containers.PackageOpts

	// PublishOpts will be populated if the PublishFlags flags are enabled on the current sub-command
	// This is set for pipelines that publish artifacts.
	PublishOpts *containers.PublishOpts

	// PackageInputOpts will be populated if the PackageInputFlags are enabled on current sub-command.
	// This is set for pipelines that accept a package as input.
	PackageInputOpts *containers.PackageInputOpts
	GPGOpts          *containers.GPGOpts
	DockerOpts       *containers.DockerOpts
	GCPOpts          *containers.GCPOpts
	ConcurrencyOpts  *ConcurrencyOpts

	// ProImageOpts will be populated if ProImageFlags are enabled on the current sub-command.
	ProImageOpts *containers.ProImageOpts
}

func PipelineArgsFromContext

func PipelineArgsFromContext(ctx context.Context, c cliutil.CLIContext) (PipelineArgs, error)

PipelineArgsFromContext populates a pipelines.PipelineArgs from a CLI context.

type PipelineFuncWithPackageInput

type PipelineFuncWithPackageInput func(context.Context, *dagger.Client, PipelineArgs) error

type SyncWriter

type SyncWriter struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

func NewSyncWriter

func NewSyncWriter(w io.Writer) *SyncWriter

func (*SyncWriter) Write

func (w *SyncWriter) Write(b []byte) (int, error)

type TarFileOpts

type TarFileOpts struct {
	Version string
	BuildID string
	// Edition is the flavor text after "grafana-", like "enterprise".
	Edition string
	Distro  executil.Distribution
	Suffix  string
}

func TarOptsFromFileName

func TarOptsFromFileName(filename string) TarFileOpts

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL