Skip to content
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

Use copy options in push and pull commands #400

Merged
merged 75 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
acca895
Fix login bug for empty ca file
qweeah May 16, 2022
8cc26cc
Move user options to dedicated package
qweeah May 16, 2022
61a6083
Code clean
qweeah May 16, 2022
d2937ae
Refactoring
qweeah May 17, 2022
c9db85d
Generalize process of applying cobra flags
qweeah May 17, 2022
6c9a8fe
Move option package into cmd
qweeah May 17, 2022
cbf7f98
Resolve comments
qweeah May 18, 2022
a2ea274
Code clean
qweeah May 18, 2022
4d419b9
Code clean
qweeah May 18, 2022
f18f6ba
Add document
qweeah May 18, 2022
e9097e7
Merge remote-tracking branch 'origin_src/main' into common-opts
qweeah May 18, 2022
fc08f88
Refactor flag applier
qweeah May 18, 2022
ee278d7
Clean comment
qweeah May 18, 2022
60d81aa
Nit: add space after license
qweeah May 18, 2022
6e52215
Refactor
qweeah May 18, 2022
535fef7
Refactor
qweeah May 19, 2022
c635e5a
Merge remote-tracking branch 'origin_src/main' into pull-v2
qweeah May 19, 2022
1dc506b
Add push and pull
qweeah May 23, 2022
54dff81
Code clean
qweeah May 23, 2022
bda804b
Merge remote-tracking branch 'origin_src/main' into push-pull-v2
qweeah May 23, 2022
8433307
Undo pull changes
qweeah May 23, 2022
88c3ecd
Go module tidy
qweeah May 23, 2022
8d949af
Code clean
qweeah May 23, 2022
f25799f
Revamp pull
qweeah May 23, 2022
64cfab0
Add reading password
qweeah May 23, 2022
6668987
Add doc comments
qweeah May 23, 2022
e252a18
Nit
qweeah May 23, 2022
cd127cc
Resolve comments
qweeah May 24, 2022
a365049
Update comments
qweeah May 25, 2022
dd400a2
Make push options private
qweeah May 25, 2022
d41c2ad
Merge branch 'push-v2' into pull-v2
qweeah May 25, 2022
feb3111
Add pull status tracking
qweeah May 25, 2022
1cf4faa
Add manifest config option
qweeah May 26, 2022
6dbc942
Merge remote-tracking branch 'origin_src/main' into pull-v2
qweeah May 26, 2022
c199c3d
Code clean
qweeah May 26, 2022
cea9c67
Remove unused files
qweeah May 26, 2022
157a802
Update dependency
qweeah May 26, 2022
53f5f87
Resolve comments
qweeah May 27, 2022
8e61623
Code clean
qweeah May 28, 2022
3f424de
Use plain text for localhost
qweeah May 28, 2022
4956d79
Cache while pulling
qweeah May 28, 2022
1a88e5e
And empty pull detection
qweeah May 28, 2022
1a9fa1c
Code clean
qweeah May 28, 2022
14bf126
Merge branch 'pull-v2' of https://github.com/qweeah/oras into pull-v2
qweeah May 28, 2022
b0dc4ae
Code clean
qweeah May 28, 2022
f73667f
Merge remote-tracking branch 'origin_src/main' into pull-v2
qweeah May 30, 2022
62f06fe
Merge remote-tracking branch 'origin_src/main' into pull-v2
qweeah May 31, 2022
16f2623
Add plain http flag check for regsitry
qweeah Jun 1, 2022
2e3abb9
Remove unnecessary else
qweeah Jun 1, 2022
9d196fd
Change pull cache
qweeah Jun 2, 2022
8901ac9
Bug fix
qweeah Jun 2, 2022
c4ea9d5
Bug fix
qweeah Jun 2, 2022
9c06b08
Add unit test
qweeah Jun 2, 2022
afea181
Add doc
qweeah Jun 2, 2022
6876351
Use copy options in push
qweeah Jun 2, 2022
6908d59
Adjust formatting
qweeah Jun 2, 2022
775200c
Update go mod
qweeah Jun 2, 2022
46afaa8
Update go mod
qweeah Jun 3, 2022
0bc93f4
Rename package
qweeah Jun 3, 2022
0951ddc
Update status tracking for push
qweeah Jun 3, 2022
d2eef33
Switch to branch with cache option
qweeah Jun 4, 2022
8f0c8bd
Merge branch 'pull-v2' into copy-options
qweeah Jun 4, 2022
a8343ac
Add pull
qweeah Jun 4, 2022
cc13aa8
Refactor caching
qweeah Jun 5, 2022
effd6a5
Add exists
qweeah Jun 6, 2022
7006bec
Merge branch 'pull-v2' into copy-options
qweeah Jun 6, 2022
8c75a27
Add copy options for pulling
qweeah Jun 6, 2022
aeeec02
Change go mod
qweeah Jun 6, 2022
0f8a41e
Use copy options
qweeah Jun 15, 2022
97df960
Code clean
qweeah Jun 16, 2022
a766609
Resolve comments
qweeah Jun 21, 2022
360024a
Code clean
qweeah Jun 21, 2022
786e584
Remove config manifest
qweeah Jun 21, 2022
a2143fb
Code clean
qweeah Jun 21, 2022
7f572d6
Resolve comments
qweeah Jun 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 0 additions & 113 deletions cmd/oras/cache.go

