config

package
v0.0.0-kmdagger2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: AGPL-3.0 Imports: 13 Imported by: 9

Documentation

Index

Constants

View Source
const (
	Tag         = "tag"
	PullRequest = "pull_request"
	Push        = "push"
	Custom      = "custom"
	Promote     = "promote"
	Cronjob     = "cron"
)
View Source
const (
	LibCMusl = "musl"
)
View Source
const (
	MainBranch = "main"
)
View Source
const PublicBucket = "grafana-downloads"

Variables

View Source
var Versions = VersionMap{
	PullRequestMode: {
		Variants: []Variant{
			VariantLinuxAmd64,
			VariantLinuxAmd64Musl,
			VariantDarwinAmd64,
			VariantWindowsAmd64,
			VariantArm64,
			VariantArm64Musl,
		},
		PluginSignature: PluginSignature{
			Sign:      false,
			AdminSign: false,
		},
		Docker: Docker{
			ShouldSave: false,
			Architectures: []Architecture{
				ArchAMD64,
				ArchARM64,
			},
			Distribution: []Distribution{
				Alpine,
			},
		},
	},
	MainMode: {
		Variants: []Variant{
			VariantArmV6,
			VariantArmV7,
			VariantArmV7Musl,
			VariantArm64,
			VariantArm64Musl,
			VariantDarwinAmd64,
			VariantWindowsAmd64,
			VariantLinuxAmd64,
			VariantLinuxAmd64Musl,
		},
		PluginSignature: PluginSignature{
			Sign:      true,
			AdminSign: true,
		},
		Docker: Docker{
			ShouldSave: false,
			Architectures: []Architecture{
				ArchAMD64,
				ArchARM64,
				ArchARMv7,
			},
			Distribution: []Distribution{
				Alpine,
				Ubuntu,
			},
		},
		Buckets: Buckets{
			Artifacts:            "grafana-downloads",
			ArtifactsEnterprise2: "grafana-downloads-enterprise2",
			CDNAssets:            "grafana-static-assets",
			Storybook:            "grafana-storybook",
		},
	},
	DownstreamMode: {
		Variants: []Variant{
			VariantArmV6,
			VariantArmV7,
			VariantArmV7Musl,
			VariantArm64,
			VariantArm64Musl,
			VariantDarwinAmd64,
			VariantWindowsAmd64,
			VariantLinuxAmd64,
			VariantLinuxAmd64Musl,
		},
		PluginSignature: PluginSignature{
			Sign:      true,
			AdminSign: true,
		},
		Docker: Docker{
			ShouldSave: true,
			Architectures: []Architecture{
				ArchAMD64,
				ArchARM64,
				ArchARMv7,
			},
			Distribution: []Distribution{
				Alpine,
				Ubuntu,
			},
		},
		Buckets: Buckets{
			Artifacts:            "grafana-downloads",
			ArtifactsEnterprise2: "grafana-downloads-enterprise2",
			CDNAssets:            "grafana-static-assets",
		},
	},
	ReleaseBranchMode: {
		Variants: []Variant{
			VariantArmV6,
			VariantArmV7,
			VariantArmV7Musl,
			VariantArm64,
			VariantArm64Musl,
			VariantDarwinAmd64,
			VariantWindowsAmd64,
			VariantLinuxAmd64,
			VariantLinuxAmd64Musl,
		},
		PluginSignature: PluginSignature{
			Sign:      true,
			AdminSign: true,
		},
		Docker: Docker{
			ShouldSave: true,
			Architectures: []Architecture{
				ArchAMD64,
				ArchARM64,
				ArchARMv7,
			},
			Distribution: []Distribution{
				Alpine,
				Ubuntu,
			},
			PrereleaseBucket: "grafana-prerelease/artifacts/docker",
		},
		Buckets: Buckets{
			Artifacts:            "grafana-downloads",
			ArtifactsEnterprise2: "grafana-downloads-enterprise2",
			CDNAssets:            "grafana-static-assets",
		},
	},
	TagMode: {
		Variants: []Variant{
			VariantArmV6,
			VariantArmV7,
			VariantArmV7Musl,
			VariantArm64,
			VariantArm64Musl,
			VariantDarwinAmd64,
			VariantWindowsAmd64,
			VariantLinuxAmd64,
			VariantLinuxAmd64Musl,
		},
		PluginSignature: PluginSignature{
			Sign:      true,
			AdminSign: true,
		},
		Docker: Docker{
			ShouldSave: true,
			Architectures: []Architecture{
				ArchAMD64,
				ArchARM64,
				ArchARMv7,
			},
			Distribution: []Distribution{
				Alpine,
				Ubuntu,
			},
			PrereleaseBucket: "grafana-prerelease/artifacts/docker",
		},
		Buckets: Buckets{
			Artifacts:            "grafana-prerelease/artifacts/downloads",
			ArtifactsEnterprise2: "grafana-prerelease/artifacts/downloads-enterprise2",
			CDNAssets:            "grafana-prerelease",
			CDNAssetsDir:         "artifacts/static-assets",
			Storybook:            "grafana-prerelease",
			StorybookSrcDir:      "artifacts/storybook",
		},
	},
	Enterprise2Mode: {
		Variants: []Variant{
			VariantArmV6,
			VariantArmV7,
			VariantArmV7Musl,
			VariantArm64,
			VariantArm64Musl,
			VariantDarwinAmd64,
			VariantWindowsAmd64,
			VariantLinuxAmd64,
			VariantLinuxAmd64Musl,
		},
		PluginSignature: PluginSignature{
			Sign:      true,
			AdminSign: true,
		},
		Docker: Docker{
			ShouldSave: true,
			Architectures: []Architecture{
				ArchAMD64,
				ArchARM64,
				ArchARMv7,
			},
			Distribution: []Distribution{
				Alpine,
				Ubuntu,
			},
			PrereleaseBucket: "grafana-prerelease/artifacts/docker",
		},
		Buckets: Buckets{
			Artifacts:            "grafana-prerelease/artifacts/downloads",
			ArtifactsEnterprise2: "grafana-prerelease/artifacts/downloads-enterprise2",
			CDNAssets:            "grafana-prerelease",
			CDNAssetsDir:         "artifacts/static-assets",
			Storybook:            "grafana-prerelease",
			StorybookSrcDir:      "artifacts/storybook",
		},
	},
	CloudMode: {
		Variants: []Variant{
			VariantLinuxAmd64Musl,

			VariantLinuxAmd64,
		},
		PluginSignature: PluginSignature{
			Sign:      true,
			AdminSign: true,
		},
		Docker: Docker{
			ShouldSave: true,
			Architectures: []Architecture{
				ArchAMD64,
			},
			Distribution: []Distribution{
				Alpine,
			},
			PrereleaseBucket: "grafana-prerelease/artifacts/docker",
		},
		Buckets: Buckets{
			Artifacts:            "grafana-prerelease/artifacts/downloads",
			ArtifactsEnterprise2: "grafana-prerelease/artifacts/downloads-enterprise2",
			CDNAssets:            "grafana-prerelease",
			CDNAssetsDir:         "artifacts/static-assets",
			Storybook:            "grafana-prerelease",
			StorybookSrcDir:      "artifacts/storybook",
		},
	},
}

