Skip to content

Commit

Permalink
Merge pull request microsoft#190 from Microsoft/computesystem
Browse files Browse the repository at this point in the history
Container to ComputeSystem
  • Loading branch information
jstarks authored May 18, 2018
2 parents 4101bbe + 635af9b commit d93eb2b
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 205 deletions.
25 changes: 3 additions & 22 deletions container.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package hcsshim

import (
"os"
"time"

"github.com/Microsoft/hcsshim/internal/hcs"
Expand Down Expand Up @@ -56,32 +55,14 @@ const (
// Supported resource types are Network and Request Types are Add/Remove
type ResourceModificationRequestResponse = schema1.ResourceModificationRequestResponse

// createContainerAdditionalJSON is read from the environment at initialisation
// time. It allows an environment variable to define additional JSON which
// is merged in the CreateContainer call to HCS.
var createContainerAdditionalJSON string

func init() {
createContainerAdditionalJSON = os.Getenv("HCSSHIM_CREATECONTAINER_ADDITIONALJSON")
}

type container struct {
system *hcs.System
}

// CreateContainer creates a new container with the given configuration but does not start it.
func CreateContainer(id string, c *ContainerConfig) (Container, error) {
system, err := hcs.CreateContainer(id, c)
if err != nil {
return nil, err
}
return &container{system}, err
}

// CreateContainerWithJSON creates a new container with the given configuration but does not start it.
// It is identical to CreateContainer except that optional additional JSON can be merged before passing to HCS.
func CreateContainerWithJSON(id string, c *ContainerConfig, additionalJSON string) (Container, error) {
system, err := hcs.CreateContainerWithJSON(id, c, additionalJSON)
system, err := hcs.CreateComputeSystem(id, c, "")
if err != nil {
return nil, err
}
Expand All @@ -90,7 +71,7 @@ func CreateContainerWithJSON(id string, c *ContainerConfig, additionalJSON strin

// OpenContainer opens an existing container by ID.
func OpenContainer(id string) (Container, error) {
system, err := hcs.OpenContainer(id)
system, err := hcs.OpenComputeSystem(id)
if err != nil {
return nil, err
}
Expand All @@ -99,7 +80,7 @@ func OpenContainer(id string) (Container, error) {

// GetContainers gets a list of the containers on the system that match the query
func GetContainers(q ComputeSystemQuery) ([]ContainerProperties, error) {
return hcs.GetContainers(q)
return hcs.GetComputeSystems(q)
}

// Start synchronously starts the container.
Expand Down
Loading

0 comments on commit d93eb2b

Please sign in to comment.