-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[API] add new endpoints for push mirrors management #19841
Merged
Merged
Changes from 6 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
cf10d77
add new endpoints for push mirrors management:
mohsek 015a57a
Merge branch 'main' into main
mohsek fb9ea68
Merge branch 'main' into main
mohsek a4b40bd
remove changes added to some files by mistake
mohsek 4a1fb91
fix lint errors
mohsek 5c5eef3
Update .drone.yml
zeripath a79cd85
Remove unnecessary package change
zeripath 99f6a77
Protect against reading other repo push mirrors
zeripath 4141460
Update services/mailer/mail_test.go
zeripath 0742732
Apply suggestions from code review
zeripath 4fa4660
And Delete too
zeripath 97204df
Merge branch 'mohsek/main-upstream' into mohsek/main
zeripath 633095d
fix lint
zeripath d507d47
Use remote name not id
zeripath 179e935
oops swagger
zeripath 37ba6cf
rename push-mirror endpoints to push_mirrors
mohsek 4560d3b
apply the suggested changes
mohsek b4e0977
Merge branch 'main' into main
mohsek addd7f1
handle error on failed sync mirror
mohsek 4071774
fix typo
mohsek 9206fc5
apply PR suggestions
mohsek 6950ff1
some code refactor to use remoteName instead of ID
mohsek 3e90998
Merge branch 'main' into main
mohsek 0d39152
fix lint-backend error
mohsek 88f620c
Merge branch 'main' into main
mohsek b23979a
code refactoring
mohsek c775d3c
fix lint
mohsek 614d724
handle error getMirrorRemoteAddress
mohsek 85eecf5
handle errors on convert.ToPushMirror
mohsek aabe5e9
use builder.Cond function to simplify code
mohsek 4a54502
restore changes done to helper.go
mohsek 639268a
Merge branch 'main' into main
mohsek 2645df8
add context parameter to added functions
mohsek 61e493e
apply PR suggestions
mohsek da57680
apply PR suggestion
mohsek e50174c
some minor refactoring
mohsek d59a235
Merge branch 'main' into main
mohsek 5cff07e
Merge remote-tracking branch 'origin/main' into mohsek/main
zeripath 0884346
Merge branch 'main' into main
zeripath 1886253
Merge branch 'main' into main
zeripath cadcfb7
Merge branch 'main' into main
mohsek c535692
Merge branch 'main' into main
lunny 8578582
Merge branch 'main' into main
zeripath 1309dec
Merge branch 'main' into main
mohsek d9ddbcf
fix wrong count calculation
mohsek d1f2993
Merge branch 'main' into main
6543 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2022 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package convert | ||
|
||
import ( | ||
repo_model "code.gitea.io/gitea/models/repo" | ||
"code.gitea.io/gitea/modules/git" | ||
api "code.gitea.io/gitea/modules/structs" | ||
) | ||
|
||
// ToPushMirror convert from repo_model.PushMirror and remoteAddress to api.TopicResponse | ||
func ToPushMirror(pm *repo_model.PushMirror, repo *repo_model.Repository) *api.PushMirror { | ||
remoteAddress, _ := getMirrorRemoteAddress(repo, pm.RemoteName) | ||
6543 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return &api.PushMirror{ | ||
ID: pm.ID, | ||
RepoName: repo.Name, | ||
RemoteName: pm.RemoteName, | ||
RemoteAddress: remoteAddress, | ||
CreatedUnix: pm.CreatedUnix.FormatLong(), | ||
LastUpdateUnix: pm.LastUpdateUnix.FormatLong(), | ||
LastError: pm.LastError, | ||
Interval: pm.Interval.String(), | ||
} | ||
} | ||
|
||
func getMirrorRemoteAddress(repo *repo_model.Repository, remoteName string) (string, error) { | ||
lunny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
u, err := git.GetRemoteAddress(git.DefaultContext, repo.RepoPath(), remoteName) | ||
if err != nil { | ||
return "", err | ||
} | ||
// remove confidential information | ||
u.User = nil | ||
return u.String(), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2021 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package structs | ||
|
||
// CreatePushMirrorOption represents need information to create a push mirror of a repository. | ||
type CreatePushMirrorOption struct { | ||
RemoteAddress string `json:"remoteAddress"` | ||
RemoteUsername string `json:"remoteUsername"` | ||
RemotePassword string `json:"remotePassword"` | ||
Interval string `json:"interval"` | ||
} | ||
|
||
// PushMirror represents information of a push mirror | ||
// swagger:model | ||
type PushMirror struct { | ||
ID int64 `json:"id"` | ||
RepoName string `json:"repoName"` | ||
RemoteName string `json:"remoteName"` | ||
RemoteAddress string `json:"remoteAddress"` | ||
CreatedUnix string `json:"created"` | ||
LastUpdateUnix string `json:"lastUpdate"` | ||
LastError string `json:"lastError"` | ||
Interval string `json:"interval"` | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the other functions now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To summarize, currently we have 2 functions :
Should we merge also this one ? if soo all the calling functions should parse the response as a list and I don't think it's a good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woops I'd missed that.