Documentation ¶
Index ¶
- Constants
- Variables
- func GenPullRequestComponentName(component, prNumber string) string
- func GenReleaseName(namespace, compName string) string
- func GenStagingNamespace(teamName string) string
- func GetDefaultLabels(teamName string) map[string]string
- func GetTeamLabelKey() string
- type ActivePromotionConfig
- type ActivePromotionController
- type ActivePromotionOption
- type ActivePromotionReporter
- type ComponentUpgradeOption
- type ComponentUpgradeReporter
- type ConfigController
- type ConfigurationJSON
- type Connection
- type DeployEngine
- type DesiredComponentChecker
- type DesiredComponentController
- type EventType
- type GitInfo
- type HTTPHeader
- type ImageMissingReporter
- type IssueType
- type MSTeamsCredential
- type Plugin
- type PostNamespaceCreation
- type PullRequestConfig
- type PullRequestData
- type PullRequestTriggerController
- type PullRequestTriggerReporter
- type QueueController
- type Reporter
- type SamsahaiConfig
- type SamsahaiController
- type SamsahaiCredential
- type SortableVersion
- type StableComponentController
- type StagingConfig
- type StagingController
- type StagingTestRunner
- type StatusType
Constants ¶
const ( // URIHealthz represents URI for health check URIHealthz = "/healthz" URIVersion = "/version" //SamsahaiCtrlName = "samsahai-ctrl" SamsahaiAuthHeader = "x-samsahai-auth" SamsahaiDefaultPort = "8080" StagingCtrlName = "s2h-staging-ctrl" StagingDefaultPort = 8090 // Viper keys VKDebug = "debug" VKServerHTTPPort = "port" VKMetricHTTPPort = "metric-port" VKPodNamespace = "pod-namespace" VKS2HConfigPath = "s2h-config-path" VKClusterDomain = "cluster-domain" VKS2HTeamName = "s2h-team-name" VKS2HAuthToken = "s2h-auth-token" VKS2HServerURL = "s2h-server-url" VKS2HServiceName = "s2h-service-name" VKS2HServiceScheme = "s2h-service-scheme" VKS2HImage = "s2h-image" VKS2HExternalURL = "s2h-external-url" VKTeamcityURL = "teamcity-url" VKTeamcityUsername = "teamcity-username" VKTeamcityPassword = "teamcity-password" VKSlackToken = "slack-token" VKMSTeamsTenantID = "ms-teams-tenant-id" VKMSTeamsClientID = "ms-teams-client-id" VKMSTeamsClientSecret = "ms-teams-client-secret" VKMSTeamsUsername = "ms-teams-username" VKMSTeamsPassword = "ms-teams-password" VKActivePromotionConcurrences = "active-promotion-concurrences" VKActivePromotionTimeout = "active-promotion-timeout" VKActivePromotionDemotionTimeout = "active-demotion-timeout" VKActivePromotionRollbackTimeout = "active-promotion-rollback-timeout" VKActivePromotionTearDownDuration = "active-promotion-teardown-duration" VKActivePromotionMaxRetry = "active-promotion-max-retry" VKActivePromotionMaxHistories = "active-promotion-max-histories" VKActivePromotionOnTeamCreation = "active-promotion-on-team-creation" VKQueueMaxHistoryDays = "queue-max-history-days" VKPRQueueConcurrences = "pr-queue-concurrences" VKPRVerificationMaxRetry = "pr-verification-max-retry" VKPRTriggerMaxRetry = "pr-trigger-max-retry" VKPRTriggerPollingTime = "pr-trigger-polling-time" VKPullRequestQueueMaxHistoryDays = "pr-queue-max-history-days" )
const AbbreviationName = "s2h"
const AppName = "samsahai"
const AppPrefix = AbbreviationName + "-"
const (
MaxReleaseNameLength = 53
)
Variables ¶
var GitCommit string
GitCommit defines commit hash of git during built
var Version string
Version defines the version of application
Functions ¶
func GenPullRequestComponentName ¶ added in v1.7.0
GenPullRequestComponentName generates PullRequest object name from component and pull request number
func GenReleaseName ¶
GenReleaseName returns the release name for deploying components
func GenStagingNamespace ¶
GenStagingNamespace returns the name of staging namespace by team name
func GetDefaultLabels ¶
GetDefaultLabels returns default labels for kubernetes resources
Types ¶
type ActivePromotionConfig ¶
type ActivePromotionConfig struct { // Concurrences defines number of active promotion concurrences Concurrences int `json:"concurrences" yaml:"concurrences"` // Timeout defines timeout duration of active promotion process Timeout metav1.Duration `json:"timeout" yaml:"timeout"` // DemotionTimeout defines timeout duration of active demotion process DemotionTimeout metav1.Duration `json:"demotionTimeout" yaml:"demotionTimeout"` // RollbackTimeout defines timeout duration of rollback process RollbackTimeout metav1.Duration `json:"rollbackTimeout" yaml:"rollbackTimeout"` // TearDownDuration defines tear down duration of previous active environment TearDownDuration metav1.Duration `json:"teardownDuration" yaml:"teardownDuration"` // MaxRetry defines max retry counts of active promotion process in case failure MaxRetry *int `json:"maxRetry"` // MaxHistories defines max stored histories of active promotion MaxHistories int `json:"maxHistories" yaml:"maxHistories"` // PromoteOnTeamCreation defines whether auto-promote active environment or not when team creation? PromoteOnTeamCreation bool `json:"promoteOnTeamCreation" yaml:"promoteOnTeamCreation"` }
ActivePromotionConfig represents configuration of active promotion
type ActivePromotionController ¶
type ActivePromotionController interface { }
type ActivePromotionOption ¶
type ActivePromotionOption func(*ActivePromotionReporter)
ActivePromotionOption allows specifying various configuration
func WithCredential ¶
func WithCredential(creds s2hv1beta1.Credential) ActivePromotionOption
TODO: should override tc credential per team WithCredential specifies credential to override when create active promotion reporter object
type ActivePromotionReporter ¶
type ActivePromotionReporter struct { TeamName string `json:"teamName,omitempty"` CurrentActiveNamespace string `json:"currentActiveNamespace,omitempty"` Runs int `json:"runs,omitempty"` Credential s2hv1beta1.Credential `json:"credential,omitempty"` Envs map[string]string s2hv1beta1.ActivePromotionStatus SamsahaiConfig }
ActivePromotionReporter manages active promotion report
func NewActivePromotionReporter ¶
func NewActivePromotionReporter(status s2hv1beta1.ActivePromotionStatus, s2hConfig SamsahaiConfig, teamName, currentNs string, runs int, opts ...ActivePromotionOption) *ActivePromotionReporter
NewActivePromotionReporter creates active promotion reporter object
type ComponentUpgradeOption ¶
type ComponentUpgradeOption func(*ComponentUpgradeReporter)
ComponentUpgradeOption allows specifying various configuration
func WithNamespace ¶ added in v1.7.0
func WithNamespace(ns string) ComponentUpgradeOption
WithNamespace specifies namespace to override when creating component upgrade reporter object
func WithQueueHistoryName ¶
func WithQueueHistoryName(qHist string) ComponentUpgradeOption
WithQueueHistoryName specifies queuehistory name to override when creating component upgrade reporter object QueueHistoryName will be the latest failure of component upgrade if reverification is success, QueueHistoryName will be the history of queue before running reverification
func WithTestRunner ¶
func WithTestRunner(tr s2hv1beta1.TestRunner) ComponentUpgradeOption
WithTestRunner specifies test runner to override when creating component upgrade reporter object
type ComponentUpgradeReporter ¶
type ComponentUpgradeReporter struct { IssueTypeStr IssueType `json:"issueTypeStr,omitempty"` StatusStr StatusType `json:"statusStr,omitempty"` StatusInt int32 `json:"statusInt,omitempty"` TestRunner s2hv1beta1.TestRunner `json:"testRunner,omitempty"` Credential s2hv1beta1.Credential `json:"credential,omitempty"` Envs map[string]string *rpc.ComponentUpgrade SamsahaiConfig }
ComponentUpgradeReporter manages component upgrade report
func NewComponentUpgradeReporter ¶
func NewComponentUpgradeReporter(comp *rpc.ComponentUpgrade, s2hConfig SamsahaiConfig, opts ...ComponentUpgradeOption) *ComponentUpgradeReporter
NewComponentUpgradeReporter creates component upgrade reporter from rpc object
type ConfigController ¶ added in v1.1.0
type ConfigController interface { // Get returns configuration from memory Get(configName string) (*s2hv1beta1.Config, error) // GetComponents returns all components from `Configuration` that has valid `Source` GetComponents(configName string) (map[string]*s2hv1beta1.Component, error) // GetParentComponents returns components that doesn't have parent (nil Parent) GetParentComponents(configName string) (map[string]*s2hv1beta1.Component, error) // GetPullRequestComponents returns all pull request components from `Configuration` that has valid `Source` GetPullRequestComponents(configName string) (map[string]*s2hv1beta1.Component, error) // GetBundles returns a group of components for each bundle GetBundles(configName string) (s2hv1beta1.ConfigBundles, error) // GetPriorityQueues returns a list of priority queues which defined in Config GetPriorityQueues(configName string) ([]string, error) // GetPullRequestConfig returns a configuration of pull request GetPullRequestConfig(configName string) (*s2hv1beta1.ConfigPullRequest, error) // GetPullRequestComponentDependencies returns a pull request component dependencies from configuration GetPullRequestComponentDependencies(configName, prCompName string) ([]string, error) // Update updates Config CRD Update(config *s2hv1beta1.Config) error // Delete deletes Config CRD Delete(configName string) error //EnsureConfigTemplateChanged updates config if template changed EnsureConfigTemplateChanged(config *s2hv1beta1.Config) error }
type ConfigurationJSON ¶
type ConfigurationJSON struct { GitRevision string `json:"gitRevision"` Configuration *s2hv1beta1.ConfigSpec `json:"config"` }
type Connection ¶
type DeployEngine ¶
type DeployEngine interface { // GetName returns name of deploy engine GetName() string // GetValues returns yaml values of release deployment GetValues() (map[string][]byte, error) // Create creates environment Create(refName string, comp *v1beta1.Component, parentComp *v1beta1.Component, values map[string]interface{}, deployTimeout *time.Duration) error // Rollback rollback helm release Rollback(refName string, revision int) error // GetHistories returns histories of release GetHistories(refName string) ([]*release.Release, error) // Delete deletes environment Delete(refName string) error // ForceDelete deletes environment when timeout ForceDelete(refName string) error // GetLabelSelector returns map of label for select the components that created by the engine GetLabelSelectors(refName string) map[string]string // GetReleases returns all deployed releases GetReleases() ([]*release.Release, error) // IsMocked uses for skip some functions due to mock deploy // // Skipped function: WaitForComponentsCleaned IsMocked() bool }
type DesiredComponentChecker ¶
type DesiredComponentChecker interface { // GetName returns name of checker GetName() string // GetVersion returns version from defined pattern GetVersion(repository string, name string, pattern string) (string, error) //EnsureVersion ensures the defined version is exist on repository EnsureVersion(repository string, name string, version string) error }
DesiredComponentChecker represents standard interface for checking component version
type DesiredComponentController ¶
type DesiredComponentController interface { }
type HTTPHeader ¶
type HTTPHeader string
type ImageMissingReporter ¶ added in v1.4.1
type ImageMissingReporter struct { TeamName string `json:"teamName,omitempty"` ComponentName string `json:"componentName,omitempty"` Envs map[string]string s2hv1beta1.Image SamsahaiConfig }
ImageMissingReporter manages image missing report
func NewImageMissingReporter ¶ added in v1.4.1
func NewImageMissingReporter(image s2hv1beta1.Image, s2hConfig SamsahaiConfig, teamName, compName string) *ImageMissingReporter
NewImageMissingReporter creates image missing reporter object
type IssueType ¶
type IssueType string
IssueType represents an issue type of component upgrade failure
type MSTeamsCredential ¶ added in v1.3.0
type Plugin ¶
type Plugin interface { DesiredComponentChecker // GetComponentName returns component name when incoming webhook matched with plugin name. // Useful for converting incoming component name to matched with the internal one. GetComponentName(name string) string }
type PostNamespaceCreation ¶
type PostNamespaceCreation struct { // Namespace defines a creating namespace Namespace string `json:"namespace"` Team s2hv1beta1.Team `json:"team"` SamsahaiConfig }
PostNamespaceCreation represents a struct for running post namespace creation
type PullRequestConfig ¶ added in v1.7.0
type PullRequestConfig struct { // QueueConcurrences defines number of pull request queue concurrences QueueConcurrences int `json:"queueConcurrences" yaml:"queueConcurrences"` // MaxVerificationRetryCounts defines the maximum times of pull request has been verified MaxVerificationRetryCounts int `json:"maxVerificationRetryCounts" yaml:"maxVerificationRetryCounts"` // MaxPRTriggerRetryCounts defines the maximum times of pull request has been triggered MaxTriggerRetryCounts int `json:"maxTriggerRetryCounts" yaml:"maxTriggerRetryCounts"` // TriggerPollingTime defines a waiting duration time to re-check the pull request image in the registry TriggerPollingTime metav1.Duration `json:"triggerPollingTime" yaml:"triggerPollingTime"` // MaxHistoryDays defines maximum days of PullRequestQueueHistory stored MaxHistoryDays int `json:"maxHistoryDays" yaml:"maxHistoryDays"` }
PullRequestConfig represents configuration of pull request
type PullRequestData ¶ added in v1.7.2
type PullRequestData struct { // PRNumber defines a pull request number PRNumber string }
PullRequestData defines a pull request data for template rendering
type PullRequestTriggerController ¶ added in v1.7.0
type PullRequestTriggerController interface { }
type PullRequestTriggerReporter ¶ added in v1.7.0
type PullRequestTriggerReporter struct { TeamName string `json:"teamName,omitempty"` ComponentName string `json:"componentName,omitempty"` PRNumber string `json:"prNumber,omitempty"` Result string `json:"result,omitempty"` Image *s2hv1beta1.Image `json:"image,omitempty"` s2hv1beta1.PullRequestTriggerStatus SamsahaiConfig }
PullRequestTriggerReporter manages pull request trigger report
func NewPullRequestTriggerResultReporter ¶ added in v1.7.0
func NewPullRequestTriggerResultReporter(status s2hv1beta1.PullRequestTriggerStatus, s2hConfig SamsahaiConfig, teamName, compName, prNumber, result string, image *s2hv1beta1.Image) *PullRequestTriggerReporter
NewPullRequestTriggerResultReporter creates pull request trigger result reporter object
type QueueController ¶
type QueueController interface { // Add adds Queue with priority list Add(q runtime.Object, priorityQueues []string) error // AddTop adds Queue to the top AddTop(q runtime.Object) error // First returns first component in Queue or current running Queue First(namespace string) (runtime.Object, error) // Remove removes Queue Remove(q runtime.Object) error // Size returns no of queues Size(namespace string) int // SetLastOrder sets queue order to the last SetLastOrder(obj runtime.Object) error // SetReverifyQueueAtFirst sets queue to reverify type SetReverifyQueueAtFirst(q runtime.Object) error // SetRetryQueue sets Queue to retry one time SetRetryQueue(q runtime.Object, noOfRetry int, nextAt time.Time) error // RemoveAllQueues removes all queues RemoveAllQueues(namespace string) error }
QueueController manages updating component queue through CRD
type Reporter ¶
type Reporter interface { // GetName returns type of reporter GetName() string // SendComponentUpgrade sends details of component upgrade SendComponentUpgrade(configCtrl ConfigController, comp *ComponentUpgradeReporter) error // SendPullRequestQueue sends details of pull request deployment queue SendPullRequestQueue(configCtrl ConfigController, comp *ComponentUpgradeReporter) error // SendActivePromotionStatus sends active promotion status SendActivePromotionStatus(configCtrl ConfigController, atpRpt *ActivePromotionReporter) error // SendImageMissing sends image missing SendImageMissing(configCtrl ConfigController, imageMissingRpt *ImageMissingReporter) error // SendPullRequestTriggerResult sends pull request trigger result information SendPullRequestTriggerResult(configCtrl ConfigController, prTriggerRpt *PullRequestTriggerReporter) error }
Reporter is the interface of reporter
type SamsahaiConfig ¶
type SamsahaiConfig struct { // ConfigDirPath defines a directory path of Samsahai configuration ConfigDirPath string `json:"-" yaml:"-"` // PluginsDir defines a plugins directory path PluginsDir string `json:"pluginsDir" yaml:"pluginsDir"` // SamsahaiImage defines a Samsahai image name and tag SamsahaiImage string `json:"s2hImage" yaml:"s2hImage"` // SamsahaiExternalURL defines a Samsahai external url SamsahaiExternalURL string `json:"s2hExternalURL" yaml:"s2hExternalURL"` // TeamcityURL defines a Teamcity url TeamcityURL string `json:"teamcityURL" yaml:"teamcityURL"` // ClusterDomain defines a cluster domain name ClusterDomain string `json:"clusterDomain" yaml:"clusterDomain"` // ActivePromotion defines an active promotion configuration ActivePromotion ActivePromotionConfig `json:"activePromotion,omitempty" yaml:"activePromotion,omitempty"` // PullRequest represents configuration of pull request PullRequest PullRequestConfig `json:"pullRequest,omitempty" yaml:"pullRequest,omitempty"` // PostNamespaceCreation defines commands executing after creating s2h namespace PostNamespaceCreation *struct { s2hv1beta1.CommandAndArgs } `json:"postNamespaceCreation,omitempty" yaml:"postNamespaceCreation,omitempty"` // StagingEnvs defines environment variables of staging controller StagingEnvs map[string]string `json:"stagingEnvs,omitempty" yaml:"stagingEnvs,omitempty"` SamsahaiURL string `json:"-" yaml:"-"` SamsahaiCredential SamsahaiCredential `json:"-" yaml:"-"` }
SamsahaiConfig represents configuration of Samsahai itself
type SamsahaiController ¶
type SamsahaiController interface { s2hrpc.RPC http.Handler PathPrefix() string // Start runs internal worker Start(stop <-chan struct{}) // QueueLen returns no. of internal queue QueueLen() int // GetTeam returns Team CRD GetTeam(teamName string, teamComp *s2hv1beta1.Team) error // GetConfigController returns samsahai configuration from config crd GetConfigController() ConfigController // GetPlugins returns samsahai plugins GetPlugins() map[string]Plugin // EnsureTeamTemplateChanged updates team if template changed EnsureTeamTemplateChanged(teamComp *s2hv1beta1.Team) error // LoadTeamSecret loads team secret from main namespace LoadTeamSecret(teamComp *s2hv1beta1.Team) error // CreateStagingEnvironment creates staging environment CreateStagingEnvironment(teamName, namespace string) error // CreatePreActiveEnvironment creates pre-active environment CreatePreActiveEnvironment(teamName, namespace string) error // PromoteActiveEnvironment switches environment from pre-active to active and stores current active components PromoteActiveEnvironment(teamComp *s2hv1beta1.Team, namespace, promotedBy string, comps map[string]s2hv1beta1.StableComponent) error // DestroyActiveEnvironment destroys active environment when active demotion is failure. DestroyActiveEnvironment(teamName, namespace string) error // DestroyPreActiveEnvironment destroys pre-active environment when active promotion is failure. DestroyPreActiveEnvironment(teamName, namespace string) error // DestroyPreviousActiveEnvironment destroys previous active environment when active promotion is success. DestroyPreviousActiveEnvironment(teamName, namespace string) error // SetPreviousActiveNamespace updates previous active namespace to team status SetPreviousActiveNamespace(teamComp *s2hv1beta1.Team, namespace string) error // SetPreActiveNamespace updates pre-active namespace to team status SetPreActiveNamespace(teamComp *s2hv1beta1.Team, namespace string) error // SetActiveNamespace updates active namespace to team status SetActiveNamespace(teamComp *s2hv1beta1.Team, namespace string) error // NotifyComponentChanged adds Component to queue for checking new version NotifyComponentChanged(name, repository, teamName string) // NotifyActivePromotionReport sends active promotion status report NotifyActivePromotionReport(atpRpt *ActivePromotionReporter) // TriggerPullRequestDeployment creates PullRequestTrigger crd object TriggerPullRequestDeployment(teamName, component, tag, prNumber string) error // GetConnections returns Services in NodePort type and Ingresses that exist in the namespace GetConnections(namespace string) (map[string][]Connection, error) // GetTeams returns list of teams in Samsahai GetTeams() (*s2hv1beta1.TeamList, error) // GetQueueHistories returns QueueHistoryList of the namespace GetQueueHistories(namespace string) (*s2hv1beta1.QueueHistoryList, error) // GetQueueHistory returns Queue by name and namespace GetQueueHistory(name, namespace string) (*s2hv1beta1.QueueHistory, error) // GetQueues returns QueueList of the namespace GetQueues(namespace string) (*s2hv1beta1.QueueList, error) // GetPullRequestQueueHistories returns PullRequestQueueHistoryList of the namespace GetPullRequestQueueHistories(namespace string) (*s2hv1beta1.PullRequestQueueHistoryList, error) // GetQueueHistory returns PullRequestQueue by name and namespace GetPullRequestQueueHistory(name, namespace string) (*s2hv1beta1.PullRequestQueueHistory, error) // GetQueues returns PullRequestQueueList of the namespace GetPullRequestQueues(namespace string) (*s2hv1beta1.PullRequestQueueList, error) // GetStableValues returns Stable Values of parent component in team GetStableValues(team *s2hv1beta1.Team, comp *s2hv1beta1.Component) (s2hv1beta1.ComponentValues, error) // GetActivePromotions returns ActivePromotionList by labels GetActivePromotions() (*s2hv1beta1.ActivePromotionList, error) // GetActivePromotion returns ActivePromotion by name GetActivePromotion(name string) (v *s2hv1beta1.ActivePromotion, err error) // GetActivePromotionHistories returns ActivePromotionList by labels GetActivePromotionHistories(selectors map[string]string) (*s2hv1beta1.ActivePromotionHistoryList, error) // GetActivePromotionHistory returns ActivePromotion by name GetActivePromotionHistory(name string) (*s2hv1beta1.ActivePromotionHistory, error) }
SamsahaiController
type SamsahaiCredential ¶
type SamsahaiCredential struct { InternalAuthToken string SlackToken string MSTeams MSTeamsCredential TeamcityUsername string TeamcityPassword string }
type SortableVersion ¶
type SortableVersion []string
func (SortableVersion) Len ¶
func (v SortableVersion) Len() int
func (SortableVersion) Less ¶
func (v SortableVersion) Less(i, j int) bool
func (SortableVersion) Swap ¶
func (v SortableVersion) Swap(i, j int)
type StableComponentController ¶
type StableComponentController interface { }
type StagingConfig ¶
type StagingConfig struct { // MaxHistoryDays defines maximum days of QueueHistory stored MaxHistoryDays int `json:"maxHistoryDays" yaml:"maxHistoryDays"` }
StagingConfig represents configuration of Staging
type StagingController ¶
type StagingController interface { // should implement RPC stagingrpc.RPC // should be able to serve http http.Handler // Start runs internal worker Start(stop <-chan struct{}) // IsBusy returns true if controller still processing queue IsBusy() bool // LoadTestRunner loads single test runner to controller LoadTestRunner(runner StagingTestRunner) // LoadDeployEngine loads single deploy engine to controller LoadDeployEngine(engine DeployEngine) }
type StagingTestRunner ¶
type StagingTestRunner interface { // GetName returns type of test runner GetName() string // Trigger makes http request to run the test build Trigger(testConfig *v1beta1.ConfigTestRunner, currentQueue *v1beta1.Queue) error // GetResult makes http request to get result of test build [FAILURE/SUCCESS/UNKNOWN] // It returns bool results of is build success and is build finished GetResult(testConfig *v1beta1.ConfigTestRunner, currentQueue *v1beta1.Queue) ( isResultSuccess bool, isBuildFinished bool, err error) }
type StatusType ¶
type StatusType string
StatusType represents an active promotion type
const ( StatusSuccess StatusType = "Success" StatusFailure StatusType = "Failure" )
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
pullrequest
|
|
reporter
|
|
third_party
|
|
protostruct
Package protostruct supports operations on the protocol buffer Struct message.
|
Package protostruct supports operations on the protocol buffer Struct message. |