-
Notifications
You must be signed in to change notification settings - Fork 11
/
deploy.go
57 lines (42 loc) · 1.52 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
package internal
import (
"time"
"helm.sh/helm/v3/pkg/release"
"github.com/agoda-com/samsahai/api/v1beta1"
)
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
}
const (
MaxReleaseNameLength = 53
)
// GenReleaseName returns the release name for deploying components
func GenReleaseName(namespace, compName string) string {
refName := namespace + "-" + compName
if len(refName) > MaxReleaseNameLength {
// component name is more important than team name
return refName[len(refName)-MaxReleaseNameLength:]
}
return refName
}