-
Notifications
You must be signed in to change notification settings - Fork 229
/
priority.go
75 lines (61 loc) · 1.82 KB
/
priority.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
// Copyright (c) Alex Ellis 2017. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
package commands
import (
"fmt"
"strings"
)
const (
openFaaSURLEnvironment = "OPENFAAS_URL"
templateURLEnvironment = "OPENFAAS_TEMPLATE_URL"
templateStoreURLEnvironment = "OPENFAAS_TEMPLATE_STORE_URL"
defaultFunctionNamespace = ""
)
func getGatewayURL(argumentURL, defaultURL, yamlURL, environmentURL string) string {
var gatewayURL string
if len(argumentURL) > 0 && argumentURL != defaultURL {
gatewayURL = argumentURL
} else if len(yamlURL) > 0 && yamlURL != defaultURL {
gatewayURL = yamlURL
} else if len(environmentURL) > 0 {
gatewayURL = environmentURL
} else {
gatewayURL = defaultURL
}
gatewayURL = strings.ToLower(strings.TrimRight(gatewayURL, "/"))
if !strings.HasPrefix(gatewayURL, "http") {
gatewayURL = fmt.Sprintf("http://%s", gatewayURL)
}
return gatewayURL
}
func getTemplateURL(argumentURL, environmentURL, defaultURL string) string {
var templateURL string
if len(argumentURL) > 0 && argumentURL != defaultURL {
templateURL = argumentURL
} else if len(environmentURL) > 0 {
templateURL = environmentURL
} else {
templateURL = defaultURL
}
return templateURL
}
func getTemplateStoreURL(argumentURL, environmentURL, defaultURL string) string {
if argumentURL != defaultURL {
return argumentURL
} else if len(environmentURL) > 0 {
return environmentURL
} else {
return defaultURL
}
}
func getNamespace(flagNamespace, stackNamespace string) string {
// If the namespace flag is passed use it
if len(flagNamespace) > 0 {
return flagNamespace
}
// https://github.com/openfaas/faas-cli/issues/742#issuecomment-625746405
if len(stackNamespace) > 0 {
return stackNamespace
}
return defaultFunctionNamespace
}