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: custom tag #3847

Merged
merged 55 commits into from
Oct 26, 2023
Merged

feat: custom tag #3847

merged 55 commits into from
Oct 26, 2023

Conversation

avdhesh-devtron
Copy link
Contributor

@avdhesh-devtron avdhesh-devtron commented Aug 30, 2023

feat: custom tag
Fixes #3566

How Has This Been Tested?

  • dev testing
  • QA testing

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR requires documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have tested it for all user roles.
  • I have added all the required unit/api test cases.

Does this PR introduce a user-facing change?

Yes


@avdhesh-devtron avdhesh-devtron changed the title Refactor tag generation feat: custom tag Aug 30, 2023
EntityKey int `json:"entityKey"`
EntityValue string `json:"entityValue"`
TagPattern string `json:"tagPattern"`
AutoIncreasingNumber int `json:"counterX"`
Copy link
Contributor

Choose a reason for hiding this comment

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

can be used better name for counterX

)

const (
imagePathPattern = "%s/%s:%s" // dockerReg/dockerRepo:Tag
Copy link
Contributor

Choose a reason for hiding this comment

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

we can put these type of constants at some common place

customTagData := repository.CustomTag{
EntityKey: tag.EntityKey,
EntityValue: tag.EntityValue,
TagPattern: strings.ReplaceAll(tag.TagPattern, "{X}", "{x}"),
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use some other relevant name than X

if customTagData.AutoIncreasingNumber < 0 {
return "", fmt.Errorf("counter {x} can not be negative")
}
dockerImageTag := strings.ReplaceAll(customTagData.TagPattern, "{x}", strconv.Itoa(customTagData.AutoIncreasingNumber-1)) //-1 because number is already incremented, current value will be used next time
Copy link
Contributor

Choose a reason for hiding this comment

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

x


// for patterns like v1.0.{x} we will calculate count with . in {x} i.e .{x}
variableCount := 0
variableCount = variableCount + strings.Count(customTagPattern, "{x}")
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use some other placeholder everywhere for x

// skip this and process for next ci workflow
}
err = impl.customTagService.DeactivateImagePathReservation(ciWorkflow.ImagePathReservationId)
if err != nil {
impl.Logger.Errorw("unable to update ci workflow, its eligible to mark failed", "err", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

why not returning error

Copy link
Contributor

Choose a reason for hiding this comment

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

there are more than one ci_workflows updated in this function. If there is some error with one workflow then we are skipping only that workflow and continuing our loop

@@ -141,6 +145,13 @@ func (impl WebhookServiceImpl) HandleCiStepFailedEvent(ciPipelineId int, request
return err
}

go func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

can use use nats for this purpose

@sonarcloud
Copy link

sonarcloud bot commented Oct 26, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@iamayushm iamayushm merged commit 2f19628 into main Oct 26, 2023
5 checks passed
@iamayushm iamayushm deleted the refactor-tag-generation branch October 26, 2023 10:40
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.

Feature: Tags to be propagated to container registry and auto-increment
4 participants