Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
moby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
emulab
moby
Commits
6644a3c7
Commit
6644a3c7
authored
11 years ago
by
Joffrey F
Browse files
Options
Downloads
Patches
Plain Diff
Reactivated CmdPush in commands.go
parent
e179c664
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
commands.go
+59
-58
59 additions, 58 deletions
commands.go
graph.go
+1
-1
1 addition, 1 deletion
graph.go
with
60 additions
and
59 deletions
commands.go
+
59
−
58
View file @
6644a3c7
...
...
@@ -492,64 +492,65 @@ func (srv *Server) CmdImport(stdin io.ReadCloser, stdout rcli.DockerConn, args .
return
nil
}
// func (srv *Server) CmdPush(stdin io.ReadCloser, stdout rcli.DockerConn, args ...string) error {
// cmd := rcli.Subcmd(stdout, "push", "NAME", "Push an image or a repository to the registry")
// if err := cmd.Parse(args); err != nil {
// return nil
// }
// local := cmd.Arg(0)
// if local == "" {
// cmd.Usage()
// return nil
// }
// // If the login failed, abort
// if srv.runtime.authConfig == nil || srv.runtime.authConfig.Username == "" {
// if err := srv.CmdLogin(stdin, stdout, args...); err != nil {
// return err
// }
// if srv.runtime.authConfig == nil || srv.runtime.authConfig.Username == "" {
// return fmt.Errorf("Please login prior to push. ('docker login')")
// }
// }
// var remote string
// tmp := strings.SplitN(local, "/", 2)
// if len(tmp) == 1 {
// return fmt.Errorf(
// "Impossible to push a \"root\" repository. Please rename your repository in <user>/<repo> (ex: %s/%s)",
// srv.runtime.authConfig.Username, local)
// } else {
// remote = local
// }
// Debugf("Pushing [%s] to [%s]\n", local, remote)
// // Try to get the image
// // FIXME: Handle lookup
// // FIXME: Also push the tags in case of ./docker push myrepo:mytag
// // img, err := srv.runtime.LookupImage(cmd.Arg(0))
// img, err := srv.runtime.graph.Get(local)
// if err != nil {
// Debugf("The push refers to a repository [%s] (len: %d)\n", local, len(srv.runtime.repositories.Repositories[local]))
// // If it fails, try to get the repository
// if localRepo, exists := srv.runtime.repositories.Repositories[local]; exists {
// if err := srv.runtime.graph.PushRepository(stdout, remote, localRepo, srv.runtime.authConfig); err != nil {
// return err
// }
// return nil
// }
// return err
// }
// err = srv.runtime.graph.PushImage(stdout, img, srv.runtime.authConfig)
// if err != nil {
// return err
// }
// return nil
// }
func
(
srv
*
Server
)
CmdPush
(
stdin
io
.
ReadCloser
,
stdout
rcli
.
DockerConn
,
args
...
string
)
error
{
cmd
:=
rcli
.
Subcmd
(
stdout
,
"push"
,
"NAME"
,
"Push an image or a repository to the registry"
)
registry
:=
cmd
.
String
(
"registry"
,
""
,
"Registry host to push the image to"
)
if
err
:=
cmd
.
Parse
(
args
);
err
!=
nil
{
return
nil
}
local
:=
cmd
.
Arg
(
0
)
if
local
==
""
{
cmd
.
Usage
()
return
nil
}
// If the login failed AND we're using the index, abort
if
*
registry
==
""
&&
(
srv
.
runtime
.
authConfig
==
nil
||
srv
.
runtime
.
authConfig
.
Username
==
""
)
{
if
err
:=
srv
.
CmdLogin
(
stdin
,
stdout
,
args
...
);
err
!=
nil
{
return
err
}
if
srv
.
runtime
.
authConfig
==
nil
||
srv
.
runtime
.
authConfig
.
Username
==
""
{
return
fmt
.
Errorf
(
"Please login prior to push. ('docker login')"
)
}
}
var
remote
string
tmp
:=
strings
.
SplitN
(
local
,
"/"
,
2
)
if
len
(
tmp
)
==
1
{
return
fmt
.
Errorf
(
"Impossible to push a
\"
root
\"
repository. Please rename your repository in <user>/<repo> (ex: %s/%s)"
,
srv
.
runtime
.
authConfig
.
Username
,
local
)
}
else
{
remote
=
local
}
Debugf
(
"Pushing [%s] to [%s]
\n
"
,
local
,
remote
)
// Try to get the image
// FIXME: Handle lookup
// FIXME: Also push the tags in case of ./docker push myrepo:mytag
// img, err := srv.runtime.LookupImage(cmd.Arg(0))
img
,
err
:=
srv
.
runtime
.
graph
.
Get
(
local
)
if
err
!=
nil
{
Debugf
(
"The push refers to a repository [%s] (len: %d)
\n
"
,
local
,
len
(
srv
.
runtime
.
repositories
.
Repositories
[
local
]))
// If it fails, try to get the repository
if
localRepo
,
exists
:=
srv
.
runtime
.
repositories
.
Repositories
[
local
];
exists
{
if
err
:=
srv
.
runtime
.
graph
.
PushRepository
(
stdout
,
remote
,
localRepo
,
srv
.
runtime
.
authConfig
);
err
!=
nil
{
return
err
}
return
nil
}
return
err
}
err
=
srv
.
runtime
.
graph
.
PushImage
(
stdout
,
img
,
*
registry
,
nil
)
if
err
!=
nil
{
return
err
}
return
nil
}
func
(
srv
*
Server
)
CmdPull
(
stdin
io
.
ReadCloser
,
stdout
io
.
Writer
,
args
...
string
)
error
{
cmd
:=
rcli
.
Subcmd
(
stdout
,
"pull"
,
"NAME"
,
"Pull an image or a repository from the registry"
)
...
...
This diff is collapsed.
Click to expand it.
graph.go
+
1
−
1
View file @
6644a3c7
...
...
@@ -312,7 +312,7 @@ func (graph *Graph) Checksums(repo Repository) ([]map[string]string, error) {
i
:=
0
for
id
,
sum
:=
range
checksums
{
result
[
i
]
=
map
[
string
]
string
{
"id"
:
id
,
"id"
:
id
,
"checksum"
:
sum
,
}
i
++
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment