Skip to content

Commit 15b2a4f

Browse files
committed
develop-merge
2 parents d5b9a1c + 839e287 commit 15b2a4f

File tree

323 files changed

+97198
-2441
lines changed

Some content is hidden

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

323 files changed

+97198
-2441
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ scripts/sql @prakarsh-dt @vikramdevtron @nishant-d @vivek-devtron
1111
scripts/utilities @prakarsh-dt @nishant-d @pawan-mehta-dt @vivek-devtron
1212

1313
#Github Specific
14-
.github/ @prakarsh-dt @nishant-d @pawan-mehta-dt @vikramdevtron @tayalrishabh96
14+
.github/ @prakarsh-dt @nishant-d @pawan-mehta-dt @vikramdevtron @tayalrishabh96 @pawan-59
15+
16+
#swagger api specs
17+
specs/ @prakarsh-dt @pawan-mehta-dt @pawan-59

.github/workflows/api-linter.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Lint API Specs
2+
on:
3+
pull_request:
4+
paths:
5+
- 'specs/swagger/**'
6+
permissions:
7+
contents: read
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
- name: Install Redocly CLI
19+
run: npm install -g @redocly/cli
20+
- name: Lint OpenAPI specification
21+
run: |
22+
cd specs/swagger
23+
echo "Linting OpenAPI specification..."
24+
redocly lint openapi.yaml
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GH_SYSTEMSDT_TOKEN }}

.github/workflows/build-docs.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: OpenAPI Build Documentation
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- 'specs/swagger/**'
8+
permissions:
9+
contents: write
10+
jobs:
11+
lint-and-build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
22+
- name: Install Redocly CLI
23+
run: npm install -g @redocly/cli
24+
25+
- name: Switch to gh-pages and copy OpenAPI source
26+
run: |
27+
git config --local user.email "[email protected]"
28+
git config --local user.name "GitHub Action"
29+
30+
mkdir tmp-api
31+
32+
cp specs/swagger/openapi.yaml tmp-api/
33+
34+
git checkout gh-pages
35+
36+
cp tmp-api/openapi.yaml specs/swagger/openapi.yaml
37+
38+
rm -rf /tmp-api
39+
40+
- name: Build OpenAPI documentation
41+
run: |
42+
43+
cd specs/swagger
44+
echo "Building OpenAPI documentation..."
45+
redocly build-docs openapi.yaml --output=openapi.html
46+
echo "Documentation built successfully!"
47+
48+
- name: Commit and push documentation
49+
run: |
50+
git config --local user.email "[email protected]"
51+
git config --local user.name "GitHub Action"
52+
53+
git add specs/swagger/openapi.html specs/swagger/openapi.yaml
54+
55+
if git diff --staged --quiet; then
56+
echo "No changes to commit"
57+
else
58+
git commit -m "Update OpenAPI documentation from main branch"
59+
git push origin gh-pages
60+
echo "Documentation pushed to gh-pages branch!"
61+
fi
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GH_SYSTEMSDT_TOKEN }}

