Skip to content

Commit

Permalink
feat: replace docker with oras (#904)
Browse files Browse the repository at this point in the history
This is a highly Draft pull request understanding the nuances of the OCI
package.

There are a LOT of things to do yet:
- [x] Figure out to nicely create repositories with hosts
- [x] Add authentication configuration to the OCI repository creation
- [x] Figure out which store to use and which implementation to use
where
- [x] Figure out the least intrusive modification that still works
- this will partially be done via declared interfaces to support
previous behaviour

---------

Co-authored-by: ocmbot[bot] <125909804+ocmbot[bot]@users.noreply.github.com>
  • Loading branch information
Skarlso and ocmbot[bot] authored Sep 26, 2024
1 parent f63057b commit 3cfa228
Show file tree
Hide file tree
Showing 40 changed files with 223 additions and 2,515 deletions.
File renamed without changes.
12 changes: 3 additions & 9 deletions .github/workflows/lint_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ jobs:
with:
go-version-file: '${{ github.workspace }}/go.mod'
- name: Test
run: |
PATH=$PATH:$(go env GOPATH)/bin make build install-requirements test
run: make build install-requirements test

go-lint:
name: Lint Golang
Expand All @@ -41,11 +40,6 @@ jobs:
with:
go-version-file: '${{ github.workspace }}/go.mod'
- name: Install goimports
run: |
go install golang.org/x/tools/cmd/goimports@latest
- name: Setup lint
run: |
make -f hack/Makefile golangci-lint
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Lint
run: |
PATH=$PATH:$(go env GOPATH)/bin make check
run: make check
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ format:
@$(REPO_ROOT)/hack/format.sh $(EFFECTIVE_DIRECTORIES)

.PHONY: check
check:
@$(REPO_ROOT)/hack/check.sh --golangci-lint-config=./.golangci.yaml $(EFFECTIVE_DIRECTORIES)
check: ## Run golangci-lint.
make -f hack/Makefile golangci-lint
golangci-lint run --timeout 10m --config .github/config/golangci.yaml $(EFFECTIVE_DIRECTORIES)

.PHONY: check-and-fix
check-and-fix:
Expand Down
12 changes: 6 additions & 6 deletions api/credentials/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,25 @@ func GuessConsumerType(ctxp ContextProvider, spec string) string {
}
}
if fix == "" {
min := -1
minVal := -1
for _, i := range matchers.List() {
idx := strings.Index(i.Type, ".")
if idx > 0 {
d := levenshtein.DistanceForStrings([]rune(lspec), []rune(strings.ToLower(i.Type[:idx])), levenshtein.DefaultOptions)
if d < 5 && fix == "" || min > d {
if d < 5 && fix == "" || minVal > d {
fix = i.Type
min = d
minVal = d
}
}
}
}
if fix == "" {
min := -1
minVal := -1
for _, i := range matchers.List() {
d := levenshtein.DistanceForStrings([]rune(lspec), []rune(strings.ToLower(i.Type)), levenshtein.DefaultOptions)
if d < 5 && fix == "" || min > d {
if d < 5 && fix == "" || minVal > d {
fix = i.Type
min = d
minVal = d
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion api/oci/cpi/support/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func (a *ArtifactAccessImpl) ManifestAccess(v cpi.ArtifactAccess) internal.Manif
return nil
}
}

return NewManifestForArtifact(v, a)
}

Expand Down Expand Up @@ -177,7 +178,7 @@ func (a *ArtifactAccessImpl) GetBlob(digest digest.Digest) (cpi.BlobAccess, erro
if d != nil {
size, data, err := a.container.GetBlobData(digest)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to get blob data for artifact access with digest %s: %w", digest.String(), err)
}
err = AdjustSize(d, size)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion api/oci/extensions/repositories/docker/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (a *artBlobCache) Unref() error {
func (a *artBlobCache) GetBlobData(digest digest.Digest) (int64, blobaccess.DataAccess, error) {
blob, err := a.access.GetBlob(digest)
if err != nil {
return -1, nil, err
return -1, nil, fmt.Errorf("error getting blob for docker repo %s: %w", digest, err)
}
return blob.Size(), blob, err
}
Expand Down
109 changes: 0 additions & 109 deletions api/oci/extensions/repositories/ocireg/blobs.go

This file was deleted.

Loading

0 comments on commit 3cfa228

Please sign in to comment.