Skip to content

Conversation

@khanhtc1202
Copy link
Member

@khanhtc1202 khanhtc1202 commented Oct 28, 2021

What this PR does / why we need it:

Sample configuration for this looks like

apiVersion: pipecd.dev/v1beta1
kind: KubernetesApp
spec:
  trigger:
    onCommit:
       disable: true
  input:
    ...

Besides, we can also configure watching paths via spec.trigger.onCommit.Paths field, the previous spec.triggerPaths is marked as deprecated and will be removed later.

Which issue(s) this PR fixes:

Fixes #2245

Does this PR introduce a user-facing change?:

Add ability to disable auto-trigger deployment on Git changes

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.13%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/piped/trigger/determiner.go Determiner.ShouldTrigger 0.00% 0.00% +0.00%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.13%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/piped/trigger/determiner.go Determiner.ShouldTrigger 0.00% 0.00% +0.00%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.13%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/piped/trigger/determiner.go Determiner.ShouldTrigger 0.00% 0.00% +0.00%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.13%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/piped/trigger/determiner.go Determiner.ShouldTrigger 0.00% 0.00% +0.00%

@khanhtc1202 khanhtc1202 marked this pull request as ready for review October 29, 2021 05:28
SealedSecrets []SealedSecretMapping `json:"sealedSecrets"`
// List of directories or files where their changes will trigger the deployment.
// Regular expression can be used.
TriggerPaths []string `json:"triggerPaths,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep both of fields to avoid breaking changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, then mark it as deprecated and remove it later 👍 Lets me address this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed by 6591559

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better update our docs as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will do it by a separated PR 🙏

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.12%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/piped/trigger/determiner.go Determiner.ShouldTrigger 0.00% 0.00% +0.00%

@nghialv
Copy link
Member

nghialv commented Oct 29, 2021

This should fix #2245

// Regular expression can be used.
Paths []string `json:"paths,omitempty"`
// Control trigger new deployment on Git change or not.
DisableAutoDeployOnChange bool `json:"disableAutoDeployOnChange,omitempty"`
Copy link
Member

@nghialv nghialv Oct 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

triggerOnChange: true
triggerOnSyncCommand: true
triggerOnChain: true

or

onChange: true
onSyncCommand: true
onChain: true

or

on:
  - GIT_CHANGE
  - SYNC_COMMAND
  - CHAIN

or

onChange:
  disabled: true
onSyncCommand:
  disabled: true
onChain:
  disabled: true
  otherConfig: foo

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get your point; let me carefully think about this 👍 At a glance, I believe (3) is best for our deployment chain implementation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Let take the time to think about that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added another option.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's too many (but I liked it) 😄

@khanhtc1202
Copy link
Member Author

/hold

@khanhtc1202 khanhtc1202 force-pushed the add-disable-auto-trigger-deploy branch from 6591559 to cbd67d8 Compare November 5, 2021 10:08
@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.10%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/piped/trigger/determiner.go Determiner.ShouldTrigger 0.00% 0.00% +0.00%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.10%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/piped/trigger/determiner.go Determiner.ShouldTrigger 0.00% 0.00% +0.00%

@pipecd-bot pipecd-bot added size/L and removed size/M labels Nov 8, 2021
@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.09%. This pull request decreases coverage by -0.02%.

File Function Base Head Diff
pkg/app/piped/trigger/determiner.go Determiner.ShouldTrigger 0.00% 0.00% +0.00%

@khanhtc1202
Copy link
Member Author

/hold cancel

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.08%. This pull request decreases coverage by -0.03%.

File Function Base Head Diff
pkg/app/piped/trigger/determiner.go Determiner.shouldTriggerOnCommit -- 0.00% +0.00%
pkg/app/piped/trigger/determiner.go Determiner.ShouldTrigger 0.00% 0.00% +0.00%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.08%. This pull request decreases coverage by -0.03%.

File Function Base Head Diff
pkg/app/piped/trigger/determiner.go Determiner.shouldTriggerOnCommit -- 0.00% +0.00%
pkg/app/piped/trigger/determiner.go Determiner.ShouldTrigger 0.00% 0.00% +0.00%


type OnCommitConfig struct {
// Control trigger new deployment on Git change or not.
Disable bool `json:"disable,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Disabled" because we are using the same format at other places.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Do we need the Config suffix?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed by b9bc4cc

SealedSecrets []SealedSecretMapping `json:"sealedSecrets"`
// List of directories or files where their changes will trigger the deployment.
// Regular expression can be used.
// Deprecated: use Trigger.Paths instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs in dev should be updated too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do in a separated PR 🙆‍♀️


type OnCommitConfig struct {
// Control trigger new deployment on Git change or not.
Disable bool `json:"disable,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Do we need the Config suffix?

func (d *Determiner) ShouldTrigger(ctx context.Context, app *model.Application) (bool, error) {
// Flag `ignoreUserConfig` set to `true` will force check changes and use it to determine
// the application deployment should be triggered or not, regardless of the user's configuration.
func (d *Determiner) ShouldTrigger(ctx context.Context, app *model.Application, ignoreUserConfig bool) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about moving ignoreUserConfig to Determiner while initializing it? In that way, we can keep this function simple as it is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, lets me adopt that 🙆‍♀️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed by 8dffc8d

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.08%. This pull request decreases coverage by -0.03%.

File Function Base Head Diff
pkg/app/piped/trigger/determiner.go Determiner.shouldTriggerOnCommit -- 0.00% +0.00%
pkg/app/piped/trigger/determiner.go Determiner.ShouldTrigger 0.00% 0.00% +0.00%

@pipecd-bot
Copy link
Collaborator

TODO

The following ISSUES will be created once got merged. If you want me to skip creating the issue, you can use /todo skip command.

Details

1. Add logic to determine trigger or not based on other configuration than onCommit.

https://github.com/pipe-cd/pipe/blob/8dffc8dde1ce421ecde90d24f915b6589f3b63db/pkg/app/piped/trigger/determiner.go#L64-L67

This was created by todo plugin since "TODO:" was found in 8dffc8d when #2714 was merged. cc: @khanhtc1202.

2. Remove deprecated deployConfig.TriggerPaths configuration.

https://github.com/pipe-cd/pipe/blob/8dffc8dde1ce421ecde90d24f915b6589f3b63db/pkg/app/piped/trigger/determiner.go#L107-L110

This was created by todo plugin since "TODO:" was found in 8dffc8d when #2714 was merged. cc: @khanhtc1202.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.08%. This pull request decreases coverage by -0.03%.

File Function Base Head Diff
pkg/app/piped/trigger/determiner.go Determiner.shouldTriggerOnCommit -- 0.00% +0.00%
pkg/app/piped/trigger/determiner.go Determiner.ShouldTrigger 0.00% 0.00% +0.00%

@nghialv
Copy link
Member

nghialv commented Nov 9, 2021

Great!
/lgtm

@pipecd-bot pipecd-bot added the lgtm label Nov 9, 2021
@nakabonne
Copy link
Member

This small step is the first step of a great walk. Well done 👍
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by nakabonne.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to disable auto-trigger when new commit has been merged

6 participants