Skip to content

Commit 0415cee

Browse files
committed
Merge branch 'main' into plugin-creation-oss
2 parents 4060ef5 + 26784d5 commit 0415cee

File tree

93 files changed

+4464
-1679
lines changed

Some content is hidden

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

93 files changed

+4464
-1679
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

+2-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"
@@ -200,7 +201,7 @@ func InitializeApp() (*App, error) {
200201
build.BuildWireSet,
201202
deployment2.DeploymentWireSet,
202203
argoApplication.ArgoApplicationWireSet,
203-
204+
fluxApplication.FluxApplicationWireSet,
204205
eventProcessor.EventProcessorWireSet,
205206
workflow3.WorkflowWireSet,
206207

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)