-
Notifications
You must be signed in to change notification settings - Fork 11
/
deploy.go
60 lines (44 loc) · 1.66 KB
/
deploy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package internal
import (
"time"
"helm.sh/helm/v3/pkg/release"
"sigs.k8s.io/controller-runtime/pkg/client"
s2hv1 "github.com/agoda-com/samsahai/api/v1"
)
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 *s2hv1.Component, parentComp *s2hv1.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
// GetLabelSelectors 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)
// WaitForPreHookReady waits until all pre-hook pods are completed
WaitForPreHookReady(k8sClient client.Client, refName string) (bool, error)
// IsMocked uses for skip some functions due to mock deploy
//
// Skipped function: WaitForComponentsCleaned
IsMocked() bool
}
const (
MaxReleaseNameLength = 45
)
// GenReleaseName returns the release name for deploying components
func GenReleaseName(compName string) string {
if len(compName) > MaxReleaseNameLength {
// component name is more important than team name
return compName[len(compName)-MaxReleaseNameLength:]
}
return compName
}