Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Config diff 3 oss #5837

Merged
merged 44 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a4bcbd6
support for CdRollback and DeploymentHistory in configData API
prakash100198 Sep 11, 2024
e2ee5a6
support for getConfigDataForDeploymentHistory and getConfigDataForCdR…
prakash100198 Sep 12, 2024
f379640
resolve cm cs data in published config code incorporated
prakash100198 Sep 12, 2024
cb1df7b
Merge branch 'develop' into config-diff-3-oss
prakash100198 Sep 12, 2024
01e7110
Merge branch 'develop' into config-diff-3-oss
prakash100198 Sep 13, 2024
17a5c6b
Merge branch 'develop' into config-diff-3-oss
prakash100198 Sep 13, 2024
aa565e0
wip: bug fixes
prakash100198 Sep 16, 2024
5ffb0f8
wip: new config area to resolve data for given values
prakash100198 Sep 17, 2024
6d95766
wip: fix
prakash100198 Sep 17, 2024
4aad54a
wip: marshal resolved template before sending back res p
prakash100198 Sep 17, 2024
711b682
convert to json raw message for resolved data
prakash100198 Sep 17, 2024
d883794
Merge branch 'develop' into config-diff-3-oss
prakash100198 Sep 17, 2024
d0714dd
wip: fix
prakash100198 Sep 17, 2024
a7033a1
wip: convert to json raw
prakash100198 Sep 18, 2024
a0fe976
Merge branch 'develop' into config-diff-3-oss
prakash100198 Sep 18, 2024
28dcbd4
wip: take values from path param values
prakash100198 Sep 18, 2024
425780f
decode values payload
prakash100198 Sep 18, 2024
fa52171
if content of post config data is >0 then only parse the payload else…
prakash100198 Sep 18, 2024
530301e
add template version and isAppMetrics enabled in case of deployment t…
prakash100198 Sep 22, 2024
6f7bc6e
Merge branch 'develop' into config-diff-3-oss
prakash100198 Sep 25, 2024
89656bf
pipeline strategy in published data req
prakash100198 Sep 25, 2024
53e102a
making config/data api backward compatible
prakash100198 Sep 26, 2024
060d5d7
handle for pg no rows
prakash100198 Sep 26, 2024
891d267
Merge branch 'develop' into config-diff-3-oss
prakash100198 Oct 7, 2024
7a7627e
merge develop here
prakash100198 Oct 7, 2024
a720200
fix for chart version
prakash100198 Oct 7, 2024
596b86b
remove getResolvedConfigDataForValues
prakash100198 Oct 7, 2024
fba905e
handle nil pipeline strategy in case of custom chart
prakash100198 Oct 8, 2024
e1cc5d3
Merge branch 'develop' into config-diff-3-oss
prakash100198 Oct 8, 2024
ae9c3aa
revert defer cancel
prakash100198 Oct 8, 2024
a83f5cc
code review :- 1
prakash100198 Oct 8, 2024
03a18d9
Merge branch 'develop' into config-diff-3-oss
prakash100198 Oct 8, 2024
228e8e8
remove pipelineStrategy
prakash100198 Oct 9, 2024
03d93ec
Merge branch 'release-candidate-v0.20.0' into config-diff-3-oss
prakash100198 Oct 10, 2024
57eb6b6
wire fix
prakash100198 Oct 10, 2024
7f8b3d0
add wfr_id in template/list api
prakash100198 Oct 10, 2024
c56c4c9
code review changes
prakash100198 Oct 10, 2024
aa670f1
scope var fix
prakash100198 Oct 14, 2024
494d30b
edit resource
prakash100198 Oct 14, 2024
5ffb3dd
previous deployments stage added
prakash100198 Oct 15, 2024
43c779a
Merge branch 'develop' into config-diff-3-oss
prakash100198 Oct 15, 2024
813738b
Merge branch 'develop' into config-diff-3-oss
prakash100198 Oct 17, 2024
ebcfd49
code review incorporation :- kartik
prakash100198 Oct 17, 2024
0078d80
code review incorporation :- kartik 2
prakash100198 Oct 17, 2024
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
12 changes: 10 additions & 2 deletions api/restHandler/DeploymentConfigurationRestHandler.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package restHandler

import (
"context"
"fmt"
"github.com/devtron-labs/devtron/api/restHandler/common"
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
"github.com/devtron-labs/devtron/pkg/auth/user"
"github.com/devtron-labs/devtron/pkg/configDiff"
"github.com/devtron-labs/devtron/pkg/configDiff/bean"
util2 "github.com/devtron-labs/devtron/util"
"github.com/devtron-labs/devtron/util/rbac"
"github.com/gorilla/schema"
"go.uber.org/zap"
"gopkg.in/go-playground/validator.v9"
"net/http"
"time"
)

