feat: implement autoscaling-auth:report

This commit is contained in:
Jose Diaz-Gonzalez committed 2024-03-06 03:39:11 -05:00
1 parent 5b0bc0b132
commit 6b74cd1d6b
5 files changed
+76 -9

No files matched your search

+34
View File
@@ -1,6 +1,9 @@
package scheduler_k3s
import (
"fmt"
"strings"
"github.com/dokku/dokku/plugins/common"
)
@@ -45,6 +48,37 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
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)
}