Skip to content

Commit 16e8054

Browse files
Merge branch 'main' into vulnerability-scanning
2 parents 0125970 + 47843d9 commit 16e8054

File tree

1,174 files changed

+59811
-124037
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,174 files changed

+59811
-124037
lines changed

.gitbook.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ redirects:
1616
setup/upgrade/devtron-upgrade-0.2.x-0.3.x: getting-started/upgrade/devtron-upgrade-0.2.x-0.3.x
1717
setup/global-configurations: user-guide/global-configurations/README.md
1818
setup/global-configurations/gitops: user-guide/global-configurations/gitops.md
19-
setup/global-configurations/custom-charts: user-guide/global-configurations/custom-charts.md
19+
setup/global-configurations/custom-charts: user-guide/global-configurations/deployment-charts.md
2020
setup/global-configurations/user-access: user-guide/global-configurations/authorization/user-access.md
2121
setup/global-configurations/external-links: user-guide/global-configurations/external-links.md
2222
setup/global-configurations/projects: user-guide/global-configurations/projects.md
@@ -109,7 +109,7 @@ redirects:
109109
getting-started/global-configurations/filter-condition: user-guide/global-configurations/filter-condition.md
110110
getting-started/global-configurations/build-infra: user-guide/global-configurations/build-infra.md
111111
getting-started/global-configurations/gitops: user-guide/global-configurations/gitops.md
112-
getting-started/global-configurations/custom-charts: user-guide/global-configurations/custom-charts.md
112+
getting-started/global-configurations/custom-charts: user-guide/global-configurations/deployment-charts.md
113113
getting-started/global-configurations/external-links: user-guide/global-configurations/external-links.md
114114
getting-started/global-configurations/projects: user-guide/global-configurations/projects.md
115115
getting-started/global-configurations/manage-notification: user-guide/global-configurations/manage-notification.md
@@ -127,4 +127,5 @@ redirects:
127127
user-guide/clusters: user-guide/resource-browser.md
128128
usage/clusters: user-guide/resource-browser.md
129129
global-configurations/authorization/sso-login/okta: user-guide/global-configurations/authorization/sso/okta.md
130-
usage/applications/creating-application/ci-pipeline/ci-build-pre-post-plugins: user-guide/creating-application/workflow/ci-build-pre-post-plugins.md
130+
usage/applications/creating-application/ci-pipeline/ci-build-pre-post-plugins: user-guide/creating-application/workflow/ci-build-pre-post-plugins.md
131+
global-configurations/custom-charts: user-guide/global-configurations/deployment-charts.md

