-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnforcerUtilHelm.go
33 lines (29 loc) · 1 KB
/
EnforcerUtilHelm.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
package rbac
import (
"fmt"
"github.com/devtron-labs/template-cron-job/pkg/cluster/repository"
"github.com/devtron-labs/template-cron-job/pkg/team"
"go.uber.org/zap"
"strings"
)
type EnforcerUtilHelm interface {
GetHelmObjectByClusterId(clusterId int, namespace string, appName string) string
}
type EnforcerUtilHelmImpl struct {
logger *zap.SugaredLogger
clusterRepository repository.ClusterRepository
}
func NewEnforcerUtilHelmImpl(logger *zap.SugaredLogger,
clusterRepository repository.ClusterRepository) *EnforcerUtilHelmImpl {
return &EnforcerUtilHelmImpl{
logger: logger,
clusterRepository: clusterRepository,
}
}
func (impl EnforcerUtilHelmImpl) GetHelmObjectByClusterId(clusterId int, namespace string, appName string) string {
cluster, err := impl.clusterRepository.FindById(clusterId)
if err != nil {
return fmt.Sprintf("%s/%s/%s", "", "", "")
}
return fmt.Sprintf("%s/%s__%s/%s", team.UNASSIGNED_PROJECT, cluster.ClusterName, namespace, strings.ToLower(appName))
}