mirror of
https://github.com/containers/podman.git
synced 2025-05-17 15:18:43 +08:00
Apply De Morgan's law
This fixes a bunch of "QF1001: could apply De Morgan's law" warnings from staticcheck linter. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@ -164,7 +164,7 @@ func imageSearch(cmd *cobra.Command, args []string) error {
|
|||||||
isJSON := report.IsJSON(searchOptions.Format)
|
isJSON := report.IsJSON(searchOptions.Format)
|
||||||
for i, element := range searchReport {
|
for i, element := range searchReport {
|
||||||
d := strings.ReplaceAll(element.Description, "\n", " ")
|
d := strings.ReplaceAll(element.Description, "\n", " ")
|
||||||
if len(d) > 44 && !(searchOptions.NoTrunc || isJSON) {
|
if len(d) > 44 && (!searchOptions.NoTrunc && !isJSON) {
|
||||||
d = strings.TrimSpace(d[:44]) + "..."
|
d = strings.TrimSpace(d[:44]) + "..."
|
||||||
}
|
}
|
||||||
searchReport[i].Description = d
|
searchReport[i].Description = d
|
||||||
|
@ -195,7 +195,7 @@ func (c *Container) getContainerInspectData(size bool, driverData *define.Driver
|
|||||||
// Check if healthcheck is not nil and --no-healthcheck option is not set.
|
// Check if healthcheck is not nil and --no-healthcheck option is not set.
|
||||||
// If --no-healthcheck is set Test will be always set to `[NONE]`, so the
|
// If --no-healthcheck is set Test will be always set to `[NONE]`, so the
|
||||||
// inspect status should be set to nil.
|
// inspect status should be set to nil.
|
||||||
if c.config.HealthCheckConfig != nil && !(len(c.config.HealthCheckConfig.Test) == 1 && c.config.HealthCheckConfig.Test[0] == "NONE") {
|
if c.config.HealthCheckConfig != nil && (len(c.config.HealthCheckConfig.Test) != 1 || c.config.HealthCheckConfig.Test[0] != "NONE") {
|
||||||
// This container has a healthcheck defined in it; we need to add its state
|
// This container has a healthcheck defined in it; we need to add its state
|
||||||
healthCheckState, err := c.readHealthCheckLog()
|
healthCheckState, err := c.readHealthCheckLog()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -215,7 +215,7 @@ func (c *Container) getContainerInspectData(size bool, driverData *define.Driver
|
|||||||
data.NetworkSettings = networkConfig
|
data.NetworkSettings = networkConfig
|
||||||
// Ports in NetworkSettings includes exposed ports for network modes that are not host,
|
// Ports in NetworkSettings includes exposed ports for network modes that are not host,
|
||||||
// and not container.
|
// and not container.
|
||||||
if !(c.config.NetNsCtr != "" || c.NetworkMode() == "host") {
|
if c.config.NetNsCtr == "" && c.NetworkMode() != "host" {
|
||||||
addInspectPortsExpose(c.config.ExposedPorts, data.NetworkSettings.Ports)
|
addInspectPortsExpose(c.config.ExposedPorts, data.NetworkSettings.Ports)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1333,7 +1333,7 @@ func (c *Container) start() error {
|
|||||||
// Check if healthcheck is not nil and --no-healthcheck option is not set.
|
// Check if healthcheck is not nil and --no-healthcheck option is not set.
|
||||||
// If --no-healthcheck is set Test will be always set to `[NONE]` so no need
|
// If --no-healthcheck is set Test will be always set to `[NONE]` so no need
|
||||||
// to update status in such case.
|
// to update status in such case.
|
||||||
if c.config.HealthCheckConfig != nil && !(len(c.config.HealthCheckConfig.Test) == 1 && c.config.HealthCheckConfig.Test[0] == "NONE") {
|
if c.config.HealthCheckConfig != nil && (len(c.config.HealthCheckConfig.Test) != 1 || c.config.HealthCheckConfig.Test[0] != "NONE") {
|
||||||
if err := c.updateHealthStatus(define.HealthCheckStarting); err != nil {
|
if err := c.updateHealthStatus(define.HealthCheckStarting); err != nil {
|
||||||
return fmt.Errorf("update healthcheck status: %w", err)
|
return fmt.Errorf("update healthcheck status: %w", err)
|
||||||
}
|
}
|
||||||
@ -1622,7 +1622,7 @@ func (c *Container) unpause() error {
|
|||||||
|
|
||||||
isStartupHealthCheck := c.config.StartupHealthCheckConfig != nil && !c.state.StartupHCPassed
|
isStartupHealthCheck := c.config.StartupHealthCheckConfig != nil && !c.state.StartupHCPassed
|
||||||
isHealthCheckEnabled := c.config.HealthCheckConfig != nil &&
|
isHealthCheckEnabled := c.config.HealthCheckConfig != nil &&
|
||||||
!(len(c.config.HealthCheckConfig.Test) == 1 && c.config.HealthCheckConfig.Test[0] == "NONE")
|
(len(c.config.HealthCheckConfig.Test) != 1 || c.config.HealthCheckConfig.Test[0] != "NONE")
|
||||||
if isHealthCheckEnabled || isStartupHealthCheck {
|
if isHealthCheckEnabled || isStartupHealthCheck {
|
||||||
timer := c.config.HealthCheckConfig.Interval.String()
|
timer := c.config.HealthCheckConfig.Interval.String()
|
||||||
if isStartupHealthCheck {
|
if isStartupHealthCheck {
|
||||||
|
@ -20,7 +20,7 @@ func (c *Container) validate() error {
|
|||||||
rootfsSet := c.config.Rootfs != ""
|
rootfsSet := c.config.Rootfs != ""
|
||||||
|
|
||||||
// If one of RootfsImageIDor RootfsImageName are set, both must be set.
|
// If one of RootfsImageIDor RootfsImageName are set, both must be set.
|
||||||
if (imageIDSet || imageNameSet) && !(imageIDSet && imageNameSet) {
|
if (imageIDSet || imageNameSet) && (!imageIDSet || !imageNameSet) {
|
||||||
return fmt.Errorf("both RootfsImageName and RootfsImageID must be set if either is set: %w", define.ErrInvalidArg)
|
return fmt.Errorf("both RootfsImageName and RootfsImageID must be set if either is set: %w", define.ErrInvalidArg)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ func (c *Container) validate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Must set at least one of RootfsImageID or Rootfs
|
// Must set at least one of RootfsImageID or Rootfs
|
||||||
if !(imageIDSet || rootfsSet) {
|
if !imageIDSet && !rootfsSet {
|
||||||
return fmt.Errorf("must set root filesystem source to either image or rootfs: %w", define.ErrInvalidArg)
|
return fmt.Errorf("must set root filesystem source to either image or rootfs: %w", define.ErrInvalidArg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ func (p *Pod) getInfraContainer() (*Container, error) {
|
|||||||
|
|
||||||
func GenerateForKubeDaemonSet(ctx context.Context, pod *YAMLPod, options entities.GenerateKubeOptions) (*YAMLDaemonSet, error) {
|
func GenerateForKubeDaemonSet(ctx context.Context, pod *YAMLPod, options entities.GenerateKubeOptions) (*YAMLDaemonSet, error) {
|
||||||
// Restart policy for DaemonSets can only be set to Always
|
// Restart policy for DaemonSets can only be set to Always
|
||||||
if !(pod.Spec.RestartPolicy == "" || pod.Spec.RestartPolicy == v1.RestartPolicyAlways) {
|
if pod.Spec.RestartPolicy != "" && pod.Spec.RestartPolicy != v1.RestartPolicyAlways {
|
||||||
return nil, fmt.Errorf("k8s DaemonSets can only have restartPolicy set to Always")
|
return nil, fmt.Errorf("k8s DaemonSets can only have restartPolicy set to Always")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ func GenerateForKubeDaemonSet(ctx context.Context, pod *YAMLPod, options entitie
|
|||||||
// kind YAML.
|
// kind YAML.
|
||||||
func GenerateForKubeDeployment(ctx context.Context, pod *YAMLPod, options entities.GenerateKubeOptions) (*YAMLDeployment, error) {
|
func GenerateForKubeDeployment(ctx context.Context, pod *YAMLPod, options entities.GenerateKubeOptions) (*YAMLDeployment, error) {
|
||||||
// Restart policy for Deployments can only be set to Always
|
// Restart policy for Deployments can only be set to Always
|
||||||
if options.Type == define.K8sKindDeployment && !(pod.Spec.RestartPolicy == "" || pod.Spec.RestartPolicy == v1.RestartPolicyAlways) {
|
if options.Type == define.K8sKindDeployment && (pod.Spec.RestartPolicy != "" && pod.Spec.RestartPolicy != v1.RestartPolicyAlways) {
|
||||||
return nil, fmt.Errorf("k8s Deployments can only have restartPolicy set to Always")
|
return nil, fmt.Errorf("k8s Deployments can only have restartPolicy set to Always")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -815,7 +815,7 @@ func simplePodWithV1Containers(ctx context.Context, ctrs []*Container, getServic
|
|||||||
if !ctr.HostNetwork() {
|
if !ctr.HostNetwork() {
|
||||||
hostNetwork = false
|
hostNetwork = false
|
||||||
}
|
}
|
||||||
if !(ctr.IDMappings().HostUIDMapping && ctr.IDMappings().HostGIDMapping) {
|
if !ctr.IDMappings().HostUIDMapping || !ctr.IDMappings().HostGIDMapping {
|
||||||
hostUsers = false
|
hostUsers = false
|
||||||
}
|
}
|
||||||
kubeCtr, kubeVols, ctrDNS, annotations, err := containerToV1Container(ctx, ctr, getService)
|
kubeCtr, kubeVols, ctrDNS, annotations, err := containerToV1Container(ctx, ctr, getService)
|
||||||
|
@ -293,7 +293,7 @@ func (c *Container) getContainerNetworkInfo() (*define.InspectNetworkSettings, e
|
|||||||
// if not only the default network is connected we can return here
|
// if not only the default network is connected we can return here
|
||||||
// otherwise we have to populate the InspectBasicNetworkConfig settings
|
// otherwise we have to populate the InspectBasicNetworkConfig settings
|
||||||
_, isDefaultNet := networks[c.runtime.config.Network.DefaultNetwork]
|
_, isDefaultNet := networks[c.runtime.config.Network.DefaultNetwork]
|
||||||
if !(len(networks) == 1 && isDefaultNet) {
|
if len(networks) != 1 || !isDefaultNet {
|
||||||
return settings, nil
|
return settings, nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -464,7 +464,7 @@ func (r *Runtime) removeVolume(ctx context.Context, v *Volume, force bool, timeo
|
|||||||
} else if v.config.Driver == define.VolumeDriverImage {
|
} else if v.config.Driver == define.VolumeDriverImage {
|
||||||
if err := v.runtime.storageService.DeleteContainer(v.config.StorageID); err != nil {
|
if err := v.runtime.storageService.DeleteContainer(v.config.StorageID); err != nil {
|
||||||
// Storage container is already gone, no problem.
|
// Storage container is already gone, no problem.
|
||||||
if !(errors.Is(err, storage.ErrNotAContainer) || errors.Is(err, storage.ErrContainerUnknown)) {
|
if !errors.Is(err, storage.ErrNotAContainer) && !errors.Is(err, storage.ErrContainerUnknown) {
|
||||||
return fmt.Errorf("removing volume %s storage: %w", v.Name(), err)
|
return fmt.Errorf("removing volume %s storage: %w", v.Name(), err)
|
||||||
}
|
}
|
||||||
logrus.Infof("Storage for volume %s already removed", v.Name())
|
logrus.Infof("Storage for volume %s already removed", v.Name())
|
||||||
|
@ -275,7 +275,7 @@ func (v *Volume) UsesVolumeDriver() bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return !(v.config.Driver == define.VolumeDriverLocal || v.config.Driver == "")
|
return v.config.Driver != define.VolumeDriverLocal && v.config.Driver != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Volume) Mount() (string, error) {
|
func (v *Volume) Mount() (string, error) {
|
||||||
|
@ -40,7 +40,7 @@ func LogsFromContainer(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !(query.Stdout || query.Stderr) {
|
if !query.Stdout && !query.Stderr {
|
||||||
msg := fmt.Sprintf("%s: you must choose at least one stream", http.StatusText(http.StatusBadRequest))
|
msg := fmt.Sprintf("%s: you must choose at least one stream", http.StatusText(http.StatusBadRequest))
|
||||||
utils.Error(w, http.StatusBadRequest, fmt.Errorf("%s for %s", msg, r.URL.String()))
|
utils.Error(w, http.StatusBadRequest, fmt.Errorf("%s for %s", msg, r.URL.String()))
|
||||||
return
|
return
|
||||||
|
@ -258,7 +258,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
for _, containerfile := range m {
|
for _, containerfile := range m {
|
||||||
// Add path to containerfile iff it is not URL
|
// Add path to containerfile iff it is not URL
|
||||||
if !(strings.HasPrefix(containerfile, "http://") || strings.HasPrefix(containerfile, "https://")) {
|
if !strings.HasPrefix(containerfile, "http://") && !strings.HasPrefix(containerfile, "https://") {
|
||||||
containerfile = filepath.Join(contextDirectory,
|
containerfile = filepath.Join(contextDirectory,
|
||||||
filepath.Clean(filepath.FromSlash(containerfile)))
|
filepath.Clean(filepath.FromSlash(containerfile)))
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func NewCompatAPIDecoder() *schema.Decoder {
|
|||||||
// mimic behaviour of github.com/docker/docker/api/server/httputils.BoolValue()
|
// mimic behaviour of github.com/docker/docker/api/server/httputils.BoolValue()
|
||||||
dec.RegisterConverter(true, func(s string) reflect.Value {
|
dec.RegisterConverter(true, func(s string) reflect.Value {
|
||||||
s = strings.ToLower(strings.TrimSpace(s))
|
s = strings.ToLower(strings.TrimSpace(s))
|
||||||
return reflect.ValueOf(!(s == "" || s == "0" || s == "no" || s == "false" || s == "none"))
|
return reflect.ValueOf(s != "" && s != "0" && s != "no" && s != "false" && s != "none")
|
||||||
})
|
})
|
||||||
|
|
||||||
return dec
|
return dec
|
||||||
|
@ -45,9 +45,9 @@ func Attach(ctx context.Context, nameOrID string, stdin io.Reader, stdout io.Wri
|
|||||||
stdout bool
|
stdout bool
|
||||||
stderr bool
|
stderr bool
|
||||||
}{
|
}{
|
||||||
stdin: !(stdin == nil || reflect.ValueOf(stdin).IsNil()),
|
stdin: stdin != nil && !reflect.ValueOf(stdin).IsNil(),
|
||||||
stdout: !(stdout == nil || reflect.ValueOf(stdout).IsNil()),
|
stdout: stdout != nil && !reflect.ValueOf(stdout).IsNil(),
|
||||||
stderr: !(stderr == nil || reflect.ValueOf(stderr).IsNil()),
|
stderr: stderr != nil && !reflect.ValueOf(stderr).IsNil(),
|
||||||
}
|
}
|
||||||
// Ensure golang can determine that interfaces are "really" nil
|
// Ensure golang can determine that interfaces are "really" nil
|
||||||
if !isSet.stdin {
|
if !isSet.stdin {
|
||||||
@ -138,7 +138,7 @@ func Attach(ctx context.Context, nameOrID string, stdin io.Reader, stdout io.Wri
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !(response.IsSuccess() || response.IsInformational()) {
|
if !response.IsSuccess() && !response.IsInformational() {
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
return response.Process(nil)
|
return response.Process(nil)
|
||||||
}
|
}
|
||||||
@ -496,7 +496,7 @@ func ExecStartAndAttach(ctx context.Context, sessionID string, options *ExecStar
|
|||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
if !(response.IsSuccess() || response.IsInformational()) {
|
if !response.IsSuccess() && !response.IsInformational() {
|
||||||
return response.Process(nil)
|
return response.Process(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ func Logs(ctx context.Context, nameOrID string, options *LogOptions, stdoutChan,
|
|||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
// if not success handle and return possible error message
|
// if not success handle and return possible error message
|
||||||
if !(response.IsSuccess() || response.IsInformational()) {
|
if !response.IsSuccess() && !response.IsInformational() {
|
||||||
return response.Process(nil)
|
return response.Process(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin
|
|||||||
// Issue #7384 and #11384: If the container is configured for
|
// Issue #7384 and #11384: If the container is configured for
|
||||||
// auto-removal, it might already have been removed at this point.
|
// auto-removal, it might already have been removed at this point.
|
||||||
// We still need to clean up since we do not know if the other cleanup process is successful
|
// We still need to clean up since we do not know if the other cleanup process is successful
|
||||||
if !(errors.Is(err, define.ErrNoSuchCtr) || errors.Is(err, define.ErrCtrRemoved)) {
|
if !errors.Is(err, define.ErrNoSuchCtr) && !errors.Is(err, define.ErrCtrRemoved) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -498,7 +498,7 @@ func (ic *ContainerEngine) ContainerRm(ctx context.Context, namesOrIds []string,
|
|||||||
for ctr, err := range ctrsMap {
|
for ctr, err := range ctrsMap {
|
||||||
report := new(reports.RmReport)
|
report := new(reports.RmReport)
|
||||||
report.Id = ctr
|
report.Id = ctr
|
||||||
if !(errors.Is(err, define.ErrNoSuchCtr) || errors.Is(err, define.ErrCtrRemoved)) {
|
if !errors.Is(err, define.ErrNoSuchCtr) && !errors.Is(err, define.ErrCtrRemoved) {
|
||||||
report.Err = err
|
report.Err = err
|
||||||
}
|
}
|
||||||
report.RawInput = idToRawInput[ctr]
|
report.RawInput = idToRawInput[ctr]
|
||||||
|
@ -157,7 +157,7 @@ func (ic *ContainerEngine) GenerateKube(ctx context.Context, nameOrIDs []string,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !(podConfig.UsePodIPC && podConfig.UsePodNet && podConfig.UsePodUTS) {
|
if !podConfig.UsePodIPC || !podConfig.UsePodNet || !podConfig.UsePodUTS {
|
||||||
defaultKubeNS = false
|
defaultKubeNS = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,7 +639,7 @@ func removeErrorsToExitCode(rmErrors []error) int {
|
|||||||
// One of the specified images has child images or is
|
// One of the specified images has child images or is
|
||||||
// being used by a container.
|
// being used by a container.
|
||||||
return 2
|
return 2
|
||||||
case noSuchImageErrors && !(otherErrors || inUseErrors):
|
case noSuchImageErrors && (!otherErrors && !inUseErrors):
|
||||||
// One of the specified images did not exist, and no other
|
// One of the specified images did not exist, and no other
|
||||||
// failures.
|
// failures.
|
||||||
return 1
|
return 1
|
||||||
|
@ -192,7 +192,7 @@ func (ic *ContainerEngine) PodUnpause(ctx context.Context, namesOrIds []string,
|
|||||||
func (ic *ContainerEngine) PodStop(ctx context.Context, namesOrIds []string, options entities.PodStopOptions) ([]*entities.PodStopReport, error) {
|
func (ic *ContainerEngine) PodStop(ctx context.Context, namesOrIds []string, options entities.PodStopOptions) ([]*entities.PodStopReport, error) {
|
||||||
reports := []*entities.PodStopReport{}
|
reports := []*entities.PodStopReport{}
|
||||||
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil && !(options.Ignore && errors.Is(err, define.ErrNoSuchPod)) {
|
if err != nil && (!options.Ignore || !errors.Is(err, define.ErrNoSuchPod)) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, p := range pods {
|
for _, p := range pods {
|
||||||
@ -276,7 +276,7 @@ func (ic *ContainerEngine) PodStart(ctx context.Context, namesOrIds []string, op
|
|||||||
|
|
||||||
func (ic *ContainerEngine) PodRm(ctx context.Context, namesOrIds []string, options entities.PodRmOptions) ([]*entities.PodRmReport, error) {
|
func (ic *ContainerEngine) PodRm(ctx context.Context, namesOrIds []string, options entities.PodRmOptions) ([]*entities.PodRmReport, error) {
|
||||||
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil && !(options.Ignore && errors.Is(err, define.ErrNoSuchPod)) {
|
if err != nil && (!options.Ignore || !errors.Is(err, define.ErrNoSuchPod)) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
reports := make([]*entities.PodRmReport, 0, len(pods))
|
reports := make([]*entities.PodRmReport, 0, len(pods))
|
||||||
|
@ -166,7 +166,7 @@ func (n UsernsMode) GetKeepIDOptions() (*KeepIDUserNsOptions, error) {
|
|||||||
|
|
||||||
// IsPrivate indicates whether the container uses the a private userns.
|
// IsPrivate indicates whether the container uses the a private userns.
|
||||||
func (n UsernsMode) IsPrivate() bool {
|
func (n UsernsMode) IsPrivate() bool {
|
||||||
return !(n.IsHost() || n.IsContainer())
|
return !n.IsHost() && !n.IsContainer()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid indicates whether the userns is valid.
|
// Valid indicates whether the userns is valid.
|
||||||
@ -306,7 +306,7 @@ type PidMode string
|
|||||||
|
|
||||||
// IsPrivate indicates whether the container uses its own new pid namespace.
|
// IsPrivate indicates whether the container uses its own new pid namespace.
|
||||||
func (n PidMode) IsPrivate() bool {
|
func (n PidMode) IsPrivate() bool {
|
||||||
return !(n.IsHost() || n.IsContainer())
|
return !n.IsHost() && !n.IsContainer()
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsHost indicates whether the container uses the host's pid namespace.
|
// IsHost indicates whether the container uses the host's pid namespace.
|
||||||
@ -364,7 +364,7 @@ func (n NetworkMode) IsDefault() bool {
|
|||||||
|
|
||||||
// IsPrivate indicates whether container uses its private network stack.
|
// IsPrivate indicates whether container uses its private network stack.
|
||||||
func (n NetworkMode) IsPrivate() bool {
|
func (n NetworkMode) IsPrivate() bool {
|
||||||
return !(n.IsHost() || n.IsContainer())
|
return !n.IsHost() && !n.IsContainer()
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsContainer indicates whether container uses a container network stack.
|
// IsContainer indicates whether container uses a container network stack.
|
||||||
|
@ -160,7 +160,7 @@ func GenVolumeMounts(volumeFlag []string) (map[string]spec.Mount, map[string]*Na
|
|||||||
if (workDirFlag && !upperDirFlag) || (!workDirFlag && upperDirFlag) {
|
if (workDirFlag && !upperDirFlag) || (!workDirFlag && upperDirFlag) {
|
||||||
return nil, nil, nil, errors.New("must set both `upperdir` and `workdir`")
|
return nil, nil, nil, errors.New("must set both `upperdir` and `workdir`")
|
||||||
}
|
}
|
||||||
if len(options) > 2 && !(len(options) == 3 && upperDirFlag && workDirFlag) || (len(options) == 2 && !chownFlag) {
|
if len(options) > 2 && (len(options) != 3 || !upperDirFlag || !workDirFlag) || (len(options) == 2 && !chownFlag) {
|
||||||
return nil, nil, nil, errors.New("can't use 'O' with other options")
|
return nil, nil, nil, errors.New("can't use 'O' with other options")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ func FindMountType(input string) (mountType string, tokens []string, err error)
|
|||||||
}
|
}
|
||||||
for _, s := range records[0] {
|
for _, s := range records[0] {
|
||||||
kv := strings.Split(s, "=")
|
kv := strings.Split(s, "=")
|
||||||
if found || !(len(kv) == 2 && kv[0] == "type") {
|
if found || (len(kv) != 2 || kv[0] != "type") {
|
||||||
tokens = append(tokens, s)
|
tokens = append(tokens, s)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ loop1:
|
|||||||
goto finishForceTerminate
|
goto finishForceTerminate
|
||||||
case strings.ContainsRune(separators, rune(c)):
|
case strings.ContainsRune(separators, rune(c)):
|
||||||
if flags&SplitDontCoalesceSeparators != 0 {
|
if flags&SplitDontCoalesceSeparators != 0 {
|
||||||
if !(flags&SplitRetainSeparators != 0) {
|
if flags&SplitRetainSeparators == 0 {
|
||||||
p++
|
p++
|
||||||
}
|
}
|
||||||
goto finishForceNext
|
goto finishForceNext
|
||||||
@ -332,7 +332,7 @@ loop1:
|
|||||||
if flags&SplitUnquote != 0 {
|
if flags&SplitUnquote != 0 {
|
||||||
break quoteloop
|
break quoteloop
|
||||||
}
|
}
|
||||||
case c == '\\' && !(flags&SplitRetainEscape != 0):
|
case c == '\\' && (flags&SplitRetainEscape == 0):
|
||||||
backslash = true
|
backslash = true
|
||||||
break quoteloop
|
break quoteloop
|
||||||
}
|
}
|
||||||
@ -354,18 +354,18 @@ loop1:
|
|||||||
if flags&SplitUnquote != 0 {
|
if flags&SplitUnquote != 0 {
|
||||||
break nonquoteloop
|
break nonquoteloop
|
||||||
}
|
}
|
||||||
case c == '\\' && !(flags&SplitRetainEscape != 0):
|
case c == '\\' && (flags&SplitRetainEscape == 0):
|
||||||
backslash = true
|
backslash = true
|
||||||
break nonquoteloop
|
break nonquoteloop
|
||||||
case strings.ContainsRune(separators, rune(c)):
|
case strings.ContainsRune(separators, rune(c)):
|
||||||
if flags&SplitDontCoalesceSeparators != 0 {
|
if flags&SplitDontCoalesceSeparators != 0 {
|
||||||
if !(flags&SplitRetainSeparators != 0) {
|
if flags&SplitRetainSeparators == 0 {
|
||||||
p++
|
p++
|
||||||
}
|
}
|
||||||
goto finishForceNext
|
goto finishForceNext
|
||||||
}
|
}
|
||||||
|
|
||||||
if !(flags&SplitRetainSeparators != 0) {
|
if flags&SplitRetainSeparators == 0 {
|
||||||
/* Skip additional coalesced separators. */
|
/* Skip additional coalesced separators. */
|
||||||
for ; ; c = nextChar() {
|
for ; ; c = nextChar() {
|
||||||
if c == 0 {
|
if c == 0 {
|
||||||
|
@ -579,7 +579,7 @@ func ConvertContainer(container *parser.UnitFile, isUser bool, unitsInfoMap map[
|
|||||||
|
|
||||||
// Only allow mixed or control-group, as nothing else works well
|
// Only allow mixed or control-group, as nothing else works well
|
||||||
killMode, ok := service.Lookup(ServiceGroup, "KillMode")
|
killMode, ok := service.Lookup(ServiceGroup, "KillMode")
|
||||||
if !ok || !(killMode == "mixed" || killMode == "control-group") {
|
if !ok || (killMode != "mixed" && killMode != "control-group") {
|
||||||
if ok {
|
if ok {
|
||||||
return nil, warnings, fmt.Errorf("invalid KillMode '%s'", killMode)
|
return nil, warnings, fmt.Errorf("invalid KillMode '%s'", killMode)
|
||||||
}
|
}
|
||||||
@ -1222,7 +1222,7 @@ func ConvertKube(kube *parser.UnitFile, unitsInfoMap map[string]*UnitInfo, isUse
|
|||||||
|
|
||||||
// Only allow mixed or control-group, as nothing else works well
|
// Only allow mixed or control-group, as nothing else works well
|
||||||
killMode, ok := service.Lookup(ServiceGroup, "KillMode")
|
killMode, ok := service.Lookup(ServiceGroup, "KillMode")
|
||||||
if !ok || !(killMode == "mixed" || killMode == "control-group") {
|
if !ok || (killMode != "mixed" && killMode != "control-group") {
|
||||||
if ok {
|
if ok {
|
||||||
return nil, fmt.Errorf("invalid KillMode '%s'", killMode)
|
return nil, fmt.Errorf("invalid KillMode '%s'", killMode)
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ func GetTimestamp(value string, reference time.Time) (string, error) {
|
|||||||
|
|
||||||
var format string
|
var format string
|
||||||
// if the string has a Z or a + or three dashes use parse otherwise use parseinlocation
|
// if the string has a Z or a + or three dashes use parse otherwise use parseinlocation
|
||||||
parseInLocation := !(strings.ContainsAny(value, "zZ+") || strings.Count(value, "-") == 3)
|
parseInLocation := !strings.ContainsAny(value, "zZ+") && strings.Count(value, "-") != 3
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case strings.Contains(value, "."):
|
case strings.Contains(value, "."):
|
||||||
|
Reference in New Issue
Block a user