mirror of
https://github.com/containers/podman.git
synced 2025-06-26 04:46:57 +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"
|
"strconv"
|
||||||
|
|
||||||
"github.com/containers/podman/v4/pkg/bindings"
|
"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 {
|
if options == nil {
|
||||||
options = new(SystemdOptions)
|
options = new(SystemdOptions)
|
||||||
}
|
}
|
||||||
@ -29,14 +29,14 @@ func Systemd(ctx context.Context, nameOrID string, options *SystemdOptions) (*en
|
|||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
report := &entities.GenerateSystemdReport{}
|
report := &types.GenerateSystemdReport{}
|
||||||
return report, response.Process(&report.Units)
|
return report, response.Process(&report.Units)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kube generate Kubernetes YAML (v1 specification)
|
// Kube generate Kubernetes YAML (v1 specification)
|
||||||
//
|
//
|
||||||
// Note: Caller is responsible for closing returned reader
|
// 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 {
|
if options == nil {
|
||||||
options = new(KubeOptions)
|
options = new(KubeOptions)
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ func Kube(ctx context.Context, nameOrIDs []string, options *KubeOptions) (*entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if response.StatusCode == http.StatusOK {
|
if response.StatusCode == http.StatusOK {
|
||||||
return &entities.GenerateKubeReport{Reader: response.Body}, nil
|
return &types.GenerateKubeReport{Reader: response.Body}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unpack the error.
|
// Unpack the error.
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package entities
|
package entities
|
||||||
|
|
||||||
import "io"
|
import (
|
||||||
|
"github.com/containers/podman/v4/pkg/domain/entities/types"
|
||||||
|
)
|
||||||
|
|
||||||
// GenerateSystemdOptions control the generation of systemd unit files.
|
// GenerateSystemdOptions control the generation of systemd unit files.
|
||||||
type GenerateSystemdOptions struct {
|
type GenerateSystemdOptions struct {
|
||||||
@ -22,10 +24,7 @@ type GenerateSystemdOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GenerateSystemdReport
|
// GenerateSystemdReport
|
||||||
type GenerateSystemdReport struct {
|
type GenerateSystemdReport = types.GenerateSystemdReport
|
||||||
// Units of the generate process. key = unit name -> value = unit content
|
|
||||||
Units map[string]string
|
|
||||||
}
|
|
||||||
|
|
||||||
// GenerateKubeOptions control the generation of Kubernetes YAML files.
|
// GenerateKubeOptions control the generation of Kubernetes YAML files.
|
||||||
type GenerateKubeOptions struct {
|
type GenerateKubeOptions struct {
|
||||||
@ -44,16 +43,9 @@ type GenerateKubeOptions struct {
|
|||||||
type KubeGenerateOptions = GenerateKubeOptions
|
type KubeGenerateOptions = GenerateKubeOptions
|
||||||
|
|
||||||
// GenerateKubeReport
|
// GenerateKubeReport
|
||||||
//
|
type GenerateKubeReport = types.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 GenerateSpecReport struct {
|
type GenerateSpecReport = types.GenerateSpecReport
|
||||||
Data []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
type GenerateSpecOptions struct {
|
type GenerateSpecOptions struct {
|
||||||
ID string
|
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