forked from goharbor/harbor-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.go
51 lines (39 loc) · 1.32 KB
/
application.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
package application
import (
"context"
"k8s.io/apimachinery/pkg/runtime/schema"
)
var (
appNameContext = "app-name"
appVersionContext = "app-version"
appGitCommitContext = "app-git-commit"
appDeletableResources = "app-deletable-resources"
)
func GetName(ctx context.Context) string {
return ctx.Value(&appNameContext).(string)
}
func SetName(ctx *context.Context, name string) {
*ctx = context.WithValue(*ctx, &appNameContext, name)
}
func GetVersion(ctx context.Context) string {
return ctx.Value(&appVersionContext).(string)
}
func SetVersion(ctx *context.Context, version string) {
*ctx = context.WithValue(*ctx, &appVersionContext, version)
}
func GetGitCommit(ctx context.Context) string {
return ctx.Value(&appGitCommitContext).(string)
}
func SetGitCommit(ctx *context.Context, gitCommit string) {
*ctx = context.WithValue(*ctx, &appGitCommitContext, gitCommit)
}
func GetDeletableResources(ctx context.Context) map[schema.GroupVersionKind]struct{} {
deletableResources := ctx.Value(&appDeletableResources)
if deletableResources == nil {
return nil
}
return deletableResources.(map[schema.GroupVersionKind]struct{})
}
func SetDeletableResources(ctx *context.Context, deletableResources map[schema.GroupVersionKind]struct{}) {
*ctx = context.WithValue(*ctx, &appDeletableResources, deletableResources)
}