...

Source file src/github.com/redhat-developer/odo/pkg/podman/info.go

Documentation: github.com/redhat-developer/odo/pkg/podman

     1  package podman
     2  
     3  import (
     4  	"encoding/json"
     5  	"fmt"
     6  	"os/exec"
     7  
     8  	"k8s.io/klog"
     9  )
    10  
    11  // podmanInfo originates from https://github.com/containers/podman/blob/main/libpod/define/info.go
    12  type podmanInfo struct {
    13  	Host *HostInfo `json:"host"`
    14  }
    15  
    16  type HostInfo struct {
    17  	CgroupsVersion string `json:"cgroupVersion"`
    18  }
    19  
    20  func (o *PodmanCli) getInfo() (podmanInfo, error) {
    21  	cmd := exec.Command(o.podmanCmd, append(o.containerRunGlobalExtraArgs, "info", "--format", "json")...)
    22  	klog.V(3).Infof("executing %v", cmd.Args)
    23  	out, err := cmd.Output()
    24  	if err != nil {
    25  		if exiterr, ok := err.(*exec.ExitError); ok {
    26  			err = fmt.Errorf("%s: %s", err, string(exiterr.Stderr))
    27  		}
    28  		return podmanInfo{}, err
    29  	}
    30  
    31  	var result podmanInfo
    32  
    33  	err = json.Unmarshal(out, &result)
    34  	return result, err
    35  }
    36  

View as plain text