-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
983 additions
and
228 deletions.
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
53 changes: 53 additions & 0 deletions
53
api/ocm/extensions/repositories/genericocireg/bloblimits.go
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,53 @@ | ||
package genericocireg | ||
|
||
import ( | ||
"sync" | ||
|
||
configctx "ocm.software/ocm/api/config" | ||
"ocm.software/ocm/api/ocm/extensions/repositories/genericocireg/config" | ||
) | ||
|
||
var ( | ||
defaultBlobLimits config.BlobLimits | ||
lock sync.Mutex | ||
) | ||
|
||
const ( | ||
KB = int64(1000) | ||
MB = 1000 * KB | ||
GB = 1000 * MB | ||
) | ||
|
||
func init() { | ||
defaultBlobLimits = config.BlobLimits{} | ||
|
||
// Add limits for known OCI repositories, here, | ||
// or provide init functions in specialized packages | ||
// by calling AddDefaultBlobLimit. | ||
AddDefaultBlobLimit("ghcr.io", 10*GB) // https://github.com/orgs/community/discussions/77429 | ||
} | ||
|
||
// AddDefaultBlobLimit can be used to set default blob limits | ||
// for known repositories. | ||
// Those limits will be overwritten, by blob limits | ||
// given by a configuration object and the repository | ||
// specification. | ||
func AddDefaultBlobLimit(name string, limit int64) { | ||
lock.Lock() | ||
defer lock.Unlock() | ||
|
||
defaultBlobLimits[name] = limit | ||
} | ||
|
||
func ConfigureBlobLimits(ctx configctx.ContextProvider, target config.Configurable) { | ||
if target != nil { | ||
lock.Lock() | ||
defer lock.Unlock() | ||
|
||
target.ConfigureBlobLimits(defaultBlobLimits) | ||
|
||
if ctx != nil { | ||
ctx.ConfigContext().ApplyTo(0, target) | ||
} | ||
} | ||
} |
Oops, something went wrong.