Skip to content

Commit b7bff2b

Browse files
committed
support for target platforms
1 parent ded2c48 commit b7bff2b

18 files changed

+51
-1
lines changed

internal/sql/repository/CiArtifactRepository.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ type CiArtifact struct {
7777
IsArtifactUploaded bool `sql:"is_artifact_uploaded"` // Deprecated; Use pipelineConfig.CiWorkflow instead.
7878
CredentialsSourceType string `sql:"credentials_source_type"`
7979
CredentialSourceValue string `sql:"credentials_source_value"`
80+
TargetPlatforms string `sql:"target_platforms"`
8081
ComponentId int `sql:"component_id"`
8182
DeployedTime time.Time `sql:"-"`
8283
Deployed bool `sql:"-"`

internal/sql/repository/pipelineConfig/CiWorkflowRepository.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ type WorkflowWithArtifact struct {
120120
TriggeredBy int32 `sql:"triggered_by"`
121121
EmailId string `sql:"email_id"`
122122
Image string `sql:"image"`
123+
TargetPlatforms string `sql:"target_platforms"`
123124
CiArtifactLocation string `sql:"ci_artifact_location"`
124125
CiArtifactId int `sql:"ci_artifact_id"`
125126
BlobStorageEnabled bool `sql:"blob_storage_enabled"`
@@ -193,6 +194,7 @@ func (impl *CiWorkflowRepositoryImpl) FindByPipelineId(pipelineId int, offset in
193194
ColumnExpr("cia.id AS ci_artifact_id").
194195
ColumnExpr("env.environment_name").
195196
ColumnExpr("cia.image").
197+
ColumnExpr("cia.target_platforms").
196198
ColumnExpr("cia.is_artifact_uploaded AS old_is_artifact_uploaded").
197199
ColumnExpr("wf.*").
198200
ColumnExpr("u.email_id").

pkg/bean/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ type CiArtifactBean struct {
827827
CiWorkflowId int `json:"-"`
828828
RegistryType string `json:"registryType"`
829829
RegistryName string `json:"registryName"`
830+
TargetPlatforms []bean.TargetPlatform `json:"targetPlatforms"`
830831
CiPipelineId int `json:"-"`
831832
CredentialsSourceType string `json:"-"`
832833
CredentialsSourceValue string `json:"-"`

pkg/eventProcessor/bean/workflowEventBean.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ type CiCompleteEvent struct {
8383
PluginRegistryArtifactDetails map[string][]string `json:"PluginRegistryArtifactDetails"`
8484
PluginArtifactStage string `json:"pluginArtifactStage"`
8585
IsScanEnabled bool `json:"isScanEnabled"`
86+
TargetPlatforms []string `json:"targetPlatforms"`
8687
pluginImageDetails *registry.ImageDetailsFromCR
8788
PluginArtifacts *PluginArtifacts `json:"pluginArtifacts"`
8889
}

pkg/eventProcessor/in/WorkflowEventProcessorService.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ func (impl *WorkflowEventProcessorImpl) BuildCiArtifactRequest(event bean.CiComp
678678
PluginRegistryArtifactDetails: pluginArtifacts,
679679
PluginArtifactStage: event.PluginArtifactStage,
680680
IsScanEnabled: event.IsScanEnabled,
681+
TargetPlatforms: event.TargetPlatforms,
681682
}
682683
// if DataSource is empty, repository.WEBHOOK is considered as default
683684
if request.DataSource == "" {

pkg/pipeline/AppArtifactManager.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean"
2121
"github.com/devtron-labs/devtron/pkg/build/artifacts/imageTagging"
2222
"github.com/devtron-labs/devtron/pkg/build/pipeline"
23+
"github.com/devtron-labs/devtron/pkg/pipeline/adapter"
2324
pipelineBean "github.com/devtron-labs/devtron/pkg/pipeline/bean"
2425
"sort"
2526
"strings"
@@ -402,6 +403,7 @@ func (impl *AppArtifactManagerImpl) BuildRollbackArtifactsList(artifactListingFi
402403
deployedCiArtifacts = append(deployedCiArtifacts, bean2.CiArtifactBean{
403404
Id: ciArtifact.Id,
404405
Image: ciArtifact.Image,
406+
TargetPlatforms: adapter.GetTargetPlatformObjectFromString(ciArtifact.TargetPlatforms),
405407
MaterialInfo: mInfo,
406408
DeployedTime: formatDate(ciArtifact.StartedOn, bean2.LayoutRFC3339),
407409
WfrId: ciArtifact.CdWorkflowRunnerId,
@@ -656,6 +658,7 @@ func (impl *AppArtifactManagerImpl) BuildArtifactsList(listingFilterOpts *bean.A
656658
currentRunningArtifactBean = &bean2.CiArtifactBean{
657659
Id: currentRunningArtifact.Id,
658660
Image: currentRunningArtifact.Image,
661+
TargetPlatforms: adapter.GetTargetPlatformObjectFromString(currentRunningArtifact.TargetPlatforms),
659662
ImageDigest: currentRunningArtifact.ImageDigest,
660663
MaterialInfo: mInfo,
661664
ScanEnabled: currentRunningArtifact.ScanEnabled,

pkg/pipeline/CdHandler.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
bean3 "github.com/devtron-labs/devtron/pkg/cluster/bean"
2828
repository3 "github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
2929
common2 "github.com/devtron-labs/devtron/pkg/deployment/common"
30+
adapter2 "github.com/devtron-labs/devtron/pkg/pipeline/adapter"
3031
util2 "github.com/devtron-labs/devtron/pkg/pipeline/util"
3132
"os"
3233
"path/filepath"
@@ -611,13 +612,16 @@ func (impl *CdHandlerImpl) FetchCdWorkflowDetails(appId int, environmentId int,
611612
triggeredByUserEmailId = "anonymous"
612613
}
613614
ciArtifactId := workflow.CiArtifactId
615+
targetPlatforms := []pipelineBean.TargetPlatform{}
614616
if ciArtifactId > 0 {
615617
ciArtifact, err := impl.ciArtifactRepository.Get(ciArtifactId)
616618
if err != nil {
617619
impl.Logger.Errorw("error fetching artifact data", "err", err)
618620
return types.WorkflowResponse{}, err
619621
}
620622

623+
targetPlatforms = adapter2.GetTargetPlatformObjectFromString(ciArtifact.TargetPlatforms)
624+
621625
// handling linked ci pipeline
622626
if ciArtifact.ParentCiArtifact > 0 && ciArtifact.WorkflowId == nil {
623627
ciArtifactId = ciArtifact.ParentCiArtifact
@@ -673,6 +677,7 @@ func (impl *CdHandlerImpl) FetchCdWorkflowDetails(appId int, environmentId int,
673677
ArtifactId: workflow.CiArtifactId,
674678
IsArtifactUploaded: workflow.IsArtifactUploaded,
675679
CiPipelineId: ciWf.CiPipelineId,
680+
TargetPlatforms: targetPlatforms,
676681
}
677682
return workflowResponse, nil
678683

@@ -776,6 +781,7 @@ func (impl *CdHandlerImpl) converterWFR(wfr pipelineConfig.CdWorkflowRunner) pip
776781
workflow.WorkflowType = string(wfr.WorkflowType)
777782
workflow.CdWorkflowId = wfr.CdWorkflowId
778783
workflow.Image = wfr.CdWorkflow.CiArtifact.Image
784+
workflow.TargetPlatforms = adapter2.GetTargetPlatformObjectFromString(wfr.CdWorkflow.CiArtifact.TargetPlatforms)
779785
workflow.PipelineId = wfr.CdWorkflow.PipelineId
780786
workflow.CiArtifactId = wfr.CdWorkflow.CiArtifactId
781787
isArtifactUploaded, isMigrationRequired := wfr.GetIsArtifactUploaded()

pkg/pipeline/CiHandler.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
bean5 "github.com/devtron-labs/devtron/pkg/cluster/bean"
3232
"github.com/devtron-labs/devtron/pkg/cluster/environment"
3333
repository2 "github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
34+
adapter2 "github.com/devtron-labs/devtron/pkg/pipeline/adapter"
3435
util3 "github.com/devtron-labs/devtron/pkg/pipeline/util"
3536
"io/ioutil"
3637
"net/http"
@@ -571,6 +572,7 @@ func (impl *CiHandlerImpl) GetBuildHistory(pipelineId int, appId int, offset int
571572
EnvironmentName: w.EnvironmentName,
572573
ReferenceWorkflowId: w.RefCiWorkflowId,
573574
PodName: w.PodName,
575+
TargetPlatforms: adapter2.GetTargetPlatformObjectFromString(w.TargetPlatforms),
574576
}
575577

576578
if w.Message == bean3.ImageTagUnavailableMessage {
@@ -1597,6 +1599,7 @@ func (impl *CiHandlerImpl) FetchMaterialInfoByArtifactId(ciArtifactId int, envId
15971599
Default: deployDetail.Default,
15981600
ImageTaggingData: *imageTaggingData,
15991601
Image: ciArtifact.Image,
1602+
TargetPlatforms: adapter2.GetTargetPlatformObjectFromString(ciArtifact.TargetPlatforms),
16001603
}
16011604
return gitTriggerInfoResponse, nil
16021605
}

pkg/pipeline/adapter/adapter.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ 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"
3031
"time"
3132
)
3233

@@ -377,4 +378,17 @@ func GetStepVariableDto(variable *repository.PipelineStageStepVariable) (*pipeli
377378
VariableStepIndexInPlugin: variable.VariableStepIndexInPlugin,
378379
}
379380
return variableDto, nil
380-
}
381+
}
382+
383+
func GetTargetPlatformObjectFromString(targetPlatform string) []pipelineConfigBean.TargetPlatform {
384+
targetPlatforms := GetTargetPlatformListFromString(targetPlatform)
385+
var targetPlatformObject []pipelineConfigBean.TargetPlatform
386+
for _, targetPlatform := range targetPlatforms {
387+
targetPlatformObject = append(targetPlatformObject, pipelineConfigBean.TargetPlatform{Name: targetPlatform})
388+
}
389+
return targetPlatformObject
390+
}
391+
392+
func GetTargetPlatformListFromString(targetPlatform string) []string {
393+
return strings.Split(targetPlatform, ",")
394+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package bean
2+
3+
type TargetPlatform struct {
4+
Name string `json:"name"`
5+
}

0 commit comments

Comments
 (0)