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(appset): get latest protected tag from gitlab api #15886

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Demch1k
Copy link

@Demch1k Demch1k commented Oct 10, 2023

Hello everyone!
This Pull Request add feature to get latest protected tag from GitLab API for SCM provider to use it with ApplicationSet.
In our company we are using simple GitFlow to deploy our applications. It means that we have 3 stages (review/stage/production). On the last stage of deploying we use lastest protected tag in gitlab to deploy our application to production.
We want to use ApplicationSet but without tags it will be not possible to implement it in our GitFlow.
What do you think about this PR? It it possible to have it in the future release or could someone do it in better way?

I have tested it locally and in our test ArgoCD installation. It works great.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.

@Demch1k Demch1k requested a review from a team as a code owner October 10, 2023 08:24
@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

Attention: 42 lines in your changes are missing coverage. Please review.

Comparison is base (58da6a3) 49.51% compared to head (ca2b78c) 49.47%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #15886      +/-   ##
==========================================
- Coverage   49.51%   49.47%   -0.05%     
==========================================
  Files         269      269              
  Lines       46990    47032      +42     
==========================================
  Hits        23269    23269              
- Misses      21437    21478      +41     
- Partials     2284     2285       +1     
Files Coverage Δ
.../apis/application/v1alpha1/applicationset_types.go 22.06% <ø> (ø)
applicationset/generators/scm_provider.go 41.74% <0.00%> (-1.47%) ⬇️
applicationset/services/scm_provider/gitlab.go 60.33% <0.00%> (-14.67%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@crenshaw-dev crenshaw-dev changed the title feat: Add feature to get latest protected tag from gitlab api feat(appset): get latest protected tag from gitlab api Oct 10, 2023
@Demch1k Demch1k requested a review from a team as a code owner October 10, 2023 15:43
@Demch1k Demch1k force-pushed the latest-tag-for-gitlab-scm-generator branch 2 times, most recently from 74b9b96 to ad82bdf Compare October 11, 2023 05:13
@Demch1k
Copy link
Author

Demch1k commented Oct 13, 2023

@crenshaw-dev Could you please take a look?

@Demch1k
Copy link
Author

Demch1k commented Oct 24, 2023

@crenshaw-dev Could you please take a look on this PR when you will have free time.

@Demch1k
Copy link
Author

Demch1k commented Nov 4, 2023

@crenshaw-dev any updates?

@Demch1k Demch1k force-pushed the latest-tag-for-gitlab-scm-generator branch from ecaebb6 to 5bf6359 Compare November 7, 2023 03:17
Ivan Sokoryan added 9 commits November 7, 2023 09:48
Signed-off-by: Ivan Sokoryan <i.sokoryan@robo.cash>
Signed-off-by: Ivan Sokoryan <i.sokoryan@robo.cash>
Signed-off-by: Ivan Sokoryan <i.sokoryan@robo.cash>
Signed-off-by: Ivan Sokoryan <i.sokoryan@robo.cash>
Signed-off-by: Ivan Sokoryan <i.sokoryan@robo.cash>
Signed-off-by: Ivan Sokoryan <i.sokoryan@robo.cash>
Signed-off-by: Ivan Sokoryan <i.sokoryan@robo.cash>
Signed-off-by: Ivan Sokoryan <i.sokoryan@robo.cash>
Signed-off-by: Ivan Sokoryan <i.sokoryan@robo.cash>
@Demch1k Demch1k force-pushed the latest-tag-for-gitlab-scm-generator branch from 5bf6359 to ca2b78c Compare November 7, 2023 03:55
@Demch1k
Copy link
Author

Demch1k commented Nov 10, 2023

Could someone take a look on this PR please?

return []gitlab.Tag{}, nil
}
if err != nil {
return nil, err
Copy link
Member

Choose a reason for hiding this comment

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

Can we add more details to the error here?

Comment on lines +211 to +213
if resp != nil && resp.StatusCode == http.StatusNotFound {
return []gitlab.Tag{}, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we get an err when receiving 404s? If not, can we check for err != nil first?

Comment on lines +234 to +238
for _, tag := range tags {
if tag.Protected {
return tag.Name, nil
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we have more than one protected tags? If yes, should we return the list here?

@@ -110,6 +112,7 @@ spec:
* `topic`: filter projects by topic. A single topic is supported by Gitlab API. Defaults to "" (all topics).
* `tokenRef`: A `Secret` name and key containing the GitLab access token to use for requests. If not specified, will make anonymous requests which have a lower rate limit and can only see public repositories.
* `insecure`: By default (false) - Skip checking the validity of the SCM's certificate - useful for self-signed TLS certificates.
* `latestProtectedTag`: Obtain latest protected tag to use it in deployments.
Copy link
Member

Choose a reason for hiding this comment

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

Can we add the default value here?

@@ -496,6 +496,8 @@ type SCMProviderGeneratorGitlab struct {
IncludeSharedProjects *bool `json:"includeSharedProjects,omitempty" protobuf:"varint,7,opt,name=includeSharedProjects"`
// Filter repos list based on Gitlab Topic.
Topic string `json:"topic,omitempty" protobuf:"bytes,8,opt,name=topic"`
// Obtain latest protected tag from GitLab project. Default to "false"
LatestProtectedTag bool `json:"latestProtectedTag,omitempty" protobuf:"varint,9,opt,name=latestProtectedTag"`
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to rename this to FetchLatestProtectedTag?

@ngnix
Copy link

ngnix commented Feb 16, 2024

Are there any plans to accept this PR?

@blakepettersson
Copy link
Member

@ngnix that depends if @Demch1k is around to address the feedback that Ishita gave a while back. Another issue is that I suspect that there are not too many maintainers that uses Gitlab, which would make it harder to validate from the maintainers' end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants