Skip to content

Commit 01a5f90

Browse files
committed
using common lib for target platform operations
1 parent 03bb805 commit 01a5f90

File tree

16 files changed

+54
-50
lines changed

16 files changed

+54
-50
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ require gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
289289
replace (
290290
github.com/argoproj/argo-workflows/v3 v3.5.10 => github.com/devtron-labs/argo-workflows/v3 v3.5.13
291291
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250113062708-5533d8b81d91
292-
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250113062708-5533d8b81d91
292+
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250122102431-e7d7af31e081
293293
github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127
294294
github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.5
295295
k8s.io/api => k8s.io/api v0.29.7

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,8 @@ github.com/devtron-labs/argo-workflows/v3 v3.5.13 h1:3pINq0gXOSeTw2z/vYe+j80lRpS
794794
github.com/devtron-labs/argo-workflows/v3 v3.5.13/go.mod h1:/vqxcovDPT4zqr4DjR5v7CF8ggpY1l3TSa2CIG3jmjA=
795795
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250113062708-5533d8b81d91 h1:mLG5ANeVjaDDDdvG+jp5cwPEISORIoGn3kf6M7h9K2U=
796796
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250113062708-5533d8b81d91/go.mod h1:5lv4Wfj5ERhhvDGXe2IeES6qxjvUVCcohaRwKnWBMNo=
797-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250113062708-5533d8b81d91 h1:YGpfHCkFr4YwRq3C1M8bmU+BmBFey66ZFx9MS4/jz/4=
798-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250113062708-5533d8b81d91/go.mod h1:1QJJLpgJSkb5Jm9xPeKAk+kXb0QgBOOOgJj0cgYhAVA=
797+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250122102431-e7d7af31e081 h1:ZDX1jkecjoTKJs649Z7X6eV2E/Q7P2ITXyJBbBpgaJ8=
798+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250122102431-e7d7af31e081/go.mod h1:1QJJLpgJSkb5Jm9xPeKAk+kXb0QgBOOOgJj0cgYhAVA=
799799
github.com/devtron-labs/go-bitbucket v0.9.60-beta h1:VEx1jvDgdtDPS6A1uUFoaEi0l1/oLhbr+90xOwr6sDU=
800800
github.com/devtron-labs/go-bitbucket v0.9.60-beta/go.mod h1:GnuiCesvh8xyHeMCb+twm8lBR/kQzJYSKL28ZfObp1Y=
801801
github.com/devtron-labs/protos v0.0.3-0.20240802105333-92ee9bb85d80 h1:xwbTeijNTf4/j1v+tSfwVqwLVnReas/NqEKeQHvSTys=

pkg/bean/app.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package bean
1818

1919
import (
2020
"encoding/json"
21+
bean4 "github.com/devtron-labs/common-lib/utils/bean"
2122
bean2 "github.com/devtron-labs/devtron/api/bean/AppView"
2223
"github.com/devtron-labs/devtron/internal/sql/constants"
2324
repository3 "github.com/devtron-labs/devtron/internal/sql/repository"
@@ -827,7 +828,7 @@ type CiArtifactBean struct {
827828
CiWorkflowId int `json:"-"`
828829
RegistryType string `json:"registryType"`
829830
RegistryName string `json:"registryName"`
830-
TargetPlatforms []*bean.TargetPlatform `json:"targetPlatforms"`
831+
TargetPlatforms []*bean4.TargetPlatform `json:"targetPlatforms"`
831832
CiPipelineId int `json:"-"`
832833
CredentialsSourceType string `json:"-"`
833834
CredentialsSourceValue string `json:"-"`

pkg/pipeline/AppArtifactManager.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
package pipeline
1818

1919
import (
20+
"github.com/devtron-labs/common-lib/utils"
2021
argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean"
2122
"github.com/devtron-labs/devtron/pkg/build/artifacts/imageTagging"
2223
"github.com/devtron-labs/devtron/pkg/build/pipeline"
23-
"github.com/devtron-labs/devtron/pkg/pipeline/adapter"
2424
pipelineBean "github.com/devtron-labs/devtron/pkg/pipeline/bean"
2525
"sort"
2626
"strings"
@@ -403,7 +403,7 @@ func (impl *AppArtifactManagerImpl) BuildRollbackArtifactsList(artifactListingFi
403403
deployedCiArtifacts = append(deployedCiArtifacts, bean2.CiArtifactBean{
404404
Id: ciArtifact.Id,
405405
Image: ciArtifact.Image,
406-
TargetPlatforms: adapter.GetTargetPlatformObjectFromString(ciArtifact.TargetPlatforms),
406+
TargetPlatforms: utils.ConvertTargetPlatformStringToObject(ciArtifact.TargetPlatforms),
407407
MaterialInfo: mInfo,
408408
DeployedTime: formatDate(ciArtifact.StartedOn, bean2.LayoutRFC3339),
409409
WfrId: ciArtifact.CdWorkflowRunnerId,
@@ -658,7 +658,7 @@ func (impl *AppArtifactManagerImpl) BuildArtifactsList(listingFilterOpts *bean.A
658658
currentRunningArtifactBean = &bean2.CiArtifactBean{
659659
Id: currentRunningArtifact.Id,
660660
Image: currentRunningArtifact.Image,
661-
TargetPlatforms: adapter.GetTargetPlatformObjectFromString(currentRunningArtifact.TargetPlatforms),
661+
TargetPlatforms: utils.ConvertTargetPlatformStringToObject(currentRunningArtifact.TargetPlatforms),
662662
ImageDigest: currentRunningArtifact.ImageDigest,
663663
MaterialInfo: mInfo,
664664
ScanEnabled: currentRunningArtifact.ScanEnabled,
@@ -740,7 +740,7 @@ func (impl *AppArtifactManagerImpl) BuildArtifactsForCdStageV2(listingFilterOpts
740740
ciArtifact := &bean2.CiArtifactBean{
741741
Id: artifact.Id,
742742
Image: artifact.Image,
743-
TargetPlatforms: adapter.GetTargetPlatformObjectFromString(artifact.TargetPlatforms),
743+
TargetPlatforms: utils.ConvertTargetPlatformStringToObject(artifact.TargetPlatforms),
744744
ImageDigest: artifact.ImageDigest,
745745
MaterialInfo: mInfo,
746746
//TODO:LastSuccessfulTriggerOnParent
@@ -785,7 +785,7 @@ func (impl *AppArtifactManagerImpl) BuildArtifactsForCIParentV2(listingFilterOpt
785785
ciArtifact := &bean2.CiArtifactBean{
786786
Id: artifact.Id,
787787
Image: artifact.Image,
788-
TargetPlatforms: adapter.GetTargetPlatformObjectFromString(artifact.TargetPlatforms),
788+
TargetPlatforms: utils.ConvertTargetPlatformStringToObject(artifact.TargetPlatforms),
789789
ImageDigest: artifact.ImageDigest,
790790
MaterialInfo: mInfo,
791791
ScanEnabled: artifact.ScanEnabled,

pkg/pipeline/CdHandler.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ import (
2020
"bufio"
2121
"errors"
2222
"fmt"
23+
"github.com/devtron-labs/common-lib/utils"
24+
bean4 "github.com/devtron-labs/common-lib/utils/bean"
2325
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/adapter/cdWorkflow"
2426
bean2 "github.com/devtron-labs/devtron/pkg/bean"
2527
"github.com/devtron-labs/devtron/pkg/build/artifacts/imageTagging"
2628
"github.com/devtron-labs/devtron/pkg/cluster/adapter"
2729
bean3 "github.com/devtron-labs/devtron/pkg/cluster/bean"
2830
repository3 "github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
2931
common2 "github.com/devtron-labs/devtron/pkg/deployment/common"
30-
adapter2 "github.com/devtron-labs/devtron/pkg/pipeline/adapter"
3132
util2 "github.com/devtron-labs/devtron/pkg/pipeline/util"
3233
"os"
3334
"path/filepath"
@@ -612,15 +613,15 @@ func (impl *CdHandlerImpl) FetchCdWorkflowDetails(appId int, environmentId int,
612613
triggeredByUserEmailId = "anonymous"
613614
}
614615
ciArtifactId := workflow.CiArtifactId
615-
targetPlatforms := []*pipelineBean.TargetPlatform{}
616+
targetPlatforms := []*bean4.TargetPlatform{}
616617
if ciArtifactId > 0 {
617618
ciArtifact, err := impl.ciArtifactRepository.Get(ciArtifactId)
618619
if err != nil {
619620
impl.Logger.Errorw("error fetching artifact data", "err", err)
620621
return types.WorkflowResponse{}, err
621622
}
622623

623-
targetPlatforms = adapter2.GetTargetPlatformObjectFromString(ciArtifact.TargetPlatforms)
624+
targetPlatforms = utils.ConvertTargetPlatformStringToObject(ciArtifact.TargetPlatforms)
624625

625626
// handling linked ci pipeline
626627
if ciArtifact.ParentCiArtifact > 0 && ciArtifact.WorkflowId == nil {
@@ -781,7 +782,7 @@ func (impl *CdHandlerImpl) converterWFR(wfr pipelineConfig.CdWorkflowRunner) pip
781782
workflow.WorkflowType = string(wfr.WorkflowType)
782783
workflow.CdWorkflowId = wfr.CdWorkflowId
783784
workflow.Image = wfr.CdWorkflow.CiArtifact.Image
784-
workflow.TargetPlatforms = adapter2.GetTargetPlatformObjectFromString(wfr.CdWorkflow.CiArtifact.TargetPlatforms)
785+
workflow.TargetPlatforms = utils.ConvertTargetPlatformStringToObject(wfr.CdWorkflow.CiArtifact.TargetPlatforms)
785786
workflow.PipelineId = wfr.CdWorkflow.PipelineId
786787
workflow.CiArtifactId = wfr.CdWorkflow.CiArtifactId
787788
isArtifactUploaded, isMigrationRequired := wfr.GetIsArtifactUploaded()

pkg/pipeline/CiHandler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"context"
2222
"errors"
2323
"fmt"
24+
"github.com/devtron-labs/common-lib/utils"
2425
"github.com/devtron-labs/common-lib/utils/workFlow"
2526
"github.com/devtron-labs/devtron/internal/sql/constants"
2627
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow"
@@ -31,7 +32,6 @@ import (
3132
bean5 "github.com/devtron-labs/devtron/pkg/cluster/bean"
3233
"github.com/devtron-labs/devtron/pkg/cluster/environment"
3334
repository2 "github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
34-
adapter2 "github.com/devtron-labs/devtron/pkg/pipeline/adapter"
3535
util3 "github.com/devtron-labs/devtron/pkg/pipeline/util"
3636
"io/ioutil"
3737
"net/http"
@@ -572,7 +572,7 @@ func (impl *CiHandlerImpl) GetBuildHistory(pipelineId int, appId int, offset int
572572
EnvironmentName: w.EnvironmentName,
573573
ReferenceWorkflowId: w.RefCiWorkflowId,
574574
PodName: w.PodName,
575-
TargetPlatforms: adapter2.GetTargetPlatformObjectFromString(w.TargetPlatforms),
575+
TargetPlatforms: utils.ConvertTargetPlatformStringToObject(w.TargetPlatforms),
576576
}
577577

578578
if w.Message == bean3.ImageTagUnavailableMessage {
@@ -800,7 +800,7 @@ func (impl *CiHandlerImpl) FetchWorkflowDetails(appId int, pipelineId int, build
800800
TriggeredBy: workflow.TriggeredBy,
801801
TriggeredByEmail: triggeredByUserEmailId,
802802
Artifact: ciArtifact.Image,
803-
TargetPlatforms: adapter2.GetTargetPlatformObjectFromString(ciArtifact.TargetPlatforms),
803+
TargetPlatforms: utils.ConvertTargetPlatformStringToObject(ciArtifact.TargetPlatforms),
804804
ArtifactId: ciArtifact.Id,
805805
IsArtifactUploaded: isArtifactUploaded,
806806
EnvironmentId: workflow.EnvironmentId,
@@ -1600,7 +1600,7 @@ func (impl *CiHandlerImpl) FetchMaterialInfoByArtifactId(ciArtifactId int, envId
16001600
Default: deployDetail.Default,
16011601
ImageTaggingData: *imageTaggingData,
16021602
Image: ciArtifact.Image,
1603-
TargetPlatforms: adapter2.GetTargetPlatformObjectFromString(ciArtifact.TargetPlatforms),
1603+
TargetPlatforms: utils.ConvertTargetPlatformStringToObject(ciArtifact.TargetPlatforms),
16041604
}
16051605
return gitTriggerInfoResponse, nil
16061606
}

pkg/pipeline/adapter/adapter.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/devtron-labs/devtron/pkg/pipeline/repository"
2828
"github.com/devtron-labs/devtron/pkg/pipeline/types"
2929
"github.com/devtron-labs/devtron/pkg/sql"
30-
"strings"
3130
"time"
3231
)
3332

@@ -379,18 +378,3 @@ func GetStepVariableDto(variable *repository.PipelineStageStepVariable) (*pipeli
379378
}
380379
return variableDto, nil
381380
}
382-
383-
func GetTargetPlatformObjectFromString(targetPlatformString string) []*pipelineConfigBean.TargetPlatform {
384-
targetPlatforms := GetTargetPlatformListFromString(targetPlatformString)
385-
targetPlatformObject := []*pipelineConfigBean.TargetPlatform{}
386-
for _, targetPlatform := range targetPlatforms {
387-
if len(targetPlatform) > 0 {
388-
targetPlatformObject = append(targetPlatformObject, &pipelineConfigBean.TargetPlatform{Name: targetPlatform})
389-
}
390-
}
391-
return targetPlatformObject
392-
}
393-
394-
func GetTargetPlatformListFromString(targetPlatform string) []string {
395-
return strings.Split(targetPlatform, ",")
396-
}

pkg/pipeline/bean/ArtifactManagerBean.go

Lines changed: 0 additions & 5 deletions
This file was deleted.

pkg/pipeline/bean/CdHandlerBean.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package bean
22

33
import (
4+
"github.com/devtron-labs/common-lib/utils/bean"
45
"github.com/devtron-labs/devtron/internal/sql/repository/imageTagging"
56
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
67
"time"
@@ -21,7 +22,7 @@ type CdWorkflowWithArtifact struct {
2122
TriggeredBy int32 `json:"triggered_by"`
2223
EmailId string `json:"email_id"`
2324
Image string `json:"image"`
24-
TargetPlatforms []*TargetPlatform `json:"targetPlatforms"`
25+
TargetPlatforms []*bean.TargetPlatform `json:"targetPlatforms"`
2526
MaterialInfo string `json:"material_info,omitempty"`
2627
DataSource string `json:"data_source,omitempty"`
2728
CiArtifactId int `json:"ci_artifact_id,omitempty"`

pkg/pipeline/types/CiCdConfig.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"fmt"
2424
"github.com/caarlos0/env"
2525
blob_storage "github.com/devtron-labs/common-lib/blob-storage"
26+
bean2 "github.com/devtron-labs/common-lib/utils/bean"
2627
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
2728
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow"
2829
"github.com/devtron-labs/devtron/pkg/bean/common"
@@ -557,7 +558,7 @@ type GitTriggerInfoResponse struct {
557558
Default bool `json:"default,omitempty"`
558559
ImageTaggingData ImageTaggingResponseDTO `json:"imageTaggingData"`
559560
Image string `json:"image"`
560-
TargetPlatforms []*bean.TargetPlatform `json:"targetPlatforms"`
561+
TargetPlatforms []*bean2.TargetPlatform `json:"targetPlatforms"`
561562
}
562563

563564
type Trigger struct {

0 commit comments

Comments
 (0)