Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion api/helm-app/HelmAppRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common"
"github.com/devtron-labs/devtron/pkg/attributes"
"github.com/devtron-labs/devtron/pkg/cluster"
serverEnvConfig "github.com/devtron-labs/devtron/pkg/server/config"
"github.com/devtron-labs/devtron/pkg/user"
"github.com/devtron-labs/devtron/pkg/user/casbin"
"github.com/devtron-labs/devtron/util/k8sObjectsUtil"
Expand Down Expand Up @@ -48,12 +49,13 @@ type HelmAppRestHandlerImpl struct {
appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService
userAuthService user.UserService
attributesService attributes.AttributesService
serverEnvConfig *serverEnvConfig.ServerEnvConfig
}

func NewHelmAppRestHandlerImpl(logger *zap.SugaredLogger,
helmAppService HelmAppService, enforcer casbin.Enforcer,
clusterService cluster.ClusterService, enforcerUtil rbac.EnforcerUtilHelm, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService,
userAuthService user.UserService, attributesService attributes.AttributesService) *HelmAppRestHandlerImpl {
userAuthService user.UserService, attributesService attributes.AttributesService, serverEnvConfig *serverEnvConfig.ServerEnvConfig) *HelmAppRestHandlerImpl {
return &HelmAppRestHandlerImpl{
logger: logger,
helmAppService: helmAppService,
Expand All @@ -63,6 +65,7 @@ func NewHelmAppRestHandlerImpl(logger *zap.SugaredLogger,
appStoreDeploymentCommonService: appStoreDeploymentCommonService,
userAuthService: userAuthService,
attributesService: attributesService,
serverEnvConfig: serverEnvConfig,
}
}

Expand Down Expand Up @@ -276,6 +279,15 @@ func (handler *HelmAppRestHandlerImpl) DeleteApplication(w http.ResponseWriter,
return
}
//RBAC enforcer Ends

// validate if the devtron-operator helm release, block that for deletion
if appIdentifier.ReleaseName == handler.serverEnvConfig.DevtronHelmReleaseName &&
appIdentifier.Namespace == handler.serverEnvConfig.DevtronHelmReleaseNamespace &&
appIdentifier.ClusterId == DEFAULT_CLUSTER_ID {
common.WriteJsonResp(w, errors.New("cannot delete this default helm app"), nil, http.StatusForbidden)
return
}

res, err := handler.helmAppService.DeleteApplication(context.Background(), appIdentifier)
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down
1 change: 1 addition & 0 deletions api/helm-app/HelmAppService.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
)

const DEFAULT_CLUSTER = "default_cluster"
const DEFAULT_CLUSTER_ID = 1

type HelmAppService interface {
ListHelmApplications(clusterIds []int, w http.ResponseWriter, token string, helmAuth func(token string, object string) bool)
Expand Down
5 changes: 2 additions & 3 deletions cmd/external-app/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.