@@ -3,24 +3,21 @@ package ctrd
33import (
44 "context"
55 "crypto/tls"
6- "encoding/json"
76 "net"
87 "net/http"
98 "time"
109
1110 "github.com/alibaba/pouch/apis/types"
1211 "github.com/alibaba/pouch/pkg/errtypes"
13- "github.com/alibaba/pouch/pkg/utils"
1412
1513 "github.com/containerd/containerd/containers"
1614 "github.com/containerd/containerd/errdefs"
1715 "github.com/containerd/containerd/namespaces"
1816 "github.com/containerd/containerd/oci"
1917 "github.com/containerd/containerd/remotes"
2018 "github.com/containerd/containerd/remotes/docker"
21- "github.com/opencontainers/go-digest"
2219 "github.com/opencontainers/image-spec/specs-go/v1"
23- specs "github.com/opencontainers/runtime-spec/specs-go"
20+ "github.com/opencontainers/runtime-spec/specs-go"
2421 "github.com/pkg/errors"
2522)
2623
@@ -80,19 +77,6 @@ func resolver(authConfig *types.AuthConfig) (remotes.Resolver, error) {
8077 return docker .NewResolver (options ), nil
8178}
8279
83- // generateID generates image's ID by the SHA256 hash of its configuration JSON.
84- func generateID (config * types.ImageInfo ) (digest.Digest , error ) {
85- var ID digest.Digest
86-
87- b , err := json .Marshal (config )
88- if err != nil {
89- return ID , err
90- }
91-
92- ID = digest .FromBytes (b )
93- return ID , nil
94- }
95-
9680// rootFSToAPIType transfer the rootfs from OCI format to Pouch format.
9781func rootFSToAPIType (rootFs * v1.RootFS ) types.ImageInfoRootFS {
9882 var layers []string
@@ -105,39 +89,6 @@ func rootFSToAPIType(rootFs *v1.RootFS) types.ImageInfoRootFS {
10589 }
10690}
10791
108- // ociImageToPouchImage transfer the image from OCI format to Pouch format.
109- func ociImageToPouchImage (ociImage v1.Image ) (types.ImageInfo , error ) {
110- imageConfig := ociImage .Config
111-
112- volumes := make (map [string ]interface {})
113- for k , obj := range imageConfig .Volumes {
114- volumes [k ] = obj
115- }
116- cfg := & types.ContainerConfig {
117- // TODO: add more fields
118- User : imageConfig .User ,
119- Env : imageConfig .Env ,
120- Entrypoint : imageConfig .Entrypoint ,
121- Cmd : imageConfig .Cmd ,
122- WorkingDir : imageConfig .WorkingDir ,
123- Labels : imageConfig .Labels ,
124- StopSignal : imageConfig .StopSignal ,
125- Volumes : volumes ,
126- }
127-
128- rootFs := rootFSToAPIType (& ociImage .RootFS )
129-
130- // FIXME need to refactor it and the ociImage's list interface.
131- imageInfo := types.ImageInfo {
132- Architecture : ociImage .Architecture ,
133- Config : cfg ,
134- CreatedAt : ociImage .Created .Format (utils .TimeLayout ),
135- Os : ociImage .OS ,
136- RootFS : & rootFs ,
137- }
138- return imageInfo , nil
139- }
140-
14192// toLinuxResources transfers Pouch Resources to LinuxResources.
14293func toLinuxResources (resources types.Resources ) (* specs.LinuxResources , error ) {
14394 r := & specs.LinuxResources {}
0 commit comments