mirror of
https://github.com/containers/podman.git
synced 2025-12-04 04:09:40 +08:00
With the advent of Podman 2.0.0 we crossed the magical barrier of go modules. While we were able to continue importing all packages inside of the project, the project could not be vendored anymore from the outside. Move the go module to new major version and change all imports to `github.com/containers/libpod/v2`. The renaming of the imports was done via `gomove` [1]. [1] https://github.com/KSubedi/gomove Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
31 lines
797 B
Go
31 lines
797 B
Go
package containers
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/containers/libpod/v2/pkg/bindings"
|
|
"github.com/containers/libpod/v2/pkg/domain/entities"
|
|
"github.com/containers/libpod/v2/pkg/specgen"
|
|
jsoniter "github.com/json-iterator/go"
|
|
)
|
|
|
|
func CreateWithSpec(ctx context.Context, s *specgen.SpecGenerator) (entities.ContainerCreateResponse, error) {
|
|
var ccr entities.ContainerCreateResponse
|
|
conn, err := bindings.GetClient(ctx)
|
|
if err != nil {
|
|
return ccr, err
|
|
}
|
|
specgenString, err := jsoniter.MarshalToString(s)
|
|
if err != nil {
|
|
return ccr, err
|
|
}
|
|
stringReader := strings.NewReader(specgenString)
|
|
response, err := conn.DoRequest(stringReader, http.MethodPost, "/containers/create", nil, nil)
|
|
if err != nil {
|
|
return ccr, err
|
|
}
|
|
return ccr, response.Process(&ccr)
|
|
}
|