Skip to content

Commit

Permalink
feat: acr polling plugin support (#5724)
Browse files Browse the repository at this point in the history
* migration number changes (#5692)

* refrain from checkin autoscalingCheckBeforeTrigger for virt clus (#5696)

* fix: Decode secret fix on add update oss (#5695)

* ValidateEncodedDataByDecoding in case add or update secret

* wire fix from main

* minor refactor

* comment

* saving pco concurrency case handled (#5688)

* fix: script for pipelineStageStepVariable, making input value and default_value text from varchar255 (#5701)

* script for pipelineStageStepVariable, making input value and default_value text from varchar255

* erro log fix

* fix: ea fixes for helm app (#5708)

* added the ea apps entry app table

* resolved the ea mode multiple rows error during configuration of app

* modified the ea dockerfile in ca-certificates cmd

* uncommented the code and left the ea helm app making way untouched

* remodified the dockerfile as previous state

* modified the docker file ea mode

* dockerfile exit code 100 due to ap install alternative in ea mode dockerfile

* execute make after main merge

* modified changes in dockerfile ea mode

* resolved comments after first level review

* Revert "fix: ea fixes for helm app (#5708)" (#5713)

This reverts commit 3e31f49.

* fix: SkipCiBuildCachePushPull code incorporated with minor refac in handle runtime params validation (#5712)

* SkipCiBuildCachePushPull code incorporated with minor refac in handle runtime params validation

* minor refactor

* minor refactor

* chore: polling plugin refactored

* chore: refactored method name

* update polling plugin response struct

* updated migration number

* updated polling plugin image

* updated polling plugin migration script

* fix: same digest for different image issue

* fix: plugin migration handling

* updated polling plugin migration script

* updated migration number

* fix: empty artifact issue

* chore: polling plugin migration prod-image updated

* updated common-lib version

---------

Co-authored-by: Prakash <prakash.kumar@devtron.ai>
Co-authored-by: Rajeev Ranjan <90333766+RajeevRanjan27@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 5, 2024
1 parent 813c3d7 commit d4e599e
Show file tree
Hide file tree
Showing 40 changed files with 220 additions and 3,608 deletions.
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ require (
github.com/argoproj/argo-workflows/v3 v3.5.10
github.com/argoproj/gitops-engine v0.7.1-0.20231013183858-f15cf615b814
github.com/aws/aws-sdk-go v1.44.290
github.com/aws/aws-sdk-go-v2/service/ecr v1.20.0
github.com/caarlos0/env v3.5.0+incompatible
github.com/caarlos0/env/v6 v6.7.2
github.com/casbin/casbin v1.9.1
Expand All @@ -22,7 +21,7 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/deckarep/golang-set v1.8.0
github.com/devtron-labs/authenticator v0.4.35-0.20240809073103-6e11da8083f8
github.com/devtron-labs/common-lib v0.16.1-0.20240903114838-d814f4cd60ca
github.com/devtron-labs/common-lib v0.16.1-0.20240904131140-b4128b676f6c
github.com/devtron-labs/go-bitbucket v0.9.60-beta
github.com/devtron-labs/protos v0.0.3-0.20240802105333-92ee9bb85d80
github.com/evanphx/json-patch v5.7.0+incompatible
Expand Down Expand Up @@ -122,7 +121,6 @@ require (
github.com/apparentlymart/go-textseg v1.0.0 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/argoproj/pkg v0.13.7-0.20230627120311-a4dd357b057e // indirect
github.com/aws/smithy-go v1.14.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.6.0 // indirect
Expand Down
11 changes: 2 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,6 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkY
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/aws/aws-sdk-go v1.44.290 h1:Md4+os9DQtJjow0lWLMzeJljsimD+XS2xwwHDr5Z+Lk=
github.com/aws/aws-sdk-go v1.44.290/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw=
github.com/aws/aws-sdk-go-v2/service/ecr v1.20.0 h1:Qw8H7V55d2P1d/a9+cLgAcdez4GtP6l30KQAeYqx9vY=
github.com/aws/aws-sdk-go-v2/service/ecr v1.20.0/go.mod h1:pGwmNL8hN0jpBfKfTbmu+Rl0bJkDhaGl+9PQLrZ4KLo=
github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ=
github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down Expand Up @@ -187,8 +180,8 @@ github.com/devtron-labs/argo-workflows/v3 v3.5.10 h1:6rxQOesOzDz6SgQCMDQNHaehsKF
github.com/devtron-labs/argo-workflows/v3 v3.5.10/go.mod h1:/vqxcovDPT4zqr4DjR5v7CF8ggpY1l3TSa2CIG3jmjA=
github.com/devtron-labs/authenticator v0.4.35-0.20240809073103-6e11da8083f8 h1:2+Q7Jdhpo/uMiaQiZZzAh+ZX7wEJIFuMFG6DEiMuo64=
github.com/devtron-labs/authenticator v0.4.35-0.20240809073103-6e11da8083f8/go.mod h1:702R6WIf5y9UzKGoCGxQ+x3l5Ws+l0fXg2xlCpSGFZI=
github.com/devtron-labs/common-lib v0.16.1-0.20240903114838-d814f4cd60ca h1:cS0cK+aAsMZ9GNcNK3mp9Bej5X/3cRmD/tDLc9/P1GM=
github.com/devtron-labs/common-lib v0.16.1-0.20240903114838-d814f4cd60ca/go.mod h1:a7aCClaxYfnyYEENSe1RnkQCeW2AwmCAPYsuvgk0aW0=
github.com/devtron-labs/common-lib v0.16.1-0.20240904131140-b4128b676f6c h1:uF5rx/rvfSddPtJ0YzEjlbu+zBa+MqfmABOy6GYBlWM=
github.com/devtron-labs/common-lib v0.16.1-0.20240904131140-b4128b676f6c/go.mod h1:a7aCClaxYfnyYEENSe1RnkQCeW2AwmCAPYsuvgk0aW0=
github.com/devtron-labs/go-bitbucket v0.9.60-beta h1:VEx1jvDgdtDPS6A1uUFoaEi0l1/oLhbr+90xOwr6sDU=
github.com/devtron-labs/go-bitbucket v0.9.60-beta/go.mod h1:GnuiCesvh8xyHeMCb+twm8lBR/kQzJYSKL28ZfObp1Y=
github.com/devtron-labs/protos v0.0.3-0.20240802105333-92ee9bb85d80 h1:xwbTeijNTf4/j1v+tSfwVqwLVnReas/NqEKeQHvSTys=
Expand Down
31 changes: 24 additions & 7 deletions pkg/eventProcessor/bean/workflowEventBean.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ package bean

import (
"context"
"github.com/aws/aws-sdk-go-v2/service/ecr/types"
"encoding/json"
"github.com/devtron-labs/common-lib/utils/registry"
"github.com/devtron-labs/devtron/api/bean"
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
bean3 "github.com/devtron-labs/devtron/pkg/pipeline/bean"
Expand Down Expand Up @@ -62,11 +63,6 @@ func (r *UserDeploymentRequest) WithPipelineOverrideId(id int) *UserDeploymentRe
return r
}

type ImageDetailsFromCR struct {
ImageDetails []types.ImageDetail `json:"imageDetails"`
Region string `json:"region"`
}

type CiCompleteEvent struct {
CiProjectDetails []bean3.CiProjectDetails `json:"ciProjectDetails"`
DockerImage string `json:"dockerImage" validate:"required,image-validator"`
Expand All @@ -81,9 +77,30 @@ type CiCompleteEvent struct {
AppName string `json:"appName"`
IsArtifactUploaded bool `json:"isArtifactUploaded"`
FailureReason string `json:"failureReason"`
ImageDetailsFromCR *ImageDetailsFromCR `json:"imageDetailsFromCR"`
ImageDetailsFromCR json.RawMessage `json:"imageDetailsFromCR"`
PluginRegistryArtifactDetails map[string][]string `json:"PluginRegistryArtifactDetails"`
PluginArtifactStage string `json:"pluginArtifactStage"`
pluginImageDetails *registry.ImageDetailsFromCR
}

func (c *CiCompleteEvent) GetPluginImageDetails() *registry.ImageDetailsFromCR {
if c == nil {
return nil
}
return c.pluginImageDetails
}

func (c *CiCompleteEvent) SetImageDetailsFromCR() error {
if c.ImageDetailsFromCR == nil {
return nil
}
var imageDetailsFromCR *registry.ImageDetailsFromCR
err := json.Unmarshal(c.ImageDetailsFromCR, &imageDetailsFromCR)
if err != nil {
return err
}
c.pluginImageDetails = imageDetailsFromCR
return nil
}

type DevtronAppReleaseContextType struct {
Expand Down
44 changes: 28 additions & 16 deletions pkg/eventProcessor/in/WorkflowEventProcessorService.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"errors"
"fmt"
"github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/aws/aws-sdk-go-v2/service/ecr/types"
pubsub "github.com/devtron-labs/common-lib/pubsub-lib"
"github.com/devtron-labs/common-lib/pubsub-lib/model"
"github.com/devtron-labs/common-lib/utils/registry"
apiBean "github.com/devtron-labs/devtron/api/bean"
client "github.com/devtron-labs/devtron/client/events"
"github.com/devtron-labs/devtron/internal/sql/models"
Expand Down Expand Up @@ -474,12 +474,25 @@ func (impl *WorkflowEventProcessorImpl) SubscribeCDWorkflowStatusUpdate() error
return nil
}

func (impl *WorkflowEventProcessorImpl) extractCiCompleteEventFrom(msg *model.PubSubMsg) (bean.CiCompleteEvent, error) {
ciCompleteEvent := bean.CiCompleteEvent{}
err := json.Unmarshal([]byte(msg.Data), &ciCompleteEvent)
if err != nil {
impl.logger.Error("error while unmarshalling json data", "error", err)
return ciCompleteEvent, err
}
err = ciCompleteEvent.SetImageDetailsFromCR()
if err != nil {
impl.logger.Error("error in unmarshalling imageDetailsFromCr results", "error", err)
return ciCompleteEvent, err
}
return ciCompleteEvent, nil
}

func (impl *WorkflowEventProcessorImpl) SubscribeCICompleteEvent() error {
callback := func(msg *model.PubSubMsg) {
ciCompleteEvent := bean.CiCompleteEvent{}
err := json.Unmarshal([]byte(msg.Data), &ciCompleteEvent)
ciCompleteEvent, err := impl.extractCiCompleteEventFrom(msg)
if err != nil {
impl.logger.Error("error while unmarshalling json data", "error", err)
return
}
impl.logger.Debugw("ci complete event for ci", "ciPipelineId", ciCompleteEvent.PipelineId)
Expand All @@ -501,34 +514,33 @@ func (impl *WorkflowEventProcessorImpl) SubscribeCICompleteEvent() error {
ciCompleteEvent.PipelineId, "request: ", req, "error: ", err)
return
}
} else if ciCompleteEvent.ImageDetailsFromCR != nil {
if len(ciCompleteEvent.ImageDetailsFromCR.ImageDetails) > 0 {
imageDetails := globalUtil.GetReverseSortedImageDetails(ciCompleteEvent.ImageDetailsFromCR.ImageDetails)
} else if ciCompleteEvent.GetPluginImageDetails() != nil {
if len(ciCompleteEvent.GetPluginImageDetails().ImageDetails) > 0 {
imageDetails := registry.SortGenericImageDetailByCreatedOn(ciCompleteEvent.GetPluginImageDetails().ImageDetails, registry.Ascending)
digestWorkflowMap, err := impl.webhookService.HandleMultipleImagesFromEvent(imageDetails, *ciCompleteEvent.WorkflowId)
if err != nil {
impl.logger.Errorw("error in getting digest workflow map", "err", err, "workflowId", ciCompleteEvent.WorkflowId)
return
}
for _, detail := range imageDetails {
if detail.ImageTags == nil {
if detail == nil || len(detail.Image) == 0 {
continue
}
request, err := impl.BuildCIArtifactRequestForImageFromCR(detail, ciCompleteEvent.ImageDetailsFromCR.Region, ciCompleteEvent, digestWorkflowMap[*detail.ImageDigest].Id)
request, err := impl.buildCIArtifactRequestForImageFromCR(detail, ciCompleteEvent, digestWorkflowMap[detail.GetGenericImageDetailIdentifier()].Id)
if err != nil {
impl.logger.Error("Error while creating request for pipelineID", "pipelineId", ciCompleteEvent.PipelineId, "err", err)
return
}
resp, err := impl.ValidateAndHandleCiSuccessEvent(triggerContext, ciCompleteEvent.PipelineId, request, detail.ImagePushedAt)
resp, err := impl.ValidateAndHandleCiSuccessEvent(triggerContext, ciCompleteEvent.PipelineId, request, detail.LastUpdatedOn)
if err != nil {
return
}
impl.logger.Debug("response of handle ci success event for multiple images from plugin", "resp", resp)
}
}

} else {
globalUtil.TriggerCIMetrics(ciCompleteEvent.Metrics, impl.globalEnvVariables.ExposeCiMetrics, ciCompleteEvent.PipelineName, ciCompleteEvent.AppName)
resp, err := impl.ValidateAndHandleCiSuccessEvent(triggerContext, ciCompleteEvent.PipelineId, req, &time.Time{})
resp, err := impl.ValidateAndHandleCiSuccessEvent(triggerContext, ciCompleteEvent.PipelineId, req, time.Time{})
if err != nil {
return
}
Expand All @@ -555,7 +567,7 @@ func (impl *WorkflowEventProcessorImpl) SubscribeCICompleteEvent() error {
return nil
}

func (impl *WorkflowEventProcessorImpl) ValidateAndHandleCiSuccessEvent(triggerContext triggerBean.TriggerContext, ciPipelineId int, request *wrokflowDagBean.CiArtifactWebhookRequest, imagePushedAt *time.Time) (int, error) {
func (impl *WorkflowEventProcessorImpl) ValidateAndHandleCiSuccessEvent(triggerContext triggerBean.TriggerContext, ciPipelineId int, request *wrokflowDagBean.CiArtifactWebhookRequest, imagePushedAt time.Time) (int, error) {
validationErr := impl.validator.Struct(request)
if validationErr != nil {
impl.logger.Errorw("validation err, HandleCiSuccessEvent", "err", validationErr, "payload", request)
Expand Down Expand Up @@ -643,13 +655,13 @@ func (impl *WorkflowEventProcessorImpl) BuildCiArtifactRequest(event bean.CiComp
return request, nil
}

func (impl *WorkflowEventProcessorImpl) BuildCIArtifactRequestForImageFromCR(imageDetails types.ImageDetail, region string, event bean.CiCompleteEvent, workflowId int) (*wrokflowDagBean.CiArtifactWebhookRequest, error) {
func (impl *WorkflowEventProcessorImpl) buildCIArtifactRequestForImageFromCR(imageDetails *registry.GenericImageDetail, event bean.CiCompleteEvent, workflowId int) (*wrokflowDagBean.CiArtifactWebhookRequest, error) {
if event.TriggeredBy == 0 {
event.TriggeredBy = 1 // system triggered event
}
request := &wrokflowDagBean.CiArtifactWebhookRequest{
Image: globalUtil.ExtractEcrImage(*imageDetails.RegistryId, region, *imageDetails.RepositoryName, imageDetails.ImageTags[0]),
ImageDigest: *imageDetails.ImageDigest,
Image: imageDetails.Image,
ImageDigest: imageDetails.ImageDigest,
DataSource: event.DataSource,
PipelineName: event.PipelineName,
UserId: event.TriggeredBy,
Expand Down
16 changes: 6 additions & 10 deletions pkg/pipeline/WebhookService.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"encoding/json"
"fmt"
"github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/aws/aws-sdk-go-v2/service/ecr/types"
pubsub "github.com/devtron-labs/common-lib/pubsub-lib"
"github.com/devtron-labs/common-lib/utils/registry"
"github.com/devtron-labs/devtron/internal/sql/repository"
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
"github.com/devtron-labs/devtron/pkg/pipeline/bean"
Expand Down Expand Up @@ -50,14 +50,10 @@ type ExternalCiWebhookDto struct {
AppName string `json:"appName"`
IsArtifactUploaded bool `json:"isArtifactUploaded"`
FailureReason string `json:"failureReason"`
ImageDetailsFromCR *ImageDetailsFromCR `json:"imageDetailsFromCR"`
ImageDetailsFromCR json.RawMessage `json:"imageDetailsFromCR"`
PluginRegistryArtifactDetails map[string][]string `json:"PluginRegistryArtifactDetails"`
PluginArtifactStage string `json:"pluginArtifactStage"`
}
type ImageDetailsFromCR struct {
ImageDetails []types.ImageDetail `json:"imageDetails"`
Region string `json:"region"`
}

type CiArtifactWebhookRequest struct {
Image string `json:"image" validate:"required"`
Expand All @@ -75,7 +71,7 @@ type CiArtifactWebhookRequest struct {

type WebhookService interface {
AuthenticateExternalCiWebhook(apiKey string) (int, error)
HandleMultipleImagesFromEvent(imageDetails []types.ImageDetail, ciWorkflowId int) (map[string]*pipelineConfig.CiWorkflow, error)
HandleMultipleImagesFromEvent(imageDetails []*registry.GenericImageDetail, ciWorkflowId int) (map[string]*pipelineConfig.CiWorkflow, error)
GetTriggerValidateFuncs() []pubsub.ValidateMsg
}

Expand Down Expand Up @@ -136,7 +132,7 @@ func (impl WebhookServiceImpl) AuthenticateExternalCiWebhook(apiKey string) (int
}

// HandleMultipleImagesFromEvent handles multiple images from plugin and creates ci workflow for n-1 images for mapping in ci_artifact
func (impl *WebhookServiceImpl) HandleMultipleImagesFromEvent(imageDetails []types.ImageDetail, ciWorkflowId int) (map[string]*pipelineConfig.CiWorkflow, error) {
func (impl *WebhookServiceImpl) HandleMultipleImagesFromEvent(imageDetails []*registry.GenericImageDetail, ciWorkflowId int) (map[string]*pipelineConfig.CiWorkflow, error) {
ciWorkflow, err := impl.ciWorkflowRepository.FindById(ciWorkflowId)
if err != nil {
impl.logger.Errorw("error in finding ci workflow by id ", "err", err, "ciWorkFlowId", ciWorkflowId)
Expand All @@ -146,7 +142,7 @@ func (impl *WebhookServiceImpl) HandleMultipleImagesFromEvent(imageDetails []typ
// creating n-1 workflows for rest images, oldest will be mapped to original workflow id.
digestWorkflowMap := make(map[string]*pipelineConfig.CiWorkflow)
// mapping oldest to original ciworkflowId
digestWorkflowMap[*imageDetails[0].ImageDigest] = ciWorkflow
digestWorkflowMap[imageDetails[0].GetGenericImageDetailIdentifier()] = ciWorkflow
for i := 1; i < len(imageDetails); i++ {
workflow := &pipelineConfig.CiWorkflow{
Name: ciWorkflow.Name + fmt.Sprintf("-child-%d", i),
Expand All @@ -170,7 +166,7 @@ func (impl *WebhookServiceImpl) HandleMultipleImagesFromEvent(imageDetails []typ
impl.logger.Errorw("error in saving workflow for child workflow", "err", err, "parentCiWorkflowId", ciWorkflowId)
return nil, err
}
digestWorkflowMap[*imageDetails[i].ImageDigest] = workflow
digestWorkflowMap[imageDetails[i].GetGenericImageDetailIdentifier()] = workflow

}
return digestWorkflowMap, nil
Expand Down
6 changes: 3 additions & 3 deletions pkg/workflow/dag/WorkflowDagExecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import (
)

type WorkflowDagExecutor interface {
HandleCiSuccessEvent(triggerContext triggerBean.TriggerContext, ciPipelineId int, request *bean2.CiArtifactWebhookRequest, imagePushedAt *time.Time) (id int, err error)
HandleCiSuccessEvent(triggerContext triggerBean.TriggerContext, ciPipelineId int, request *bean2.CiArtifactWebhookRequest, imagePushedAt time.Time) (id int, err error)
HandlePreStageSuccessEvent(triggerContext triggerBean.TriggerContext, cdStageCompleteEvent eventProcessorBean.CdStageCompleteEvent) error
HandleDeploymentSuccessEvent(triggerContext triggerBean.TriggerContext, pipelineOverride *chartConfig.PipelineOverride) error
HandlePostStageSuccessEvent(triggerContext triggerBean.TriggerContext, cdWorkflowId int, cdPipelineId int, triggeredBy int32, pluginRegistryImageDetails map[string][]string) error
Expand Down Expand Up @@ -687,7 +687,7 @@ func (impl *WorkflowDagExecutorImpl) HandlePostStageSuccessEvent(triggerContext
return nil
}

func (impl *WorkflowDagExecutorImpl) HandleCiSuccessEvent(triggerContext triggerBean.TriggerContext, ciPipelineId int, request *bean2.CiArtifactWebhookRequest, imagePushedAt *time.Time) (id int, err error) {
func (impl *WorkflowDagExecutorImpl) HandleCiSuccessEvent(triggerContext triggerBean.TriggerContext, ciPipelineId int, request *bean2.CiArtifactWebhookRequest, imagePushedAt time.Time) (id int, err error) {
impl.logger.Infow("webhook for artifact save", "req", request)
if request.WorkflowId != nil {
savedWorkflow, err := impl.ciWorkflowRepository.FindById(*request.WorkflowId)
Expand Down Expand Up @@ -730,7 +730,7 @@ func (impl *WorkflowDagExecutorImpl) HandleCiSuccessEvent(triggerContext trigger
createdOn := time.Now()
updatedOn := time.Now()
if !imagePushedAt.IsZero() {
createdOn = *imagePushedAt
createdOn = imagePushedAt
}
buildArtifact := &repository.CiArtifact{
Image: request.Image,
Expand Down
5 changes: 5 additions & 0 deletions scripts/sql/284_polling_plugin_v2.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- revert the container image path of the polling plugin version 1.0.0
UPDATE plugin_pipeline_script
SET container_image_path ='quay.io/devtron/poll-container-image:97a996a5-545-16654'
WHERE container_image_path ='quay.io/devtron/devtron-plugins:polling-plugin-v1.0.1'
AND deleted = false;
30 changes: 30 additions & 0 deletions scripts/sql/284_polling_plugin_v2.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- update the container image path for the polling plugin version 1.0.0
UPDATE plugin_pipeline_script
SET container_image_path ='quay.io/devtron/devtron-plugins:polling-plugin-v1.0.1'
WHERE container_image_path ='quay.io/devtron/poll-container-image:97a996a5-545-16654'
AND deleted = false;

-- create plugin_parent_metadata for the polling plugin, if not exists
INSERT INTO "plugin_parent_metadata" ("id", "name", "identifier", "description", "type", "icon", "deleted", "created_on", "created_by", "updated_on", "updated_by")
SELECT nextval('id_seq_plugin_parent_metadata'), 'Pull images from container repository','pull-images-from-container-repository','Polls a container repository and pulls images stored in the repository which can be used for deployment.','PRESET','https://raw.githubusercontent.com/devtron-labs/devtron/main/assets/plugin-poll-container-registry.png','f', 'now()', 1, 'now()', 1
WHERE NOT EXISTS (
SELECT 1
FROM plugin_parent_metadata
WHERE identifier='pull-images-from-container-repository'
AND deleted = false
);

-- update the plugin_metadata with the plugin_parent_metadata_id
UPDATE plugin_metadata
SET plugin_parent_metadata_id = (
SELECT id
FROM plugin_parent_metadata
WHERE identifier='pull-images-from-container-repository'
AND deleted = false
)
WHERE name='Pull images from container repository'
AND (
plugin_parent_metadata_id IS NULL
OR plugin_parent_metadata_id = 0
)
AND deleted = false;
Loading

0 comments on commit d4e599e

Please sign in to comment.