This file was deleted.

32 changes: 32 additions & 0 deletions cmd/oras/internal/display/convert.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright The ORAS Authors.
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 display

import (
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)

// ShortDigest converts the digest of the descriptor to a short form for displaying.
func ShortDigest(desc ocispec.Descriptor) (digestString string) {
digestString = desc.Digest.String()
if err := desc.Digest.Validate(); err == nil {
if algo := desc.Digest.Algorithm(); algo == digest.SHA256 {
digestString = desc.Digest.Encoded()[:12]
}
}
return digestString
}
31 changes: 31 additions & 0 deletions cmd/oras/internal/display/print.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright The ORAS Authors.
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 display

import (
"fmt"
"sync"
)

var printLock sync.Mutex

// Print objects to display concurrent-safely
func Print(a ...any) error {
printLock.Lock()
defer printLock.Unlock()
_, err := fmt.Println(a...)
return err
}
15 changes: 12 additions & 3 deletions cmd/oras/internal/option/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"crypto/tls"
"fmt"
"io"
"net"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -131,7 +132,7 @@ func (opts *Remote) NewRegistry(hostname string, common Common) (reg *remote.Reg
if err != nil {
return nil, err
}
reg.PlainHTTP = opts.PlainHTTP
reg.PlainHTTP = opts.isPlainHttp(reg.Reference.Registry)
if reg.Client, err = opts.authClient(common.Debug); err != nil {
return nil, err
}
Expand All @@ -144,10 +145,18 @@ func (opts *Remote) NewRepository(reference string, common Common) (repo *remote
if err != nil {
return nil, err
}

repo.PlainHTTP = opts.PlainHTTP
repo.PlainHTTP = opts.isPlainHttp(repo.Reference.Registry)
if repo.Client, err = opts.authClient(common.Debug); err != nil {
return nil, err
}
return
}

// isPlainHttp returns the plain http flag for a given regsitry.
func (opts *Remote) isPlainHttp(registry string) bool {
host, _, _ := net.SplitHostPort(registry)
if host == "localhost" || registry == "localhost" {
return true
}
return opts.PlainHTTP
}
15 changes: 15 additions & 0 deletions cmd/oras/internal/option/remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,18 @@ func TestRemote_NewRepository(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}
}

func TestRemote_isPlainHttp_localhost(t *testing.T) {
opts := Remote{PlainHTTP: false}
got := opts.isPlainHttp("localhost")
if got != true {
t.Fatalf("tls should be disabled when domain is localhost")

}

got = opts.isPlainHttp("localhost:9090")
if got != true {
t.Fatalf("tls should be disabled when domain is localhost")

}
}
Loading