Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: By default scm github/gitlab/stash/gitea uses force push #2026

Merged
merged 5 commits into from
Apr 5, 2024

Conversation

olblak
Copy link
Member

@olblak olblak commented Apr 5, 2024

I started using 0.75.0-rc.1 and I am really annoyed that I now have to go over all my manifest for a behavior that I feel should be the default.
I would expected for any pipeline relying on a working branch created by Updatecli to be automatically recreated when the based branch is modified.

I already put in place a safeguard for the scm git plugin, because by default it doesn't create a working branch so if only force is set to true there is a risk to accidentally force push changes.
so the following pipeline would trigger an error

scms:
  default:
    kind: git 
    spec:
      url: git@github.com:updatecli/updatecli.git
      force: true

will trigger an error asking to set workingbranch to either true or false to show that the user understand the behavior

scms:
  default:
    kind: git 
    spec:
      url: git@github.com:updatecli/updatecli.git
      force: true
      workingbranch: false

This pull request set force to true for the scm plugins GitLab, Gitea, GitHub, Stash and provide additional safe guards for unclear configuration.

Unclear manifest
scms:
  default:
    kind: github
    spec:
      owner: olblak
      repository: updatecli
      token: '{{ requiredEnv "GITHUB_TOKEN" }}'
      workingbranch: false
Console output
+++++++++++
+ PREPARE +
+++++++++++

Loading Pipeline "/tmp/tt.yaml"
WARNING: Updatecli binary version is unset. This means you are using a development version that ignores manifest version constraint.
WARNING: no git branch specified, fallback to "main"
ERROR: Better safe than sorry.

Updatecli may be pushing unwanted changes to the branch "main".

The GitHub scm plugin has by default the force option set to true,
The scm force option set to true means that Updatecli is going to run "git push --force"
Some target plugin, like the shell one, run "git commit -A" to catch all changes done by that target.

If you know what you are doing, please set the force option to true in your configuration file to ignore this error message.
ERROR: failed loading pipeline(s)
	* "/tmp/tt.yaml" - unclear configuration, better safe than sorry

0 pipeline(s) successfully loaded

SCM repository retrieved: 0


++++++++++++++++++
+ AUTO DISCOVERY +
++++++++++++++++++

ERROR: ✗ no valid pipeline found
ERROR: command failed: no valid pipeline found
[1]    5346 exit 1     ./bin/updatecli diff --config /tmp/tt.yaml

Test

To test this pull request, you can run the following commands:

cd <to_package_directory>
go test

Additional Information

Tradeoff

Different force behavior depending on the scm plugin. I guess the day we align the git plugin with the other ones, we'll be able to also align the force setting

Potential improvement

Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak added the enhancement New feature or request label Apr 5, 2024
@olblak olblak added this to the 0.75.0 milestone Apr 5, 2024
@olblak olblak merged commit 379e1f6 into updatecli:main Apr 5, 2024
6 checks passed
@olblak olblak deleted the extraWarning branch April 5, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant