presenters

package
v0.7.4-0...-fb5339c Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareMsg

func PrepareMsg(releaseEvent *kwrelease.Event) string

PrepareMsg prepares a short, markdown-like message which is suitable for sending to chat applications like Slack. Formatting like *text* us used to add emphasis. This is supported by both Slack and Google Chat. Emoji are also used liberally.

func PrepareServerStartupMsg

func PrepareServerStartupMsg(releases []*release.Release) string

PrepareServerStartupMsg prepares a message which is suitable for sending to a chat application like Slack on server startup. The message will contain information about the Helm charts that are installed in the cluster at the time of install. They will be presented in a monospaced table.

Types

type ExistingReleaseForJSON

type ExistingReleaseForJSON struct {
	AppName            string `json:"appName"`
	AppVersion         string `json:"appVersion"`
	Namespace          string `json:"namespace"`
	AppDescription     string `json:"appDescription"`
	InstallNotes       string `json:"installNotes"`
	ChartVersion       string `json:"chartVersion"`
	ReleaseDescription string `json:"releaseDescription"`
}

ExistingReleaseForJSON is a single release Event which may be contained in a ExistingReleasesForJSON object.

type ExistingReleasesForJSON

type ExistingReleasesForJSON struct {
	MessagePrefix string `json:"messagePrefix,omitempty"`
	// Do not use omitempty on existingReleases. Doing so requires the API to have a null check
	// before mapping over the existingReleases and generally makes it more likely that bugs will
	// occur for the users.
	ExistingReleases []*ExistingReleaseForJSON `json:"existingReleases"`
}

ExistingReleasesForJSON is used to marshal Helm release objects so they can be sent to an API.

There are two problems which just directly marshaling Helm release objects.

  1. They may contain sensitive data which should not leave the cluster.
  2. They are huge when marshalled because all the templates are stored within.

By implementing a custom struct we effectively whitelist the properties which should be send to any API.

func ToExistingReleasesForJSON

func ToExistingReleasesForJSON(releases []*rspb.Release) *ExistingReleasesForJSON

ToExistingReleasesForJSON takes a release Event and turns it into a ToExistingReleasesForJSON. It holds knowledge such where to find the message prefix environment variable.

type ReleaseEventForJSON

type ReleaseEventForJSON struct {
	AppName              string       `json:"appName"`
	AppVersion           string       `json:"appVersion"`
	Namespace            string       `json:"namespace"`
	PreviousAppVersion   string       `json:"previousAppVersion,omitempty"`
	Action               string       `json:"action"`
	AppDescription       string       `json:"appDescription"`
	InstallNotes         string       `json:"installNotes"`
	MessagePrefix        string       `json:"messagePrefix,omitempty"`
	CreatedAt            meta_v1.Time `json:"createdAt"`
	UpdatedAt            meta_v1.Time `json:"updatedAt"`
	SecretUID            types.UID    `json:"secretUid"`
	ChartVersion         string       `json:"chartVersion"`
	PreviousChartVersion string       `json:"previousChartVersion"`
	ReleaseDescription   string       `json:"releaseDescription"`
}

ReleaseEventForJSON is a container for a subset of the properties available in a typical Release Event. Release events contain all of the files present in the Helm package which was installed. They can be massive, larger than your typical JSON payload. They can also contain sensitive data. For this reason, we use ReleaseEventForJSON to whitelist properties.

Some fields may be denormalized because it makes more sense for users of the webhooks. The user wants to know what time the event occurred as a first class concept in the Json.

func ToReleaseEventForJSON

func ToReleaseEventForJSON(e *kwrelease.Event) *ReleaseEventForJSON

ToReleaseEventForJSON takes a release Event and turns it into a ReleaseEventForJSON. It holds knowledge such as when to omit certain empty time fields and where to find the message prefix.

Jump to

Keyboard shortcuts

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