Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* fix: upgrade @loadable/component from 5.14.1 to 5.16.4 (#5000)

Snyk has created this PR to upgrade @loadable/component from 5.14.1 to 5.16.4.

See this package in yarn:
@loadable/component

See this project in Snyk:
https://app.snyk.io/org/pipecd/project/f41c5767-b506-4f59-beb9-ef662258eb9a?utm_source=github&utm_medium=referral&page=upgrade-pr

Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com>
Co-authored-by: snyk-bot <snyk-bot@snyk.io>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* fix: upgrade @reduxjs/toolkit from 1.8.5 to 1.9.7 (#4999)

Snyk has created this PR to upgrade @reduxjs/toolkit from 1.8.5 to 1.9.7.

See this package in yarn:
@reduxjs/toolkit

See this project in Snyk:
https://app.snyk.io/org/pipecd/project/f41c5767-b506-4f59-beb9-ef662258eb9a?utm_source=github&utm_medium=referral&page=upgrade-pr

Co-authored-by: snyk-bot <snyk-bot@snyk.io>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* fix: upgrade react-router-dom from 5.2.0 to 5.3.4 (#5001)

Snyk has created this PR to upgrade react-router-dom from 5.2.0 to 5.3.4.

See this package in yarn:
react-router-dom

See this project in Snyk:
https://app.snyk.io/org/pipecd/project/f41c5767-b506-4f59-beb9-ef662258eb9a?utm_source=github&utm_medium=referral&page=upgrade-pr

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Co-authored-by: snyk-bot <snyk-bot@snyk.io>
Co-authored-by: Tetsuya Kikuchi <97105818+t-kikuc@users.noreply.github.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* fix: upgrade grpc-web from 1.0.7 to 1.5.0 (#4984)

Snyk has created this PR to upgrade grpc-web from 1.0.7 to 1.5.0.

See this package in yarn:
grpc-web

See this project in Snyk:
https://app.snyk.io/org/pipecd/project/f41c5767-b506-4f59-beb9-ef662258eb9a?utm_source=github&utm_medium=referral&page=upgrade-pr

Co-authored-by: snyk-bot <snyk-bot@snyk.io>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* [Snyk] Security upgrade alpine from 3.17 to 3.20 (#5014)

* fix: docs/Dockerfile to reduce vulnerabilities

The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-ALPINE317-OPENSSL-7413590
- https://snyk.io/vuln/SNYK-ALPINE317-OPENSSL-7413590
- https://snyk.io/vuln/SNYK-ALPINE317-OPENSSL-7413591
- https://snyk.io/vuln/SNYK-ALPINE317-OPENSSL-7413591

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>

* Bump alpine

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>

---------

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Co-authored-by: snyk-bot <snyk-bot@snyk.io>
Co-authored-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Upgrade google-cloud-sdk (#5042)

* Use x86_64 version of google-cloud-sdk

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>

* Upgrade google-cloud-sdk

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>

---------

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* feat: add support mention slack groups for NotificationReceiverSlack and NotificationMention (#4903)

* feat: add support mentione groups for NotifactionReceiverSlack and slackGroups for NotificationMention

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* remove change in docs v0.47.x

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* update docs

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* update logic for having getGroupsAsString()

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* using <!subteam^ID> for group mentioning

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* typo

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* call both getAccountsAsString and getGroupsAsString

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* revert change pkg/model/notificationevent.pb.go

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* use same format for group <!subteam^ID>

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* same method to format slack group

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* following slack api, !subteam^ is a literal string that should not change

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* feat: add slackUsers field and mark slack as deprecated field

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* revert pkg/model/notificationevent.pb.go

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* update doc Using the groupID or teamID in the documents makes it easier for users to use this feature.

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* add code gen

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* adjust mention users and slack logic

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

* unify the process to get users and groups in the same method

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>

---------

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Ignore `desiredCount` of ECS when it's 0 or not set for AutoScaling (#5030)

* add a flag: ignoreDesiredCountOnUpdate

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* ignore desiredCount on updateService if needed

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Add a flag ignoreDesiredCountOnUpdate into each func

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Format func params and comment

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* add docs

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* fix tests: add a missing attribute

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* recover desiredCount in CreateService (mistake)

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* add mentioning driftdetection

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Revert changes of adding ignoreDesiredCountOnUpdate

This reverts commit a0f3459.

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Revert commits of adding ignoreDesiredCount"

This reverts commit 7d65824.

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Revert "add docs"

This reverts commit dcd7dc9.

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Revert "Format func params and comment"

This reverts commit 5103158.

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Revert "Add a flag ignoreDesiredCountOnUpdate into each func"

This reverts commit d17a9b7.

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Revert "ignore desiredCount on updateService if needed"

This reverts commit cf3efbf.

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Revert "add a flag: ignoreDesiredCountOnUpdate"

This reverts commit 6b2af75.

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* ignore updating desiredCount if it's 0 or not defined

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Use pruning when 'recreate' is on

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* add docs

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* refine docs

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Clarify procedure of configuring

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

---------

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

---------

Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>
Co-authored-by: Khanh Tran <32532742+khanhtc1202@users.noreply.github.com>
Co-authored-by: snyk-bot <snyk-bot@snyk.io>
Co-authored-by: Chris Aniszczyk <caniszczyk@gmail.com>
Co-authored-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Co-authored-by: Henry Vu <26101787+hungran@users.noreply.github.com>
  • Loading branch information
6 people authored Jul 18, 2024
1 parent 6439f97 commit 84db6a6
Show file tree
Hide file tree
Showing 37 changed files with 1,418 additions and 383 deletions.
2 changes: 1 addition & 1 deletion cmd/helloworld/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.15
FROM alpine:3.20

ADD .artifacts/helloworld /usr/local/bin/helloworld

Expand Down
10 changes: 5 additions & 5 deletions cmd/pipecd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
FROM alpine:3.13
FROM alpine:3.20

ARG GOOGLE_CLOUD_SDK_VERSION=324.0.0
ARG GOOGLE_CLOUD_SDK_VERSION=477.0.0

RUN \
apk add --no-cache \
python3 \
curl && \
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-x86.tar.gz && \
tar -zxvf ./google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-x86.tar.gz && \
rm ./google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-x86.tar.gz && \
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-x86_64.tar.gz && \
tar -zxvf ./google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-x86_64.tar.gz && \
rm ./google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-x86_64.tar.gz && \
./google-cloud-sdk/install.sh --quiet

ENV PATH="/google-cloud-sdk/bin:${PATH}"
Expand Down
2 changes: 1 addition & 1 deletion cmd/pipectl/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.13
FROM alpine:3.20

RUN apk add --no-cache git

Expand Down
2 changes: 1 addition & 1 deletion docs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM golang:1.22.4-alpine3.20 AS builder
COPY main.go .
RUN go build -o /server main.go

FROM alpine:3.17
FROM alpine:3.20
RUN apk --no-cache add ca-certificates

COPY --from=builder /server ./
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ One of `yamlField` or `regex` is required.
| Field | Type | Description | Required |
|-|-|-|-|
| event | string | The event to be notified to users. | Yes |
| slack | []string | List of user IDs for mentioning in Slack. See [here](https://api.slack.com/reference/surfaces/formatting#mentioning-users) for more information on how to check them. | No |
| slack | []string | Deprecated: Please use `slackUsers` instead. List of user IDs for mentioning in Slack. See [here](https://api.slack.com/reference/surfaces/formatting#mentioning-users) for more information on how to check them. | No |
| slackUsers | []string | List of user IDs for mentioning in Slack. See [here](https://api.slack.com/reference/surfaces/formatting#mentioning-users) for more information on how to check them. | No |
| slackGroups | []string | List of group IDs for mentioning in Slack. See [here](https://api.slack.com/reference/surfaces/formatting#mentioning-groups) for more information on how to check them. | No |

## KubernetesDeploymentInput

Expand Down Expand Up @@ -516,6 +518,8 @@ One of `yamlField` or `regex` is required.

There are some restrictions in configuring a service definition file.

- As long as `desiredCount` is 0 or not set, `desiredCount` of your service will NOT be updated in deployments.
- If `desiredCount` is 0 or not set for a new service, the service's `desiredCount` will be 0.
- `capacityProviderStrategy` is not supported.
- `clientToken` is not supported.
- `deploymentController` is required and must be `EXTERNAL`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ spec:
- When you use an ELB for deployments, all listener rules that have the same target groups as configured in app.pipecd.yaml will be controlled.
- For more information and diagrams, see [Issue#4733 [ECS] Modify ELB listener rules other than defaults without adding config](https://github.com/pipe-cd/pipecd/pull/4733).
- When you use [Service Connect](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-connect.html), you cannot use Canary or Blue/Green deployment yet because Service Connect does not support the external deployment yet.
- When you use AutoScaling for a service, you can disable reconciling `desiredCount` by following steps.
1. Create a service without defining `desiredCount` in the service definition file. See [Restrictions of Service Definition](../../../configuration-reference/#restrictions-of-service-definition).
2. Configure AutoScaling by yourself.

## Reference

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ Must be one of the following structs:
| oauthTokenFile | string | The path to the oautoken file | No |
| channelID | string | The channel id which slack api send to. | No |
| mentionedAccounts | []string | The accounts to which slack api referes. This field supports both `@username` and `username` writing styles.| No |
| mentionedGroups | []string | The groups to which slack api referes. This field supports both `<!subteam^groupname>` and `groupname` writing styles.| No |

#### NotificationReceiverWebhook

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@ spec:
mentionedAccounts:
- '@user1'
- 'user2'
- name: integration-slack-api-with-oauthTokenData-and-mentioned-groups
slack:
oauthTokenData: token
channelID: testid
mentionedGroups:
- 'group1'
- '<!subteam^group2>'
- name: integration-slack-api-with-oauthTokenData-and-mentioned-both-accounts-and-groups
slack:
oauthTokenData: token
channelID: testid
mentionedAccounts:
- 'user1'
- '@user2'
mentionedGroups:
- 'groupID1'
- '<!subteam^groupID2>'
```
Expand Down
4 changes: 2 additions & 2 deletions manifests/pipecd/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ spec:
{{- if .Values.quickstart.enabled }}
initContainers:
- name: dep-waiter
image: alpine:3.14
image: alpine:3.20
command: ["sh", "-c"]
args:
- |
Expand Down Expand Up @@ -259,7 +259,7 @@ spec:
{{- if .Values.quickstart.enabled }}
initContainers:
- name: dep-waiter
image: alpine:3.14
image: alpine:3.20
command: ["sh", "-c"]
args:
- |
Expand Down
31 changes: 16 additions & 15 deletions pkg/app/piped/controller/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,16 @@ func (p *planner) reportDeploymentPlanned(ctx context.Context, out pln.Output) e
}
)

accounts, err := p.getMentionedAccounts(model.NotificationEventType_EVENT_DEPLOYMENT_PLANNED)
if err != nil {
p.logger.Error("failed to get the list of accounts", zap.Error(err))
}
users, groups, err := p.getApplicationNotificationMentions(model.NotificationEventType_EVENT_DEPLOYMENT_PLANNED)

defer func() {
p.notifier.Notify(model.NotificationEvent{
Type: model.NotificationEventType_EVENT_DEPLOYMENT_PLANNED,
Metadata: &model.NotificationEventDeploymentPlanned{
Deployment: p.deployment,
Summary: out.Summary,
MentionedAccounts: accounts,
MentionedAccounts: users,
MentionedGroups: groups,
},
})
}()
Expand Down Expand Up @@ -285,9 +283,9 @@ func (p *planner) reportDeploymentFailed(ctx context.Context, reason string) err
retry = pipedservice.NewRetry(10)
)

accounts, err := p.getMentionedAccounts(model.NotificationEventType_EVENT_DEPLOYMENT_FAILED)
users, groups, err := p.getApplicationNotificationMentions(model.NotificationEventType_EVENT_DEPLOYMENT_FAILED)
if err != nil {
p.logger.Error("failed to get the list of accounts", zap.Error(err))
p.logger.Error("failed to get the list of users or groups", zap.Error(err))
}

defer func() {
Expand All @@ -296,7 +294,8 @@ func (p *planner) reportDeploymentFailed(ctx context.Context, reason string) err
Metadata: &model.NotificationEventDeploymentFailed{
Deployment: p.deployment,
Reason: reason,
MentionedAccounts: accounts,
MentionedAccounts: users,
MentionedGroups: groups,
},
})
}()
Expand Down Expand Up @@ -330,9 +329,9 @@ func (p *planner) reportDeploymentCancelled(ctx context.Context, commander, reas
retry = pipedservice.NewRetry(10)
)

accounts, err := p.getMentionedAccounts(model.NotificationEventType_EVENT_DEPLOYMENT_CANCELLED)
users, groups, err := p.getApplicationNotificationMentions(model.NotificationEventType_EVENT_DEPLOYMENT_CANCELLED)
if err != nil {
p.logger.Error("failed to get the list of accounts", zap.Error(err))
p.logger.Error("failed to get the list of users or groups", zap.Error(err))
}

defer func() {
Expand All @@ -341,7 +340,8 @@ func (p *planner) reportDeploymentCancelled(ctx context.Context, commander, reas
Metadata: &model.NotificationEventDeploymentCancelled{
Deployment: p.deployment,
Commander: commander,
MentionedAccounts: accounts,
MentionedAccounts: users,
MentionedGroups: groups,
},
})
}()
Expand All @@ -359,16 +359,17 @@ func (p *planner) reportDeploymentCancelled(ctx context.Context, commander, reas
return err
}

func (p *planner) getMentionedAccounts(event model.NotificationEventType) ([]string, error) {
// getApplicationNotificationMentions returns the list of users groups who should be mentioned in the notification.
func (p *planner) getApplicationNotificationMentions(event model.NotificationEventType) ([]string, []string, error) {
n, ok := p.metadataStore.Shared().Get(model.MetadataKeyDeploymentNotification)
if !ok {
return []string{}, nil
return []string{}, []string{}, nil
}

var notification config.DeploymentNotification
if err := json.Unmarshal([]byte(n), &notification); err != nil {
return nil, fmt.Errorf("could not extract mentions config: %w", err)
return nil, nil, fmt.Errorf("could not extract mentions config: %w", err)
}

return notification.FindSlackAccounts(event), nil
return notification.FindSlackUsers(event), notification.FindSlackGroups(event), nil
}
36 changes: 21 additions & 15 deletions pkg/app/piped/controller/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,43 +652,49 @@ func (s *scheduler) reportDeploymentCompleted(ctx context.Context, status model.
defer func() {
switch status {
case model.DeploymentStatus_DEPLOYMENT_SUCCESS:
accounts, err := s.getMentionedAccounts(model.NotificationEventType_EVENT_DEPLOYMENT_SUCCEEDED)
users, groups, err := s.getApplicationNotificationMentions(model.NotificationEventType_EVENT_DEPLOYMENT_SUCCEEDED)
if err != nil {
s.logger.Error("failed to get the list of accounts", zap.Error(err))
s.logger.Error("failed to get the list of users or groups", zap.Error(err))
}

s.notifier.Notify(model.NotificationEvent{
Type: model.NotificationEventType_EVENT_DEPLOYMENT_SUCCEEDED,
Metadata: &model.NotificationEventDeploymentSucceeded{
Deployment: s.deployment,
MentionedAccounts: accounts,
MentionedAccounts: users,
MentionedGroups: groups,
},
})

case model.DeploymentStatus_DEPLOYMENT_FAILURE:
accounts, err := s.getMentionedAccounts(model.NotificationEventType_EVENT_DEPLOYMENT_FAILED)
users, groups, err := s.getApplicationNotificationMentions(model.NotificationEventType_EVENT_DEPLOYMENT_FAILED)
if err != nil {
s.logger.Error("failed to get the list of accounts", zap.Error(err))
s.logger.Error("failed to get the list of users or groups", zap.Error(err))
}

s.notifier.Notify(model.NotificationEvent{
Type: model.NotificationEventType_EVENT_DEPLOYMENT_FAILED,
Metadata: &model.NotificationEventDeploymentFailed{
Deployment: s.deployment,
Reason: desc,
MentionedAccounts: accounts,
MentionedAccounts: users,
MentionedGroups: groups,
},
})

case model.DeploymentStatus_DEPLOYMENT_CANCELLED:
accounts, err := s.getMentionedAccounts(model.NotificationEventType_EVENT_DEPLOYMENT_CANCELLED)
users, groups, err := s.getApplicationNotificationMentions(model.NotificationEventType_EVENT_DEPLOYMENT_CANCELLED)
if err != nil {
s.logger.Error("failed to get the list of accounts", zap.Error(err))
s.logger.Error("failed to get the list of users", zap.Error(err))
}

s.notifier.Notify(model.NotificationEvent{
Type: model.NotificationEventType_EVENT_DEPLOYMENT_CANCELLED,
Metadata: &model.NotificationEventDeploymentCancelled{
Deployment: s.deployment,
Commander: cancelCommander,
MentionedAccounts: accounts,
MentionedAccounts: users,
MentionedGroups: groups,
},
})
}
Expand All @@ -705,18 +711,18 @@ func (s *scheduler) reportDeploymentCompleted(ctx context.Context, status model.
return err
}

func (s *scheduler) getMentionedAccounts(event model.NotificationEventType) ([]string, error) {
n, ok := s.metadataStore.Shared().Get(model.MetadataKeyDeploymentNotification)
// getApplicationNotificationMentions returns the list of users groups who should be mentioned in the notification.
func (p *scheduler) getApplicationNotificationMentions(event model.NotificationEventType) ([]string, []string, error) {
n, ok := p.metadataStore.Shared().Get(model.MetadataKeyDeploymentNotification)
if !ok {
return []string{}, nil
return []string{}, []string{}, nil
}

var notification config.DeploymentNotification
if err := json.Unmarshal([]byte(n), &notification); err != nil {
return nil, fmt.Errorf("could not extract mentions config: %w", err)
return nil, nil, fmt.Errorf("could not extract mentions config: %w", err)
}

return notification.FindSlackAccounts(event), nil
return notification.FindSlackUsers(event), notification.FindSlackGroups(event), nil
}

func (s *scheduler) reportMostRecentlySuccessfulDeployment(ctx context.Context) error {
Expand Down
3 changes: 1 addition & 2 deletions pkg/app/piped/executor/ecs/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ func sync(ctx context.Context, in *executor.Input, platformProviderName string,
cnt := service.DesiredCount
// Scale down the service tasks by set it to 0
in.LogPersister.Infof("Scale down ECS desired tasks count to 0")
service.DesiredCount = 0
if _, err = client.UpdateService(ctx, *service); err != nil {
if err = client.PruneServiceTasks(ctx, *service); err != nil {
in.LogPersister.Errorf("Failed to stop service tasks: %v", err)
return false
}
Expand Down
23 changes: 13 additions & 10 deletions pkg/app/piped/executor/waitapproval/waitapproval.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,48 +110,51 @@ func (e *Executor) checkApproval(ctx context.Context, num int) bool {
}

func (e *Executor) reportApproved(approver string) {
accounts, err := e.getMentionedAccounts(model.NotificationEventType_EVENT_DEPLOYMENT_APPROVED)
users, groups, err := e.getApplicationNotificationMentions(model.NotificationEventType_EVENT_DEPLOYMENT_APPROVED)
if err != nil {
e.Logger.Error("failed to get the list of accounts", zap.Error(err))
e.Logger.Error("failed to get the list of users or groups", zap.Error(err))
}

e.Notifier.Notify(model.NotificationEvent{
Type: model.NotificationEventType_EVENT_DEPLOYMENT_APPROVED,
Metadata: &model.NotificationEventDeploymentApproved{
Deployment: e.Deployment,
Approver: approver,
MentionedAccounts: accounts,
MentionedAccounts: users,
MentionedGroups: groups,
},
})
}

func (e *Executor) reportRequiringApproval() {
accounts, err := e.getMentionedAccounts(model.NotificationEventType_EVENT_DEPLOYMENT_WAIT_APPROVAL)
users, groups, err := e.getApplicationNotificationMentions(model.NotificationEventType_EVENT_DEPLOYMENT_WAIT_APPROVAL)
if err != nil {
e.Logger.Error("failed to get the list of accounts", zap.Error(err))
e.Logger.Error("failed to get the list of users or groups", zap.Error(err))
}

e.Notifier.Notify(model.NotificationEvent{
Type: model.NotificationEventType_EVENT_DEPLOYMENT_WAIT_APPROVAL,
Metadata: &model.NotificationEventDeploymentWaitApproval{
Deployment: e.Deployment,
MentionedAccounts: accounts,
MentionedAccounts: users,
MentionedGroups: groups,
},
})
}

func (e *Executor) getMentionedAccounts(event model.NotificationEventType) ([]string, error) {
// getMentionedUsers returns the list of users groups who should be mentioned in the notification.
func (e *Executor) getApplicationNotificationMentions(event model.NotificationEventType) ([]string, []string, error) {
n, ok := e.MetadataStore.Shared().Get(model.MetadataKeyDeploymentNotification)
if !ok {
return []string{}, nil
return []string{}, []string{}, nil
}

var notification config.DeploymentNotification
if err := json.Unmarshal([]byte(n), &notification); err != nil {
return nil, fmt.Errorf("could not extract mentions config: %w", err)
return nil, nil, fmt.Errorf("could not extract mentions users and groups config: %w", err)
}

return notification.FindSlackAccounts(event), nil
return notification.FindSlackUsers(event), notification.FindSlackGroups(event), nil
}

// validateApproverNum checks if number of approves is valid.
Expand Down
Loading

0 comments on commit 84db6a6

Please sign in to comment.