Functions

func GetDroneCommit

func GetDroneCommit() (string, error)

func GetGrafanaVersion

func GetGrafanaVersion(buildID, grafanaDir string) (string, error)

GetGrafanaVersion gets the Grafana version from the package.json

func GrafanaTimestamp

func GrafanaTimestamp(ctx context.Context, dir string) (int64, error)

Types

type Architecture

type Architecture string

Architecture is an allowed value in the GOARCH environment variable.

const (
	ArchAMD64  Architecture = "amd64"
	ArchARMv6  Architecture = "armv6"
	ArchARMv7  Architecture = "armv7"
	ArchARM64  Architecture = "arm64"
	ArchARMHF  Architecture = "armhf"
	ArchARMHFP Architecture = "armhfp"
	ArchARM    Architecture = "arm"
)

type Buckets

type Buckets struct {
	Artifacts            string `json:"artifacts,omitempty"`
	ArtifactsEnterprise2 string `json:"artifactsEnterprise2,omitempty"`
	CDNAssets            string `json:"CDNAssets,omitempty"`
	CDNAssetsDir         string `json:"CDNAssetsDir,omitempty"`
	Storybook            string `json:"storybook,omitempty"`
	StorybookSrcDir      string `json:"storybookSrcDir,omitempty"`
}

type BuildConfig

type BuildConfig struct {
	Variants        []Variant       `json:"variants,omitempty"`
	PluginSignature PluginSignature `json:"pluginSignature,omitempty"`
	Docker          Docker          `json:"docker,omitempty"`
	Buckets         Buckets         `json:"buckets,omitempty"`
}

BuildConfig represents the struct that defines all of the different variables used to build Grafana

