-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
- Loading branch information
Showing
16 changed files
with
583 additions
and
150 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
File renamed without changes.
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,31 @@ | ||
// Copyright 2023 Linka Cloud All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cache | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
var ( | ||
DefaultTTL = 5 * time.Minute | ||
d = New() | ||
) | ||
|
||
func Set(key string, value any, opts ...Option) { | ||
d.Set(key, value, opts...) | ||
} | ||
func Get(key string) (any, bool) { | ||
return d.Get(key) | ||
} |
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,51 @@ | ||
// Copyright 2023 Linka Cloud All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package registry | ||
|
||
import ( | ||
"context" | ||
"io" | ||
|
||
ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||
"oras.land/oras-go/v2/content" | ||
"oras.land/oras-go/v2/registry" | ||
) | ||
|
||
type BlobStore = registry.BlobStore | ||
|
||
type BlobProxy interface { | ||
registry.ReferenceFetcher | ||
content.Fetcher | ||
} | ||
|
||
type blobs struct { | ||
BlobStore | ||
p BlobProxy | ||
} | ||
|
||
func (b *blobs) Fetch(ctx context.Context, target ocispec.Descriptor) (io.ReadCloser, error) { | ||
return b.maybeProxy().Fetch(ctx, target) | ||
} | ||
|
||
func (b *blobs) FetchReference(ctx context.Context, reference string) (ocispec.Descriptor, io.ReadCloser, error) { | ||
return b.maybeProxy().FetchReference(ctx, reference) | ||
} | ||
|
||
func (b *blobs) maybeProxy() BlobProxy { | ||
if b.p != nil { | ||
return b.p | ||
} | ||
return b.BlobStore | ||
} |
Oops, something went wrong.