refactor: use const for prefix
This commit is contained in:
@@ -536,14 +536,14 @@ func getAutoscaling(input GetAutoscalingInput) (ProcessAutoscaling, error) {
|
||||
|
||||
// getKedaValues retrieves keda values for a given app and process type
|
||||
func getKedaValues(appName string) (GlobalKedaValues, error) {
|
||||
properties, err := common.PropertyGetAllByPrefix("scheduler-k3s", appName, "trigger-auth-")
|
||||
properties, err := common.PropertyGetAllByPrefix("scheduler-k3s", appName, TriggerAuthPropertyPrefix)
|
||||
if err != nil {
|
||||
return GlobalKedaValues{}, fmt.Errorf("Error getting trigger-auth properties: %w", err)
|
||||
}
|
||||
|
||||
auths := map[string]KedaAuthentication{}
|
||||
for key, value := range properties {
|
||||
parts := strings.SplitN(strings.TrimPrefix(key, "trigger-auth-"), ":", 2)
|
||||
parts := strings.SplitN(strings.TrimPrefix(key, TriggerAuthPropertyPrefix), ".", 2)
|
||||
if len(parts) != 2 {
|
||||
return GlobalKedaValues{}, fmt.Errorf("Invalid trigger-auth property format: %s", key)
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ const DefaultIngressClass = "traefik"
|
||||
const GlobalProcessType = "--global"
|
||||
const KubeConfigPath = "/etc/rancher/k3s/k3s.yaml"
|
||||
const DefaultKubeContext = ""
|
||||
const TriggerAuthPropertyPrefix = "trigger-auth."
|
||||
|
||||
var (
|
||||
runtimeScheme = runtime.NewScheme()
|
||||
|
||||
@@ -65,7 +65,7 @@ func CommandAutoscalingAuthSet(appName string, trigger string, metadata map[stri
|
||||
}
|
||||
|
||||
if len(metadata) == 0 {
|
||||
properties, err := common.PropertyGetAllByPrefix("scheduler-k3s", appName, fmt.Sprintf("trigger-auth.%s.", trigger))
|
||||
properties, err := common.PropertyGetAllByPrefix("scheduler-k3s", appName, fmt.Sprintf("%s%s.", TriggerAuthPropertyPrefix, trigger))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to get property list: %w", err)
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func CommandAutoscalingAuthSet(appName string, trigger string, metadata map[stri
|
||||
}
|
||||
|
||||
for key, value := range metadata {
|
||||
if err := common.PropertyWrite("scheduler-k3s", appName, fmt.Sprintf("trigger-auth.%s.%s", trigger, key), value); err != nil {
|
||||
if err := common.PropertyWrite("scheduler-k3s", appName, fmt.Sprintf("%s%s.%s", TriggerAuthPropertyPrefix, trigger, key), value); err != nil {
|
||||
return fmt.Errorf("Unable to set property: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user