type DeploymentConfigurationRestHandler interface {
Expand Down Expand Up @@ -88,6 +91,7 @@ func (handler *DeploymentConfigurationRestHandlerImpl) GetConfigData(w http.Resp
return
}

configDataQueryParams.UserId = userId
//RBAC START
token := r.Header.Get(common.TokenHeaderKey)
object := handler.enforcerUtil.GetAppRBACName(configDataQueryParams.AppName)
Expand All @@ -97,8 +101,12 @@ func (handler *DeploymentConfigurationRestHandlerImpl) GetConfigData(w http.Resp
return
}
//RBAC END

res, err := handler.deploymentConfigurationService.GetAllConfigData(r.Context(), configDataQueryParams)
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*")
userHasAdminAccess := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionUpdate, object)
ctx, cancel := context.WithTimeout(r.Context(), 60*time.Second)
defer cancel()
ctx = util2.SetSuperAdminInContext(ctx, isSuperAdmin)
res, err := handler.deploymentConfigurationService.GetAllConfigData(ctx, configDataQueryParams, userHasAdminAccess)
if err != nil {
handler.logger.Errorw("service err, GetAllConfigData ", "err", err)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down
3 changes: 2 additions & 1 deletion internal/sql/repository/DeploymentTemplateRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type DeploymentTemplateComparisonMetadata struct {
EnvironmentId int `json:"environmentId,omitempty"`
EnvironmentName string `json:"environmentName,omitempty"`
DeploymentTemplateHistoryId int `json:"deploymentTemplateHistoryId,omitempty"`
WfrId int `json:"wfrId,omitempty"`
StartedOn *time.Time `json:"startedOn,omitempty"`
FinishedOn *time.Time `json:"finishedOn,omitempty"`
Status string `json:"status,omitempty"`
Expand Down Expand Up @@ -69,7 +70,7 @@ func (impl DeploymentTemplateRepositoryImpl) FetchDeploymentHistoryWithChartRefs
limit := 15

query := "select p.id as pipeline_id, dth.id as deployment_template_history_id," +
" wfr.finished_on, wfr.status, c.chart_ref_id, c.chart_version FROM cd_workflow_runner wfr" +
" wfr.id as wfr_id, wfr.finished_on, wfr.status, c.chart_ref_id, c.chart_version FROM cd_workflow_runner wfr" +
" JOIN cd_workflow wf ON wf.id = wfr.cd_workflow_id JOIN pipeline p ON p.id = wf.pipeline_id" +
" JOIN deployment_template_history dth ON dth.deployed_on = wfr.started_on " +
"JOIN pipeline_config_override pco ON pco.cd_workflow_id = wf.id " +
Expand Down
3 changes: 3 additions & 0 deletions pkg/bean/configSecretData.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type SecretList struct {
ConfigData []*ConfigData `json:"secrets"`
}

// there is an adapter written in pkg/bean folder to convert below ConfigData struct to pipeline/bean's ConfigData

// TODO refactoring: duplicate struct of ConfigData in ConfigMapBean.go
type ConfigData struct {
Name string `json:"name"`
Expand All @@ -49,6 +51,7 @@ type ConfigData struct {
SubPath bool `json:"subPath"`
ESOSubPath []string `json:"esoSubPath"`
FilePermission string `json:"filePermission"`
Overridden bool `json:"overridden"`
}

func (c *ConfigData) IsESOExternalSecretType() bool {
Expand Down
12 changes: 12 additions & 0 deletions pkg/cluster/repository/EnvironmentRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type EnvironmentRepository interface {
FindAllActiveWithFilter() ([]*Environment, error)
FindEnvClusterInfosByIds([]int) ([]*EnvCluserInfo, error)
FindEnvLinkedWithCiPipelines(externalCi bool, ciPipelineIds []int) ([]*Environment, error)
FindEnvByNameWithClusterDetails(envName string) (*Environment, error)
}

func NewEnvironmentRepositoryImpl(dbConnection *pg.DB, logger *zap.SugaredLogger, appStatusRepository appStatus.AppStatusRepository) *EnvironmentRepositoryImpl {
Expand Down Expand Up @@ -160,6 +161,17 @@ func (repositoryImpl EnvironmentRepositoryImpl) FindByName(name string) (*Enviro
return environment, err
}

func (repositoryImpl EnvironmentRepositoryImpl) FindEnvByNameWithClusterDetails(envName string) (*Environment, error) {
environment := &Environment{}
err := repositoryImpl.dbConnection.
Model(environment).
Column("environment.*", "Cluster").
Where("environment.environment_name = ?", envName).
Where("environment.active = ?", true).
Select()
return environment, err
}

func (repositoryImpl EnvironmentRepositoryImpl) FindIdByName(name string) (int, error) {
environment := &Environment{}
err := repositoryImpl.dbConnection.
Expand Down
Loading