Wire.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ import (
103103
app2 "github.com/devtron-labs/devtron/internal/sql/repository/app"
104104
appStatusRepo "github.com/devtron-labs/devtron/internal/sql/repository/appStatus"
105105
appWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow"
106-
"github.com/devtron-labs/devtron/internal/sql/repository/bulkUpdate"
107106
"github.com/devtron-labs/devtron/internal/sql/repository/chartConfig"
108107
dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry"
109108
"github.com/devtron-labs/devtron/internal/sql/repository/helper"
@@ -128,6 +127,7 @@ import (
128127
"github.com/devtron-labs/devtron/pkg/build"
129128
"github.com/devtron-labs/devtron/pkg/build/artifacts/imageTagging"
130129
pipeline6 "github.com/devtron-labs/devtron/pkg/build/pipeline"
130+
repository11 "github.com/devtron-labs/devtron/pkg/bulkAction/repository"
131131
"github.com/devtron-labs/devtron/pkg/bulkAction/service"
132132
"github.com/devtron-labs/devtron/pkg/chart"
133133
"github.com/devtron-labs/devtron/pkg/chart/gitOpsConfig"
@@ -268,8 +268,8 @@ func InitializeApp() (*App, error) {
268268
app.NewAppService,
269269
wire.Bind(new(app.AppService), new(*app.AppServiceImpl)),
270270

271-
bulkUpdate.NewBulkUpdateRepository,
272-
wire.Bind(new(bulkUpdate.BulkUpdateRepository), new(*bulkUpdate.BulkUpdateRepositoryImpl)),
271+
repository11.NewBulkEditRepository,
272+
wire.Bind(new(repository11.BulkEditRepository), new(*repository11.BulkEditRepositoryImpl)),
273273

274274
chartConfig.NewEnvConfigOverrideRepository,
275275
wire.Bind(new(chartConfig.EnvConfigOverrideRepository), new(*chartConfig.EnvConfigOverrideRepositoryImpl)),
@@ -372,6 +372,8 @@ func InitializeApp() (*App, error) {
372372
wire.Bind(new(chart.ChartService), new(*chart.ChartServiceImpl)),
373373
read2.NewChartReadServiceImpl,
374374
wire.Bind(new(read2.ChartReadService), new(*read2.ChartReadServiceImpl)),
375+
376+
service.NewBulkUpdateServiceEntImpl,
375377
service.NewBulkUpdateServiceImpl,
376378
wire.Bind(new(service.BulkUpdateService), new(*service.BulkUpdateServiceImpl)),
377379

api/cluster/ClusterRestHandler.go

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ import (
2020
"context"
2121
"encoding/json"
2222
"errors"
23-
bean2 "github.com/devtron-labs/devtron/pkg/cluster/bean"
24-
"github.com/devtron-labs/devtron/pkg/cluster/environment"
25-
"github.com/devtron-labs/devtron/pkg/cluster/rbac"
2623
"net/http"
2724
"strconv"
2825
"strings"
2926
"time"
3027

28+
bean2 "github.com/devtron-labs/devtron/pkg/cluster/bean"
29+
"github.com/devtron-labs/devtron/pkg/cluster/environment"
30+
"github.com/devtron-labs/devtron/pkg/cluster/rbac"
31+
3132
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
3233
"github.com/devtron-labs/devtron/pkg/auth/user"
3334
"github.com/devtron-labs/devtron/pkg/genericNotes"
@@ -60,6 +61,7 @@ type ClusterRestHandler interface {
6061
GetClusterNamespaces(w http.ResponseWriter, r *http.Request)
6162
GetAllClusterNamespaces(w http.ResponseWriter, r *http.Request)
6263
FindAllForClusterPermission(w http.ResponseWriter, r *http.Request)
64+
FindByIds(w http.ResponseWriter, r *http.Request)
6365
}
6466

6567
type ClusterRestHandlerImpl struct {
@@ -296,6 +298,59 @@ func (impl ClusterRestHandlerImpl) FindAll(w http.ResponseWriter, r *http.Reques
296298
common.WriteJsonResp(w, err, result, http.StatusOK)
297299
}
298300

301+
func (impl ClusterRestHandlerImpl) FindByIds(w http.ResponseWriter, r *http.Request) {
302+
token := r.Header.Get("token")
303+
304+
// Parse clusterId query parameter
305+
clusterIdsStr := r.URL.Query().Get("clusterId")
306+
if clusterIdsStr == "" {
307+
// If no clusterId parameter, return all clusters (same as FindAll)
308+
impl.FindAll(w, r)
309+
return
310+
}
311+
312+
// Parse comma-separated cluster IDs
313+
var clusterIds []int
314+
clusterIdStrs := strings.Split(clusterIdsStr, ",")
315+
for _, idStr := range clusterIdStrs {
316+
idStr = strings.TrimSpace(idStr)
317+
if idStr == "" {
318+
continue
319+
}
320+
id, err := strconv.Atoi(idStr)
321+
if err != nil {
322+
impl.logger.Errorw("request err, FindByIds", "error", err, "clusterId", idStr)
323+
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
324+
return
325+
}
326+
clusterIds = append(clusterIds, id)
327+
}
328+
329+
if len(clusterIds) == 0 {
330+
// If no valid cluster IDs, return empty result
331+
common.WriteJsonResp(w, nil, []*bean2.ClusterBean{}, http.StatusOK)
332+
return
333+
}
334+
335+
clusterList, err := impl.clusterService.FindByIdsWithoutConfig(clusterIds)
336+
if err != nil {
337+
impl.logger.Errorw("service err, FindByIds", "err", err)
338+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
339+
return
340+
}
341+
342+
// RBAC enforcer applying
343+
var result []*bean2.ClusterBean
344+
for _, item := range clusterList {
345+
if ok := impl.enforcer.Enforce(token, casbin.ResourceCluster, casbin.ActionGet, item.ClusterName); ok {
346+
result = append(result, item)
347+
}
348+
}
349+
//RBAC enforcer Ends
350+
351+
common.WriteJsonResp(w, nil, result, http.StatusOK)
352+
}
353+
299354
func (impl ClusterRestHandlerImpl) FindById(w http.ResponseWriter, r *http.Request) {
300355
vars := mux.Vars(r)
301356
id := vars["id"]
@@ -671,7 +726,14 @@ func (impl ClusterRestHandlerImpl) GetClusterNamespaces(w http.ResponseWriter, r
671726

672727
allClusterNamespaces, err := impl.clusterService.FindAllNamespacesByUserIdAndClusterId(userId, clusterId, isActionUserSuperAdmin)
673728
if err != nil {
674-
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
729+
// Check if it's a cluster connectivity error and return appropriate status code
730+
if err.Error() == cluster.ErrClusterNotReachable {
731+
impl.logger.Errorw("cluster connectivity error in GetClusterNamespaces", "error", err, "clusterId", clusterId)
732+
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
733+
} else {
734+
impl.logger.Errorw("error in GetClusterNamespaces", "error", err, "clusterId", clusterId)
735+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
736+
}
675737
return
676738
}
677739
common.WriteJsonResp(w, nil, allClusterNamespaces, http.StatusOK)

api/cluster/ClusterRouter.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ func (impl ClusterRouterImpl) InitClusterRouter(clusterRouter *mux.Router) {
5757
Queries("id", "{id}").
5858
HandlerFunc(impl.clusterRestHandler.FindNoteByClusterId)
5959

60+
clusterRouter.Path("").
61+
Methods("GET").
62+
Queries("clusterId", "{clusterId}").
63+
HandlerFunc(impl.clusterRestHandler.FindByIds)
64+
6065
clusterRouter.Path("").
6166
Methods("GET").
6267
HandlerFunc(impl.clusterRestHandler.FindAll)

0 commit comments

Comments
 (0)