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
3 changes: 2 additions & 1 deletion Wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import (
history3 "github.com/devtron-labs/devtron/pkg/pipeline/history"
repository3 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository"
repository5 "github.com/devtron-labs/devtron/pkg/pipeline/repository"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
"github.com/devtron-labs/devtron/pkg/plugin"
repository6 "github.com/devtron-labs/devtron/pkg/plugin/repository"
"github.com/devtron-labs/devtron/pkg/projectManagementService/jira"
Expand Down Expand Up @@ -441,7 +442,7 @@ func InitializeApp() (*App, error) {
repository.NewNotificationSettingsRepositoryImpl,
wire.Bind(new(repository.NotificationSettingsRepository), new(*repository.NotificationSettingsRepositoryImpl)),
util.IntValidator,
pipeline.GetCiCdConfig,
types.GetCiCdConfig,

pipeline.NewWorkflowServiceImpl,
wire.Bind(new(pipeline.WorkflowService), new(*pipeline.WorkflowServiceImpl)),
Expand Down
7 changes: 4 additions & 3 deletions api/restHandler/GitHostRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/devtron-labs/devtron/api/restHandler/common"
"github.com/devtron-labs/devtron/client/gitSensor"
"github.com/devtron-labs/devtron/pkg/pipeline"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
"github.com/devtron-labs/devtron/pkg/user"
"github.com/devtron-labs/devtron/pkg/user/casbin"
"github.com/gorilla/mux"
Expand Down Expand Up @@ -84,7 +85,7 @@ func (impl GitHostRestHandlerImpl) GetGitHosts(w http.ResponseWriter, r *http.Re

// RBAC enforcer applying
token := r.Header.Get("token")
result := make([]pipeline.GitHostRequest, 0)
result := make([]types.GitHostRequest, 0)
for _, item := range res {
if ok := impl.enforcer.Enforce(token, casbin.ResourceGit, casbin.ActionGet, strings.ToLower(item.Name)); ok {
result = append(result, item)
Expand Down Expand Up @@ -136,7 +137,7 @@ func (impl GitHostRestHandlerImpl) CreateGitHost(w http.ResponseWriter, r *http.

decoder := json.NewDecoder(r.Body)

var bean pipeline.GitHostRequest
var bean types.GitHostRequest
err = decoder.Decode(&bean)
if err != nil {
impl.logger.Errorw("request err, CreateGitHost", "err", err, "payload", bean)
Expand Down Expand Up @@ -291,6 +292,6 @@ func (impl GitHostRestHandlerImpl) GetWebhookDataMetaConfig(w http.ResponseWrite

type WebhookDataMetaConfigResponse struct {
GitHostId int `json:"gitHostId"`
GitHost *pipeline.GitHostRequest `json:"gitHost"`
GitHost *types.GitHostRequest `json:"gitHost"`
WebhookEvents []*gitSensor.WebhookEventConfig `json:"webhookEvents"`
}
9 changes: 5 additions & 4 deletions api/restHandler/GitProviderRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/devtron-labs/devtron/api/restHandler/common"
delete2 "github.com/devtron-labs/devtron/pkg/delete"
"github.com/devtron-labs/devtron/pkg/pipeline"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
"github.com/devtron-labs/devtron/pkg/team"
"github.com/devtron-labs/devtron/pkg/user"
"github.com/devtron-labs/devtron/pkg/user/casbin"
Expand Down Expand Up @@ -81,7 +82,7 @@ func (impl GitProviderRestHandlerImpl) SaveGitRepoConfig(w http.ResponseWriter,
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
return
}
var bean pipeline.GitRegistry
var bean types.GitRegistry
err = decoder.Decode(&bean)
if err != nil {
impl.logger.Errorw("request err, SaveGitRepoConfig", "err", err, "payload", bean)
Expand Down Expand Up @@ -135,7 +136,7 @@ func (impl GitProviderRestHandlerImpl) FetchAllGitProviders(w http.ResponseWrite

// RBAC enforcer applying
token := r.Header.Get("token")
result := make([]pipeline.GitRegistry, 0)
result := make([]types.GitRegistry, 0)
for _, item := range res {
if ok := impl.enforcer.Enforce(token, casbin.ResourceGit, casbin.ActionGet, strings.ToLower(item.Name)); ok {
result = append(result, item)
Expand Down Expand Up @@ -174,7 +175,7 @@ func (impl GitProviderRestHandlerImpl) UpdateGitRepoConfig(w http.ResponseWriter
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
return
}
var bean pipeline.GitRegistry
var bean types.GitRegistry
err = decoder.Decode(&bean)
if err != nil {
impl.logger.Errorw("request err, UpdateGitRepoConfig", "err", err, "payload", bean)
Expand Down Expand Up @@ -213,7 +214,7 @@ func (impl GitProviderRestHandlerImpl) DeleteGitRepoConfig(w http.ResponseWriter
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
return
}
var bean pipeline.GitRegistry
var bean types.GitRegistry
err = decoder.Decode(&bean)
if err != nil {
impl.logger.Errorw("request err, DeleteGitRepoConfig", "err", err, "payload", bean)
Expand Down
6 changes: 3 additions & 3 deletions api/restHandler/PubSubClientRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ package restHandler

import (
"encoding/json"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
"net/http"
"strings"

pubsub "github.com/devtron-labs/common-lib/pubsub-lib"
"github.com/devtron-labs/devtron/api/restHandler/common"
"github.com/devtron-labs/devtron/pkg/pipeline"
"go.uber.org/zap"
)

Expand All @@ -35,15 +35,15 @@ type PubSubClientRestHandler interface {
type PubSubClientRestHandlerImpl struct {
pubsubClient *pubsub.PubSubClientServiceImpl
logger *zap.SugaredLogger
cdConfig *pipeline.CiCdConfig
cdConfig *types.CiCdConfig
}

type PublishRequest struct {
Topic string `json:"topic"`
Payload json.RawMessage `json:"payload"`
}

func NewPubSubClientRestHandlerImpl(pubsubClient *pubsub.PubSubClientServiceImpl, logger *zap.SugaredLogger, cdConfig *pipeline.CiCdConfig) *PubSubClientRestHandlerImpl {
func NewPubSubClientRestHandlerImpl(pubsubClient *pubsub.PubSubClientServiceImpl, logger *zap.SugaredLogger, cdConfig *types.CiCdConfig) *PubSubClientRestHandlerImpl {
return &PubSubClientRestHandlerImpl{
pubsubClient: pubsubClient,
logger: logger,
Expand Down
13 changes: 7 additions & 6 deletions api/restHandler/app/BuildPipelineRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/devtron-labs/devtron/pkg/bean"
"github.com/devtron-labs/devtron/pkg/pipeline"
bean1 "github.com/devtron-labs/devtron/pkg/pipeline/bean"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
resourceGroup "github.com/devtron-labs/devtron/pkg/resourceGroup"
"github.com/devtron-labs/devtron/pkg/user/casbin"
util2 "github.com/devtron-labs/devtron/util"
Expand All @@ -31,10 +32,10 @@ import (
const GIT_MATERIAL_DELETE_SUCCESS_RESP = "Git material deleted successfully."

type BuildHistoryResponse struct {
HideImageTaggingHardDelete bool `json:"hideImageTaggingHardDelete"`
TagsEditable bool `json:"tagsEditable"`
AppReleaseTagNames []string `json:"appReleaseTagNames"` //unique list of tags exists in the app
CiWorkflows []pipeline.WorkflowResponse `json:"ciWorkflows"`
HideImageTaggingHardDelete bool `json:"hideImageTaggingHardDelete"`
TagsEditable bool `json:"tagsEditable"`
AppReleaseTagNames []string `json:"appReleaseTagNames"` //unique list of tags exists in the app
CiWorkflows []types.WorkflowResponse `json:"ciWorkflows"`
}
type DevtronAppBuildRestHandler interface {
CreateCiConfig(w http.ResponseWriter, r *http.Request)
Expand Down Expand Up @@ -1850,7 +1851,7 @@ func (handler PipelineConfigRestHandlerImpl) CreateUpdateImageTagging(w http.Res
return
}
decoder := json.NewDecoder(r.Body)
req := &pipeline.ImageTaggingRequestDTO{}
req := &types.ImageTaggingRequestDTO{}
err = decoder.Decode(&req)
if err != nil {
handler.Logger.Errorw("request err, CreateUpdateImageTagging", "err", err, "payload", req)
Expand Down Expand Up @@ -1909,7 +1910,7 @@ func (handler PipelineConfigRestHandlerImpl) CreateUpdateImageTagging(w http.Res
handler.Logger.Errorw("error occurred in getting unique tags in app", "err", err1, "appId", appId)
err = err1
}
resp = &pipeline.ImageTaggingResponseDTO{}
resp = &types.ImageTaggingResponseDTO{}
resp.AppReleaseTags = appReleaseTags
}
handler.Logger.Errorw("error occurred in creating/updating image tagging data", "err", err, "ciPipelineId", ciPipelineId)
Expand Down
5 changes: 3 additions & 2 deletions pkg/delete/DeleteServiceFullMode.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry"
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
"github.com/devtron-labs/devtron/pkg/pipeline"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
"github.com/go-pg/pg"
"go.uber.org/zap"
)

type DeleteServiceFullMode interface {
DeleteGitProvider(deleteRequest *pipeline.GitRegistry) error
DeleteGitProvider(deleteRequest *types.GitRegistry) error
DeleteDockerRegistryConfig(deleteRequest *pipeline.DockerArtifactStoreBean) error
CanDeleteContainerRegistryConfig(storeId string) bool
}
Expand Down Expand Up @@ -40,7 +41,7 @@ func NewDeleteServiceFullModeImpl(logger *zap.SugaredLogger,
dockerRegistryRepository: dockerRegistryRepository,
}
}
func (impl DeleteServiceFullModeImpl) DeleteGitProvider(deleteRequest *pipeline.GitRegistry) error {
func (impl DeleteServiceFullModeImpl) DeleteGitProvider(deleteRequest *types.GitRegistry) error {
//finding if this git account is used in any git material, if yes then will not delete
materials, err := impl.gitMaterialRepository.FindByGitProviderId(deleteRequest.Id)
if err != nil && err != pg.ErrNoRows {
Expand Down
6 changes: 3 additions & 3 deletions pkg/git/WebhookSecretValidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import (
"crypto/hmac"
"crypto/sha1"
"encoding/hex"
"github.com/devtron-labs/devtron/pkg/pipeline"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
"go.uber.org/zap"
"net/http"
"strings"
)

type WebhookSecretValidator interface {
ValidateSecret(r *http.Request, secretInUrl string, requestBodyBytes []byte, gitHost *pipeline.GitHostRequest) bool
ValidateSecret(r *http.Request, secretInUrl string, requestBodyBytes []byte, gitHost *types.GitHostRequest) bool
}

type WebhookSecretValidatorImpl struct {
Expand All @@ -51,7 +51,7 @@ const (
// URL_APPEND : Secret will come in URL (last path param of URL)
// PLAIN_TEXT : Plain text value in request header
// SHA1 : SHA1 encrypted text in request header
func (impl *WebhookSecretValidatorImpl) ValidateSecret(r *http.Request, secretInUrl string, requestBodyBytes []byte, gitHost *pipeline.GitHostRequest) bool {
func (impl *WebhookSecretValidatorImpl) ValidateSecret(r *http.Request, secretInUrl string, requestBodyBytes []byte, gitHost *types.GitHostRequest) bool {

secretValidator := gitHost.SecretValidator
impl.logger.Debug("Validating signature for secret validator : ", secretValidator)
Expand Down
5 changes: 3 additions & 2 deletions pkg/pipeline/ArgoWorkflowExecutor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
bean2 "github.com/devtron-labs/devtron/api/bean"
"github.com/devtron-labs/devtron/internal/util"
"github.com/devtron-labs/devtron/pkg/pipeline/bean"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
"github.com/stretchr/testify/assert"
v12 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -27,7 +28,7 @@ func TestExecuteWorkflow(t *testing.T) {
t.SkipNow()
logger, loggerErr := util.NewSugardLogger()
assert.Nil(t, loggerErr)
cdConfig, err := GetCiCdConfig()
cdConfig, err := types.GetCiCdConfig()
assert.Nil(t, err)
workflowExecutorImpl := NewArgoWorkflowExecutorImpl(logger)

Expand Down Expand Up @@ -260,7 +261,7 @@ func getGcpBlobStorage() *blob_storage.GcpBlobConfig {
}
}

func getBaseWorkflowTemplate(cdConfig *CiCdConfig) bean.WorkflowTemplate {
func getBaseWorkflowTemplate(cdConfig *types.CiCdConfig) bean.WorkflowTemplate {

workflowTemplate := bean.WorkflowTemplate{}
workflowTemplate.WfControllerInstanceID = "random-controller-id"
Expand Down
17 changes: 9 additions & 8 deletions pkg/pipeline/BuildPipelineConfigService.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/devtron-labs/devtron/pkg/bean"
bean3 "github.com/devtron-labs/devtron/pkg/pipeline/bean"
"github.com/devtron-labs/devtron/pkg/pipeline/history"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup"
"github.com/devtron-labs/devtron/pkg/sql"
util2 "github.com/devtron-labs/devtron/util"
Expand Down Expand Up @@ -109,7 +110,7 @@ type CiPipelineConfigServiceImpl struct {
ciTemplateService CiTemplateService
materialRepo pipelineConfig.MaterialRepository
ciPipelineRepository pipelineConfig.CiPipelineRepository
ciConfig *CiCdConfig
ciConfig *types.CiCdConfig
attributesService attributes.AttributesService
ciWorkflowRepository pipelineConfig.CiWorkflowRepository
appWorkflowRepository appWorkflow.AppWorkflowRepository
Expand Down Expand Up @@ -137,7 +138,7 @@ func NewCiPipelineConfigServiceImpl(logger *zap.SugaredLogger,
ciPipelineRepository pipelineConfig.CiPipelineRepository,
ecrConfig *EcrConfig,
appWorkflowRepository appWorkflow.AppWorkflowRepository,
ciConfig *CiCdConfig,
ciConfig *types.CiCdConfig,
attributesService attributes.AttributesService,
pipelineStageService PipelineStageService,
ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository,
Expand Down Expand Up @@ -543,7 +544,7 @@ func (impl *CiPipelineConfigServiceImpl) GetCiPipeline(appId int) (ciConfig *bea
return nil, err
}
if hostUrl != nil {
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, ExternalCiWebhookPath)
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, types.ExternalCiWebhookPath)
}
}
//map of ciPipelineId and their templateOverrideConfig
Expand Down Expand Up @@ -705,7 +706,7 @@ func (impl *CiPipelineConfigServiceImpl) GetCiPipelineById(pipelineId int) (ciPi
return nil, err
}
if hostUrl != nil {
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, ExternalCiWebhookPath)
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, types.ExternalCiWebhookPath)
}
}

Expand Down Expand Up @@ -933,7 +934,7 @@ func (impl *CiPipelineConfigServiceImpl) GetExternalCi(appId int) (ciConfig []*b
return nil, err
}
if hostUrl != nil {
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, ExternalCiWebhookPath)
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, types.ExternalCiWebhookPath)
}

externalCiConfigs := make([]*bean.ExternalCiConfig, 0)
Expand Down Expand Up @@ -1065,7 +1066,7 @@ func (impl *CiPipelineConfigServiceImpl) GetExternalCiById(appId int, externalCi
return nil, err
}
if hostUrl != nil {
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, ExternalCiWebhookPath)
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, types.ExternalCiWebhookPath)
}

appWorkflowMappings, err := impl.appWorkflowRepository.FindWFCDMappingByExternalCiId(externalCiPipeline.Id)
Expand Down Expand Up @@ -1604,7 +1605,7 @@ func (impl *CiPipelineConfigServiceImpl) GetCiPipelineByEnvironment(request reso
return nil, err
}
if hostUrl != nil {
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, ExternalCiWebhookPath)
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, types.ExternalCiWebhookPath)
}
}

Expand Down Expand Up @@ -1891,7 +1892,7 @@ func (impl *CiPipelineConfigServiceImpl) GetExternalCiByEnvironment(request reso
return nil, err
}
if hostUrl != nil {
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, ExternalCiWebhookPath)
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, types.ExternalCiWebhookPath)
}

var externalCiPipelineIds []int
Expand Down
Loading