/
report.go
163 lines (132 loc) · 5.34 KB
/
report.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package scheduler_k3s
import (
"fmt"
"strings"
"github.com/dokku/dokku/plugins/common"
)
// ReportSingleApp is an internal function that displays the scheduler-k3s report for one or more apps
func ReportSingleApp(appName string, format string, infoFlag string) error {
if err := common.VerifyAppName(appName); err != nil {
return err
}
flags := map[string]common.ReportFunc{
"--scheduler-k3s-computed-deploy-timeout": reportComputedDeployTimeout,
"--scheduler-k3s-deploy-timeout": reportDeployTimeout,
"--scheduler-k3s-global-deploy-timeout": reportGlobalDeployTimeout,
"--scheduler-k3s-computed-image-pull-secrets": reportComputedImagePullSecrets,
"--scheduler-k3s-image-pull-secrets": reportImagePullSecrets,
"--scheduler-k3s-global-image-pull-secrets": reportGlobalImagePullSecrets,
"--scheduler-k3s-global-kubeconfig-path": reportGlobalKubeconfigPath,
"--scheduler-k3s-global-kube-context": reportGlobalKubeContext,
"--scheduler-k3s-computed-letsencrypt-server": reportComputedLetsencryptServer,
"--scheduler-k3s-letsencrypt-server": reportLetsencryptServer,
"--scheduler-k3s-global-letsencrypt-server": reportGlobalLetsencryptServer,
"--scheduler-k3s-global-ingress-class": reportGlobalIngressClass,
"--scheduler-k3s-global-letsencrypt-email-prod": reportGlobalLetsencryptEmailProd,
"--scheduler-k3s-global-letsencrypt-email-stag": reportGlobalLetsencryptEmailStag,
"--scheduler-k3s-computed-namespace": reportComputedNamespace,
"--scheduler-k3s-namespace": reportNamespace,
"--scheduler-k3s-global-namespace": reportGlobalNamespace,
"--scheduler-k3s-global-network-interface": reportGlobalNetworkInterface,
"--scheduler-k3s-computed-rollback-on-failure": reportComputedRollbackOnFailure,
"--scheduler-k3s-rollback-on-failure": reportRollbackOnFailure,
"--scheduler-k3s-global-rollback-on-failure": reportGlobalRollbackOnFailure,
}
flagKeys := []string{}
for flagKey := range flags {
flagKeys = append(flagKeys, flagKey)
}
trimPrefix := false
uppercaseFirstCharacter := true
infoFlags := common.CollectReport(appName, infoFlag, flags)
return common.ReportSingleApp("scheduler-k3s", appName, infoFlag, infoFlags, flagKeys, format, trimPrefix, uppercaseFirstCharacter)
}
// ReportAutoscalingAuthSingleApp is an internal function that displays the scheduler-k3s autoscaling-auth report for one app
func ReportAutoscalingAuthSingleApp(appName string, format string, includeMetadata bool) error {
properties, err := common.PropertyGetAllByPrefix("scheduler-k3s", appName, TriggerAuthPropertyPrefix)
if err != nil {
return fmt.Errorf("Unable to get property list: %w", err)
}
infoFlags := map[string]string{}
for key, value := range properties {
metadataKey := strings.TrimPrefix(key, TriggerAuthPropertyPrefix)
authType := strings.SplitN(metadataKey, ".", 2)[0]
if authType == "" {
continue
}
infoFlags[authType] = "configured"
if includeMetadata {
infoFlags[strings.ReplaceAll(metadataKey, ".", "-")] = value
}
}
flagKeys := []string{}
for flagKey := range infoFlags {
flagKeys = append(flagKeys, flagKey)
}
trimPrefix := false
uppercaseFirstCharacter := true
return common.ReportSingleApp("scheduler-k3s", appName, "", infoFlags, flagKeys, format, trimPrefix, uppercaseFirstCharacter)
}
func reportComputedDeployTimeout(appName string) string {
return getComputedDeployTimeout(appName)
}
func reportDeployTimeout(appName string) string {
return getDeployTimeout(appName)
}
func reportGlobalDeployTimeout(appName string) string {
return getGlobalDeployTimeout()
}
func reportComputedImagePullSecrets(appName string) string {
return getComputedImagePullSecrets(appName)
}
func reportImagePullSecrets(appName string) string {
return getImagePullSecrets(appName)
}
func reportGlobalImagePullSecrets(appName string) string {
return getGlobalImagePullSecrets()
}
func reportGlobalIngressClass(appName string) string {
return getGlobalIngressClass()
}
func reportGlobalKubeconfigPath(appName string) string {
return getKubeconfigPath()
}
func reportGlobalKubeContext(appName string) string {
return getKubeContext()
}
func reportComputedLetsencryptServer(appName string) string {
return getComputedLetsencryptServer(appName)
}
func reportLetsencryptServer(appName string) string {
return getLetsencryptServer(appName)
}
func reportGlobalLetsencryptServer(appName string) string {
return getGlobalLetsencryptServer()
}
func reportGlobalLetsencryptEmailProd(appName string) string {
return getGlobalLetsencryptEmailProd()
}
func reportGlobalLetsencryptEmailStag(appName string) string {
return getGlobalLetsencryptEmailStag()
}
func reportComputedNamespace(appName string) string {
return getComputedNamespace(appName)
}
func reportNamespace(appName string) string {
return getNamespace(appName)
}
func reportGlobalNamespace(appName string) string {
return getGlobalNamespace()
}
func reportGlobalNetworkInterface(appName string) string {
return getGlobalNetworkInterface()
}
func reportComputedRollbackOnFailure(appName string) string {
return getComputedRollbackOnFailure(appName)
}
func reportRollbackOnFailure(appName string) string {
return getRollbackOnFailure(appName)
}
func reportGlobalRollbackOnFailure(appName string) string {
return getGlobalRollbackOnFailure()
}