This repository has been archived by the owner on Feb 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 887
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support to import image from docker-daemon in rkt
Now you can import an image that is available in docker's image store on a local machine into rkt's imagestore. To do so run following command: ``` rkt fetch --insecure-options=all docker-daemon://docker.io/library/alpine ``` This will import the image `docker.io/library/alpine` into rkt's store.
- Loading branch information
Showing
314 changed files
with
27,158 additions
and
9,026 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,83 @@ | ||
package distribution | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
|
||
d2acommon "github.com/appc/docker2aci/lib/common" | ||
) | ||
|
||
const ( | ||
TypeDockerDaemon Type = "docker-daemon" | ||
) | ||
|
||
func init() { | ||
Register(TypeDockerDaemon, NewDockerDaemon) | ||
} | ||
|
||
type DockerDaemon struct { | ||
url string // a valid docker reference URL | ||
parsedURL *d2acommon.ParsedDockerURL | ||
|
||
full string // the full string representation for equals operations | ||
simple string // the user friendly (simple) string representation | ||
} | ||
|
||
func NewDockerDaemon(u *url.URL) (Distribution, error) { | ||
dp, err := parseCIMD(u) | ||
if err != nil { | ||
return nil, fmt.Errorf("cannot parse URI: %q: %v", u.String(), err) | ||
} | ||
if dp.Type != TypeDocker { | ||
return nil, fmt.Errorf("wrong distribution type: %q", dp.Type) | ||
} | ||
|
||
parsed, err := d2acommon.ParseDockerURL(dp.Data) | ||
if err != nil { | ||
return nil, fmt.Errorf("bad docker URL %q: %v", dp.Data, err) | ||
} | ||
|
||
return &DockerDaemon{ | ||
url: dp.Data, | ||
parsedURL: parsed, | ||
simple: SimpleDockerRef(parsed), | ||
full: FullDockerRef(parsed), | ||
}, nil | ||
} | ||
|
||
func NewDockerDaemonFromString(ds string) (Distribution, error) { | ||
urlStr := NewCIMDString(TypeDocker, distDockerVersion, ds) | ||
u, err := url.Parse(urlStr) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return NewDockerDaemon(u) | ||
} | ||
|
||
func (d *DockerDaemon) CIMD() *url.URL { | ||
uriStr := NewCIMDString(TypeDocker, distDockerVersion, d.url) | ||
// Create a copy of the URL | ||
u, err := url.Parse(uriStr) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return u | ||
} | ||
|
||
func (d *DockerDaemon) String() string { | ||
return d.simple | ||
} | ||
|
||
func (d *DockerDaemon) Equals(dist Distribution) bool { | ||
d2, ok := dist.(*DockerDaemon) | ||
if !ok { | ||
return false | ||
} | ||
|
||
return d.full == d2.full | ||
} | ||
|
||
// ReferenceURL returns the docker reference URL. | ||
func (d *DockerDaemon) ReferenceURL() string { | ||
return d.url | ||
} |
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 @@ | ||
package image |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.