func GetBuildConfig

func GetBuildConfig(mode VersionMode) (*BuildConfig, error)

GetBuildConfig reads the embedded config.json and decodes it.

type Config

type Config struct {
	Version        string
	Bucket         string
	DebRepoBucket  string
	DebDBBucket    string
	RPMRepoBucket  string
	GPGPassPath    string
	GPGPrivateKey  string
	GPGPublicKey   string
	NumWorkers     int
	GitHubUser     string
	GitHubToken    string
	PullEnterprise bool
	PackageVersion string
	SignPackages   bool
}

type Distribution

type Distribution string

Distribution is the base os image where the Grafana image is built on.

const (
	Ubuntu Distribution = "ubuntu"
	Alpine Distribution = "alpine"
)

type Docker

type Docker struct {
	ShouldSave       bool           `json:"shouldSave,omitempty"`
	Distribution     []Distribution `json:"distribution,omitempty"`
	Architectures    []Architecture `json:"archs,omitempty"`
	PrereleaseBucket string         `json:"prereleaseBucket,omitempty"`
}

type Edition

type Edition string
const (
	EditionOSS         Edition = "oss"
	EditionEnterprise  Edition = "enterprise"
	EditionEnterprise2 Edition = "enterprise2"
)

type LibC

type LibC string

type Metadata

type Metadata struct {
	GrafanaVersion string      `json:"version,omitempty"`
	ReleaseMode    ReleaseMode `json:"releaseMode,omitempty"`
	GrabplVersion  string      `json:"grabplVersion,omitempty"`
	CurrentCommit  string      `json:"currentCommit,omitempty"`
}

func GenerateMetadata

func GenerateMetadata(c *cli.Context) (Metadata, error)

func (*Metadata) GetReleaseMode

func (md *Metadata) GetReleaseMode() (ReleaseMode, error)

type OS

type OS string
const (
	OSWindows OS = "windows"
	OSDarwin  OS = "darwin"
	OSLinux   OS = "linux"
)

type PluginSignature

type PluginSignature struct {
	Sign      bool `json:"sign,omitempty"`
	AdminSign bool `json:"adminSign,omitempty"`
}

type ReleaseMode

type ReleaseMode struct {
	Mode      VersionMode `json:"mode,omitempty"`
	IsPreview bool        `json:"IsPreview,omitempty"`
	IsTest    bool        `json:"isTest,omitempty"`
}

func CheckSemverSuffix

func CheckSemverSuffix() (ReleaseMode, error)

type Revision

type Revision struct {
	Timestamp int64
	SHA256    string
	Branch    string
}

func GrafanaRevision

func GrafanaRevision(ctx context.Context, grafanaDir string) (Revision, error)

GrafanaRevision uses git commands to get information about the checked out Grafana code located at 'grafanaDir'. This could maybe be a more generic "Describe" function in the "git" package.

type Variant

type Variant string

Variant is the OS / Architecture combination that Grafana can be compiled for.

const (
	VariantLinuxAmd64     Variant = "linux-amd64"
	VariantLinuxAmd64Musl Variant = "linux-amd64-musl"
	VariantArmV6          Variant = "linux-armv6"
	VariantArmV7          Variant = "linux-armv7"
	VariantArmV7Musl      Variant = "linux-armv7-musl"
	VariantArm64          Variant = "linux-arm64"
	VariantArm64Musl      Variant = "linux-arm64-musl"
	VariantDarwinAmd64    Variant = "darwin-amd64"
	VariantWindowsAmd64   Variant = "windows-amd64"
)

type VersionMap

type VersionMap map[VersionMode]BuildConfig

VersionMap is a map of versions. Each key of the Versions map is an event that uses the the config as the value for that key. For example, the 'pull_request' key will have data in it that might cause Grafana to be built differently in a pull request, than the way it will be built in 'main'

type VersionMode

type VersionMode string

VersionMode defines the source event that created a release or published version

const (
	MainMode          VersionMode = "main"
	TagMode           VersionMode = "release"
	ReleaseBranchMode VersionMode = "branch"
	PullRequestMode   VersionMode = "pull_request"
	DownstreamMode    VersionMode = "downstream"
	Enterprise2Mode   VersionMode = "enterprise2"
	CronjobMode       VersionMode = "cron"
	CloudMode         VersionMode = "cloud"
)

func CheckDroneTargetBranch

func CheckDroneTargetBranch() (VersionMode, error)

Jump to

Keyboard shortcuts

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