Wire.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"github.com/devtron-labs/devtron/api/deployment"
4242
"github.com/devtron-labs/devtron/api/devtronResource"
4343
"github.com/devtron-labs/devtron/api/externalLink"
44+
fluxApplication "github.com/devtron-labs/devtron/api/fluxApplication"
4445
client "github.com/devtron-labs/devtron/api/helm-app"
4546
"github.com/devtron-labs/devtron/api/infraConfig"
4647
"github.com/devtron-labs/devtron/api/k8s"
@@ -115,6 +116,7 @@ import (
115116
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deploymentTypeChange"
116117
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/resource"
117118
"github.com/devtron-labs/devtron/pkg/appWorkflow"
119+
"github.com/devtron-labs/devtron/pkg/argoRepositoryCreds"
118120
"github.com/devtron-labs/devtron/pkg/asyncProvider"
119121
"github.com/devtron-labs/devtron/pkg/attributes"
120122
"github.com/devtron-labs/devtron/pkg/build"
@@ -123,6 +125,7 @@ import (
123125
"github.com/devtron-labs/devtron/pkg/chart/gitOpsConfig"
124126
chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository"
125127
"github.com/devtron-labs/devtron/pkg/commonService"
128+
"github.com/devtron-labs/devtron/pkg/configDiff"
126129
delete2 "github.com/devtron-labs/devtron/pkg/delete"
127130
deployment2 "github.com/devtron-labs/devtron/pkg/deployment"
128131
"github.com/devtron-labs/devtron/pkg/deployment/common"
@@ -175,6 +178,7 @@ func InitializeApp() (*App, error) {
175178
externalLink.ExternalLinkWireSet,
176179
team.TeamsWireSet,
177180
AuthWireSet,
181+
util4.GetRuntimeConfig,
178182
util4.NewK8sUtil,
179183
wire.Bind(new(util4.K8sService), new(*util4.K8sServiceImpl)),
180184
user.UserWireSet,
@@ -198,7 +202,7 @@ func InitializeApp() (*App, error) {
198202
build.BuildWireSet,
199203
deployment2.DeploymentWireSet,
200204
argoApplication.ArgoApplicationWireSet,
201-
205+
fluxApplication.FluxApplicationWireSet,
202206
eventProcessor.EventProcessorWireSet,
203207
workflow3.WorkflowWireSet,
204208

@@ -708,6 +712,13 @@ func InitializeApp() (*App, error) {
708712
scopedVariable.NewScopedVariableRestHandlerImpl,
709713
wire.Bind(new(scopedVariable.ScopedVariableRestHandler), new(*scopedVariable.ScopedVariableRestHandlerImpl)),
710714

715+
router.NewDeploymentConfigurationRouter,
716+
wire.Bind(new(router.DeploymentConfigurationRouter), new(*router.DeploymentConfigurationRouterImpl)),
717+
restHandler.NewDeploymentConfigurationRestHandlerImpl,
718+
wire.Bind(new(restHandler.DeploymentConfigurationRestHandler), new(*restHandler.DeploymentConfigurationRestHandlerImpl)),
719+
configDiff.NewDeploymentConfigurationServiceImpl,
720+
wire.Bind(new(configDiff.DeploymentConfigurationService), new(*configDiff.DeploymentConfigurationServiceImpl)),
721+
711722
router.NewTelemetryRouterImpl,
712723
wire.Bind(new(router.TelemetryRouter), new(*router.TelemetryRouterImpl)),
713724
restHandler.NewTelemetryRestHandlerImpl,
@@ -989,6 +1000,9 @@ func InitializeApp() (*App, error) {
9891000
common.NewDeploymentConfigServiceImpl,
9901001
wire.Bind(new(common.DeploymentConfigService), new(*common.DeploymentConfigServiceImpl)),
9911002

1003+
argoRepositoryCreds.NewRepositorySecret,
1004+
wire.Bind(new(argoRepositoryCreds.RepositorySecret), new(*argoRepositoryCreds.RepositorySecretImpl)),
1005+
9921006
repocreds.NewServiceClientImpl,
9931007
wire.Bind(new(repocreds.ServiceClient), new(*repocreds.ServiceClientImpl)),
9941008
)

api/bean/AppView.go

+3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ type AppEnvironmentContainer struct {
144144
type DeploymentDetailContainer struct {
145145
InstalledAppId int `json:"installedAppId,omitempty"`
146146
AppId int `json:"appId,omitempty"`
147+
PcoId int `json:"pcoId"`
147148
CdPipelineId int `json:"cdPipelineId,omitempty"`
148149
TriggerType string `json:"triggerType,omitempty"`
149150
ParentEnvironmentName string `json:"parentEnvironmentName"`
@@ -183,6 +184,8 @@ type DeploymentDetailContainer struct {
183184
HelmPackageName string `json:"helmPackageName"`
184185
HelmReleaseInstallStatus string `json:"-"`
185186
DeploymentConfig *bean.DeploymentConfig `json:"-"`
187+
IsPipelineTriggered bool `json:"isPipelineTriggered"`
188+
ReleaseMode string `json:"releaseMode"`
186189
}
187190

188191
type AppDetailContainer struct {

api/bean/ConfigMapAndSecret.go

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type ConfigMapJson struct {
3232
type ConfigSecretRootJson struct {
3333
ConfigSecretJson ConfigSecretJson `json:"ConfigSecrets"`
3434
}
35+
3536
type ConfigSecretJson struct {
3637
Enabled bool `json:"enabled"`
3738
Secrets []*ConfigSecretMap `json:"secrets"`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package fluxApplication
2+
3+
import (
4+
"errors"
5+
"github.com/devtron-labs/devtron/api/restHandler/common"
6+
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
7+
clientErrors "github.com/devtron-labs/devtron/pkg/errors"
8+
"github.com/devtron-labs/devtron/pkg/fluxApplication"
9+
"github.com/gorilla/mux"
10+
"go.uber.org/zap"
11+
"net/http"
12+
)
13+
14+
type FluxApplicationRestHandler interface {
15+
ListFluxApplications(w http.ResponseWriter, r *http.Request)
16+
GetApplicationDetail(w http.ResponseWriter, r *http.Request)
17+
}
18+
19+
type FluxApplicationRestHandlerImpl struct {
20+
fluxApplicationService fluxApplication.FluxApplicationService
21+
logger *zap.SugaredLogger
22+
enforcer casbin.Enforcer
23+
}
24+
25+
func NewFluxApplicationRestHandlerImpl(fluxApplicationService fluxApplication.FluxApplicationService,
26+
logger *zap.SugaredLogger, enforcer casbin.Enforcer) *FluxApplicationRestHandlerImpl {
27+
return &FluxApplicationRestHandlerImpl{
28+
fluxApplicationService: fluxApplicationService,
29+
logger: logger,
30+
enforcer: enforcer,
31+
}
32+
33+
}
34+
35+
func (handler *FluxApplicationRestHandlerImpl) ListFluxApplications(w http.ResponseWriter, r *http.Request) {
36+
37+
//handle super-admin RBAC
38+
token := r.Header.Get("token")
39+
if ok := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*"); !ok {
40+
common.WriteJsonResp(w, errors.New("unauthorized"), nil, http.StatusForbidden)
41+
return
42+
}
43+
v := r.URL.Query()
44+
clusterIdString := v.Get("clusterIds")
45+
var clusterIds []int
46+
var err error
47+
48+
//handling when the clusterIds string is empty ,it will not support the
49+
if len(clusterIdString) == 0 {
50+
handler.logger.Errorw("error in getting cluster ids", "error", err, "clusterIds", clusterIds)
51+
common.WriteJsonResp(w, errors.New("error in getting cluster ids"), nil, http.StatusBadRequest)
52+
return
53+
}
54+
clusterIds, err = common.ExtractIntArrayQueryParam(w, r, "clusterIds")
55+
if err != nil {
56+
handler.logger.Errorw("error in parsing cluster ids", "error", err, "clusterIds", clusterIds)
57+
return
58+
}
59+
handler.logger.Debugw("extracted ClusterIds successfully ", "clusterIds", clusterIds)
60+
handler.fluxApplicationService.ListFluxApplications(r.Context(), clusterIds, w)
61+
}
62+
63+
func (handler *FluxApplicationRestHandlerImpl) GetApplicationDetail(w http.ResponseWriter, r *http.Request) {
64+
vars := mux.Vars(r)
65+
appIdString := vars["appId"]
66+
appIdentifier, err := fluxApplication.DecodeFluxExternalAppId(appIdString)
67+
if err != nil {
68+
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
69+
return
70+
}
71+
if appIdentifier.IsKustomizeApp == true && appIdentifier.Name == "flux-system" && appIdentifier.Namespace == "flux-system" {
72+
73+
common.WriteJsonResp(w, errors.New("cannot proceed for the flux system root level "), nil, http.StatusBadRequest)
74+
return
75+
}
76+
77+
// handle super-admin RBAC
78+
token := r.Header.Get("token")
79+
if ok := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*"); !ok {
80+
common.WriteJsonResp(w, errors.New("unauthorized"), nil, http.StatusForbidden)
81+
return
82+
}
83+
84+
res, err := handler.fluxApplicationService.GetFluxAppDetail(r.Context(), appIdentifier)
85+
if err != nil {
86+
apiError := clientErrors.ConvertToApiError(err)
87+
if apiError != nil {
88+
err = apiError
89+
}
90+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
91+
return
92+
}
93+
common.WriteJsonResp(w, err, res, http.StatusOK)
94+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package fluxApplication
2+
3+
import (
4+
"github.com/gorilla/mux"
5+
)
6+
7+
type FluxApplicationRouter interface {
8+
InitFluxApplicationRouter(fluxApplicationRouter *mux.Router)
9+
}
10+
11+
type FluxApplicationRouterImpl struct {
12+
fluxApplicationRestHandler FluxApplicationRestHandler
13+
}
14+
15+
func NewFluxApplicationRouterImpl(fluxApplicationRestHandler FluxApplicationRestHandler) *FluxApplicationRouterImpl {
16+
return &FluxApplicationRouterImpl{
17+
fluxApplicationRestHandler: fluxApplicationRestHandler,
18+
}
19+
}
20+
21+
func (impl *FluxApplicationRouterImpl) InitFluxApplicationRouter(fluxApplicationRouter *mux.Router) {
22+
fluxApplicationRouter.Path("").
23+
Methods("GET").
24+
HandlerFunc(impl.fluxApplicationRestHandler.ListFluxApplications)
25+
fluxApplicationRouter.Path("/app").Queries("appId", "{appId}").
26+
HandlerFunc(impl.fluxApplicationRestHandler.GetApplicationDetail).Methods("GET")
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package fluxApplication
2+
3+
import (
4+
"github.com/devtron-labs/devtron/pkg/fluxApplication"
5+
"github.com/google/wire"
6+
)
7+
8+
var FluxApplicationWireSet = wire.NewSet(
9+
fluxApplication.NewFluxApplicationServiceImpl,
10+
wire.Bind(new(fluxApplication.FluxApplicationService), new(*fluxApplication.FluxApplicationServiceImpl)),
11+
12+
NewFluxApplicationRestHandlerImpl,
13+
wire.Bind(new(FluxApplicationRestHandler), new(*FluxApplicationRestHandlerImpl)),
14+
15+
NewFluxApplicationRouterImpl,
16+
wire.Bind(new(FluxApplicationRouter), new(*FluxApplicationRouterImpl)),
17+
)

0 commit comments

Comments
 (0)