-
Notifications
You must be signed in to change notification settings - Fork 523
/
Copy pathCiCdUtil.go
45 lines (41 loc) · 1.48 KB
/
CiCdUtil.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
package util
import (
"github.com/devtron-labs/devtron/pkg/bean"
"github.com/devtron-labs/devtron/pkg/bean/common"
"github.com/devtron-labs/devtron/util"
"github.com/devtron-labs/devtron/util/urlUtil"
)
func IsValidUrlSubPath(subPath string) bool {
url := "http://127.0.0.1:8080/" + subPath
return urlUtil.IsValidUrl(url)
}
// in oss, only WorkflowCacheConfigInherit is supported
func GetWorkflowCacheConfig(WorkflowCacheConfig common.WorkflowCacheConfigType, globalValue bool) bean.WorkflowCacheConfig {
//explicitly return inherit here to handle empty case
return bean.WorkflowCacheConfig{
Type: common.WorkflowCacheConfigInherit,
Value: !globalValue,
GlobalValue: !globalValue,
}
}
// in oss, only WorkflowCacheConfigInherit is supported
func GetWorkflowCacheConfigWithBackwardCompatibility(WorkflowCacheConfig common.WorkflowCacheConfigType, WorkflowCacheConfigEnv string, globalValue bool, oldGlobalValue bool) (bean.WorkflowCacheConfig, error) {
isEmptyJson, err := util.IsEmptyJSON([]byte(WorkflowCacheConfigEnv))
if err != nil {
return bean.WorkflowCacheConfig{}, err
}
if isEmptyJson {
//this means new global flag is not configured
return bean.WorkflowCacheConfig{
Type: common.WorkflowCacheConfigInherit,
Value: !oldGlobalValue,
GlobalValue: !oldGlobalValue,
}, nil
} else {
return bean.WorkflowCacheConfig{
Type: common.WorkflowCacheConfigInherit,
Value: !globalValue,
GlobalValue: !globalValue,
}, nil
}
}