-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Make mirror feature more configurable #16957
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
Merged
+161
−74
Merged
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
afd97dd
move disable_mirror from repo to mirror section
6543 bbe0302
move mirror disable setting into mirror section and make it more fine…
6543 12713b4
documentation
6543 709e62a
Merge branch 'master' into only-push-mirror
6543 3880209
indenting
6543 82d2925
deprecated msg on fallback usage
6543 00db6ff
update docs
6543 9a0a376
Merge branch 'main' into only-push-mirror
6543 4f55d71
as per @lunny
6543 9f648e6
Merge branch 'main' into only-push-mirror
6543 1518188
Merge branch 'main' into only-push-mirror
6543 2106a45
Apply suggestions from code review
6543 4d97128
Merge branch 'main' into only-push-mirror
6543 b3fb7fe
Apply suggestions from code review
6543 a20a453
cover edge case where gitea-admin did missunderstud how to set things
6543 7a8d6cb
Merge branch 'main' into only-push-mirror
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,55 @@ | ||
// 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 setting | ||
|
||
import ( | ||
"time" | ||
|
||
"code.gitea.io/gitea/modules/log" | ||
) | ||
|
||
var ( | ||
// Mirror settings | ||
Mirror = struct { | ||
Enabled bool | ||
DisableNewPull bool | ||
DisableNewPush bool | ||
DefaultInterval time.Duration | ||
MinInterval time.Duration | ||
}{ | ||
Enabled: true, | ||
DisableNewPull: false, | ||
DisableNewPush: false, | ||
MinInterval: 10 * time.Minute, | ||
DefaultInterval: 8 * time.Hour, | ||
} | ||
) | ||
|
||
func newMirror() { | ||
// Handle old configuration through `[repository]` `DISABLE_MIRRORS` | ||
// - please note this was badly named and only disabled the creation of new pull mirrors | ||
if Cfg.Section("repository").Key("DISABLE_MIRRORS").MustBool(false) { | ||
log.Warn("Deprecated DISABLE_MIRRORS config is used, please change your config and use the options within the [mirror] section") | ||
// TODO: enable on v1.17.0: log.Error("Deprecated fallback used, will be removed in v1.18.0") | ||
Mirror.DisableNewPull = true | ||
6543 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
if err := Cfg.Section("mirror").MapTo(&Mirror); err != nil { | ||
log.Fatal("Failed to map Mirror settings: %v", err) | ||
} | ||
|
||
if !Mirror.Enabled { | ||
Mirror.DisableNewPull = true | ||
Mirror.DisableNewPush = true | ||
} | ||
|
||
if Mirror.MinInterval.Minutes() < 1 { | ||
log.Warn("Mirror.MinInterval is too low, set to 1 minute") | ||
Mirror.MinInterval = 1 * time.Minute | ||
} | ||
if Mirror.DefaultInterval < Mirror.MinInterval { | ||
log.Warn("Mirror.DefaultInterval is less than Mirror.MinInterval, set to 8 hours") | ||
Mirror.DefaultInterval = time.Hour * 8 | ||
6543 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.