mirror of
https://github.com/containers/podman.git
synced 2025-06-24 19:42:56 +08:00
bindings: generate uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -7,10 +7,10 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/containers/podman/v4/pkg/bindings"
|
||||
"github.com/containers/podman/v4/pkg/domain/entities"
|
||||
"github.com/containers/podman/v4/pkg/domain/entities/types"
|
||||
)
|
||||
|
||||
func Systemd(ctx context.Context, nameOrID string, options *SystemdOptions) (*entities.GenerateSystemdReport, error) {
|
||||
func Systemd(ctx context.Context, nameOrID string, options *SystemdOptions) (*types.GenerateSystemdReport, error) {
|
||||
if options == nil {
|
||||
options = new(SystemdOptions)
|
||||
}
|
||||
@ -29,14 +29,14 @@ func Systemd(ctx context.Context, nameOrID string, options *SystemdOptions) (*en
|
||||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
report := &entities.GenerateSystemdReport{}
|
||||
report := &types.GenerateSystemdReport{}
|
||||
return report, response.Process(&report.Units)
|
||||
}
|
||||
|
||||
// Kube generate Kubernetes YAML (v1 specification)
|
||||
//
|
||||
// Note: Caller is responsible for closing returned reader
|
||||
func Kube(ctx context.Context, nameOrIDs []string, options *KubeOptions) (*entities.GenerateKubeReport, error) {
|
||||
func Kube(ctx context.Context, nameOrIDs []string, options *KubeOptions) (*types.GenerateKubeReport, error) {
|
||||
if options == nil {
|
||||
options = new(KubeOptions)
|
||||
}
|
||||
@ -64,7 +64,7 @@ func Kube(ctx context.Context, nameOrIDs []string, options *KubeOptions) (*entit
|
||||
}
|
||||
|
||||
if response.StatusCode == http.StatusOK {
|
||||
return &entities.GenerateKubeReport{Reader: response.Body}, nil
|
||||
return &types.GenerateKubeReport{Reader: response.Body}, nil
|
||||
}
|
||||
|
||||
// Unpack the error.
|
||||
|
@ -1,6 +1,8 @@
|
||||
package entities
|
||||
|
||||
import "io"
|
||||
import (
|
||||
"github.com/containers/podman/v4/pkg/domain/entities/types"
|
||||
)
|
||||
|
||||
// GenerateSystemdOptions control the generation of systemd unit files.
|
||||
type GenerateSystemdOptions struct {
|
||||
@ -22,10 +24,7 @@ type GenerateSystemdOptions struct {
|
||||
}
|
||||
|
||||
// GenerateSystemdReport
|
||||
type GenerateSystemdReport struct {
|
||||
// Units of the generate process. key = unit name -> value = unit content
|
||||
Units map[string]string
|
||||
}
|
||||
type GenerateSystemdReport = types.GenerateSystemdReport
|
||||
|
||||
// GenerateKubeOptions control the generation of Kubernetes YAML files.
|
||||
type GenerateKubeOptions struct {
|
||||
@ -44,16 +43,9 @@ type GenerateKubeOptions struct {
|
||||
type KubeGenerateOptions = GenerateKubeOptions
|
||||
|
||||
// GenerateKubeReport
|
||||
//
|
||||
// FIXME: Podman4.0 should change io.Reader to io.ReaderCloser
|
||||
type GenerateKubeReport struct {
|
||||
// Reader - the io.Reader to reader the generated YAML file.
|
||||
Reader io.Reader
|
||||
}
|
||||
type GenerateKubeReport = types.GenerateKubeReport
|
||||
|
||||
type GenerateSpecReport struct {
|
||||
Data []byte
|
||||
}
|
||||
type GenerateSpecReport = types.GenerateSpecReport
|
||||
|
||||
type GenerateSpecOptions struct {
|
||||
ID string
|
||||
|
20
pkg/domain/entities/types/generate.go
Normal file
20
pkg/domain/entities/types/generate.go
Normal file
@ -0,0 +1,20 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
type GenerateSystemdReport struct {
|
||||
// Units of the generate process. key = unit name -> value = unit content
|
||||
Units map[string]string
|
||||
}
|
||||
|
||||
type GenerateKubeReport struct {
|
||||
// FIXME: Podman4.0 should change io.Reader to io.ReaderCloser
|
||||
// Reader - the io.Reader to reader the generated YAML file.
|
||||
Reader io.Reader
|
||||
}
|
||||
|
||||
type GenerateSpecReport struct {
|
||||
Data []byte
|
||||
}
|
Reference in New Issue
Block a user