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: allow deployment webhook to push deployments to multiple repos … #6535

Merged
merged 3 commits into from
Nov 30, 2023

Conversation

abeizn
Copy link
Contributor

@abeizn abeizn commented Nov 29, 2023

Summary

feat: allow deployment webhook to push deployments to multiple repos in one request

[BE] Support the new payload
[BE] Add commit_msg to table cicd_deployment_commits
[FE] Update webhook deployment example

Does this close any open issues?

Related to #6262

Screenshots

img_v3_025k_3ef00b6a-f485-4606-a3f4-764d0bf15d9g
img_v3_025k_77d11025-3c51-488e-8eea-6eb05096449g
img_v3_025k_5376bdbe-e691-4c77-bd99-6d082d788edg

img_v3_025k_8f0a63b2-7602-4f9e-b848-afcde9ce168g
img_v3_025k_4f907ed3-8d7d-4019-9f03-ce3f51159a9g
img_v3_025k_dc9144ae-9903-4502-b2e5-ab1be965463g

Other Information

Any other information that is important to this PR.

@klesh klesh merged commit 71a1ddd into main Nov 30, 2023
11 checks passed
@klesh klesh deleted the feat#6162-webhook branch November 30, 2023 02:43
if err != nil {
logger.Error(err, "create deployment commit")
return nil, err
duration := request.FinishedDate.Sub(*request.StartedDate).Seconds()
Copy link
Contributor

Choose a reason for hiding this comment

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

duration is float type now. So please use .Milliseconds(), and divide 1000, get the float64 duration.

if request.DeploymentCommits == nil {
name = fmt.Sprintf(`deployment for %s`, request.CommitSha)
} else {
commit_sha_list := []string{}
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 name it with commitShaList?

} else {
commit_sha_list := []string{}
for _, commit := range request.DeploymentCommits {
commit_sha_list = append(commit_sha_list, commit.CommitSha)
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above.

}
} else {
for _, commit := range request.DeploymentCommits {
urlHash16 := fmt.Sprintf("%x", md5.Sum([]byte(commit.RepoUrl)))[:16]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is duplicated code, and can be wrapped to a function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, this is in the loop

// start_time and end_time is more readable for users,
// StartedDate and FinishedDate is same as columns in db.
// So they all keep.
CreatedDate *time.Time `mapstructure:"create_time"`
StartedDate *time.Time `mapstructure:"start_time" validate:"required"`
FinishedDate *time.Time `mapstructure:"end_time"`
RepoUrl string `mapstructure:"repo_url"`
Environment string `validate:"omitempty,oneof=PRODUCTION STAGING TESTING DEVELOPMENT"`
Copy link
Contributor

Choose a reason for hiding this comment

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

why doesn't this field have mapstructure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will not change the name, it will be resolved into environment

@abeizn
Copy link
Contributor Author

abeizn commented Nov 30, 2023

all fixed by other pr

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.

None yet

3 participants