func info(logger log.Logger) (*providers.ProviderInfo, error) {
	const podman = "podman"
	args := []string{"info", "--format", "json"}
	cmd := exec.Command(podman, args...)
	out, err := exec.Output(cmd)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to get podman info (%s %s): %q",
			podman, strings.Join(args, " "), string(out))
	}
	var pInfo podmanInfo
	if err := json.Unmarshal(out, &pInfo); err != nil {
		return nil, err
	}
	stringSliceContains := func(s []string, str string) bool {
		for _, v := range s {
			if v == str {
				return true
			}
		}
		return false
	}

	// Since Podman version before v4.0.0 does not gives controller info.
	// We assume all the cgroup controllers to be available.
	// For rootless, this assumption is not always correct,
	// so we print the warning below.
	cgroupSupportsMemoryLimit := true
	cgroupSupportsPidsLimit := true
	cgroupSupportsCPUShares := true

	v, err := getPodmanVersion()
	if err != nil {
		return nil, errors.Wrap(err, "failed to check podman version")
	}
	// Info for controllers must be available after v4.0.0
	// via https://github.com/containers/podman/pull/10387
	if v.AtLeast(version.MustParseSemantic("4.0.0")) {
		cgroupSupportsMemoryLimit = stringSliceContains(pInfo.Host.CgroupControllers, "memory")
		cgroupSupportsPidsLimit = stringSliceContains(pInfo.Host.CgroupControllers, "pids")
		cgroupSupportsCPUShares = stringSliceContains(pInfo.Host.CgroupControllers, "cpu")
	}

	info := &providers.ProviderInfo{
		Rootless:            pInfo.Host.Security.Rootless,
		Cgroup2:             pInfo.Host.CgroupVersion == "v2",
		SupportsMemoryLimit: cgroupSupportsMemoryLimit,
		SupportsPidsLimit:   cgroupSupportsPidsLimit,
		SupportsCPUShares:   cgroupSupportsCPUShares,
	}
	if info.Rootless && !v.AtLeast(version.MustParseSemantic("4.0.0")) {
		logger.Warn("Cgroup controller detection is not implemented for Podman. " +
			"If you see cgroup-related errors, you might need to set systemd property \"Delegate=yes\", see https://kind.sigs.k8s.io/docs/user/rootless/")
	}
	return info, nil
}
// info detects ProviderInfo by executing `podman info --format json`.
info detects ProviderInfo by executing `podman info --format json`.
// info detects ProviderInfo by executing ` podman info -- format json ` .
func info(logger log.Logger) (*providers.ProviderInfo, error) {
	const podman = "podman"
	args := []string{"info", "--format", "json"}
	cmd := exec.Command(podman, args...)
	out, err := exec.Output(cmd)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to get podman info (%s %s): %q",
			podman, strings.Join(args, " "), string(out))
	}
	var pInfo podmanInfo
	if err := json.Unmarshal(out, &pInfo); err != nil {
		return nil, err
	}
	stringSliceContains := func(s []string, str string) bool {
		for _, v := range s {
			if v == str {
				return true
			}
		}
		return false
	}
	cgroupSupportsMemoryLimit := true
	cgroupSupportsPidsLimit := true
	cgroupSupportsCPUShares := true
	v, err := getPodmanVersion()
	if err != nil {
		return nil, errors.Wrap(err, "failed to check podman version")
	}
	if v.AtLeast(version.MustParseSemantic("4.0.0")) {
		cgroupSupportsMemoryLimit = stringSliceContains(pInfo.Host.CgroupControllers, "memory")
		cgroupSupportsPidsLimit = stringSliceContains(pInfo.Host.CgroupControllers, "pids")
		cgroupSupportsCPUShares = stringSliceContains(pInfo.Host.CgroupControllers, "cpu")
	}
	info := &providers.ProviderInfo{
		Rootless:            pInfo.Host.Security.Rootless,
		Cgroup2:             pInfo.Host.CgroupVersion == "v2",
		SupportsMemoryLimit: cgroupSupportsMemoryLimit,
		SupportsPidsLimit:   cgroupSupportsPidsLimit,
		SupportsCPUShares:   cgroupSupportsCPUShares,
	}
	if info.Rootless && !v.AtLeast(version.MustParseSemantic("4.0.0")) {
		logger.Warn("Cgroup controller detection is not implemented for Podman. " +
			"If you see cgroup-related errors, you might need to set systemd property \"Delegate=yes\", see https://kind.sigs.k8s.io/docs/user/rootless/")
	}
	return info, nil
}
func info ( logger log . Logger ) ( * providers . ProviderInfo , error ) { const podman = " " args := [ ] string { " " , " " , " " } cmd := exec . Command ( podman , args ... ) out , err := exec . Output ( cmd ) if err != nil { return nil , errors . Wrapf ( err , " " , podman , strings . Join ( args , " " ) , string ( out ) ) } var pInfo podmanInfo if err := json . Unmarshal ( out , & pInfo ) ; err != nil { return nil , err } stringSliceContains := func ( s [ ] string , str string ) bool { for _ , v := range s { if v == str { return true } } return false } cgroupSupportsMemoryLimit := true cgroupSupportsPidsLimit := true cgroupSupportsCPUShares := true v , err := getPodmanVersion ( ) if err != nil { return nil , errors . Wrap ( err , " " ) } if v . AtLeast ( version . MustParseSemantic ( " " ) ) { cgroupSupportsMemoryLimit = stringSliceContains ( pInfo . Host . CgroupControllers , " " ) cgroupSupportsPidsLimit = stringSliceContains ( pInfo . Host . CgroupControllers , " " ) cgroupSupportsCPUShares = stringSliceContains ( pInfo . Host . CgroupControllers , " " ) } info := & providers . ProviderInfo { Rootless : pInfo . Host . Security . Rootless , Cgroup2 : pInfo . Host . CgroupVersion == " " , SupportsMemoryLimit : cgroupSupportsMemoryLimit , SupportsPidsLimit : cgroupSupportsPidsLimit , SupportsCPUShares : cgroupSupportsCPUShares , } if info . Rootless && ! v . AtLeast ( version . MustParseSemantic ( " " ) ) { logger . Warn ( " " + " \" \" " ) } return info , nil }
info detects ProviderInfo by executing `podman info --format json`.
info detects ProviderInfo by executing ` podman info -- format json ` .
// Since Podman version before v4.0.0 does not gives controller info. // We assume all the cgroup controllers to be available. // For rootless, this assumption is not always correct, // so we print the warning below. // Info for controllers must be available after v4.0.0 // via https://github.com/containers/podman/pull/10387