github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/pkg/domain/infra/tunnel/generate.go (about)

     1  package tunnel
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/hanks177/podman/v4/pkg/bindings/generate"
     7  	"github.com/hanks177/podman/v4/pkg/domain/entities"
     8  )
     9  
    10  func (ic *ContainerEngine) GenerateSystemd(ctx context.Context, nameOrID string, opts entities.GenerateSystemdOptions) (*entities.GenerateSystemdReport, error) {
    11  	options := new(
    12  		generate.SystemdOptions).
    13  		WithUseName(opts.Name).
    14  		WithContainerPrefix(opts.ContainerPrefix).
    15  		WithNew(opts.New).WithNoHeader(opts.NoHeader).
    16  		WithTemplateUnitFile(opts.TemplateUnitFile).
    17  		WithPodPrefix(opts.PodPrefix).
    18  		WithSeparator(opts.Separator).
    19  		WithWants(opts.Wants).
    20  		WithAfter(opts.After).
    21  		WithRequires(opts.Requires)
    22  
    23  	if opts.StartTimeout != nil {
    24  		options.WithStartTimeout(*opts.StartTimeout)
    25  	}
    26  	if opts.StopTimeout != nil {
    27  		options.WithStopTimeout(*opts.StopTimeout)
    28  	}
    29  	if opts.RestartPolicy != nil {
    30  		options.WithRestartPolicy(*opts.RestartPolicy)
    31  	}
    32  	if opts.RestartSec != nil {
    33  		options.WithRestartSec(*opts.RestartSec)
    34  	}
    35  
    36  	return generate.Systemd(ic.ClientCtx, nameOrID, options)
    37  }
    38  
    39  // GenerateKube Kubernetes YAML (v1 specification) for nameOrIDs
    40  //
    41  // Note: Caller is responsible for closing returned Reader
    42  func (ic *ContainerEngine) GenerateKube(ctx context.Context, nameOrIDs []string, opts entities.GenerateKubeOptions) (*entities.GenerateKubeReport, error) {
    43  	options := new(generate.KubeOptions).WithService(opts.Service)
    44  	return generate.Kube(ic.ClientCtx, nameOrIDs, options)
    45  }