Skip to content

Commit

Permalink
Fix: use proper OS separator depending on runtime (#751)
Browse files Browse the repository at this point in the history
* Fix: use proper OS separator depending on runtime

* Use strings.Fields

* Fix: dockerComposeVersion
  • Loading branch information
mtojek authored Mar 24, 2022
1 parent 867e842 commit 01d3a31
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (p *Project) WaitForHealthy(opts CommandOptions) error {
startTime := time.Now()
timeout := startTime.Add(waitForHealthyTimeout)

containerIDs := strings.Split(strings.TrimSpace(b.String()), "\n")
containerIDs := strings.Fields(b.String())
for {
if time.Now().After(timeout) {
return errors.New("timeout waiting for healthy container")
Expand Down Expand Up @@ -400,7 +400,7 @@ func (p *Project) dockerComposeVersion() (*semver.Version, error) {
return nil, errors.Wrap(err, "running Docker Compose version command failed")
}
dcVersion := b.String()
ver, err := semver.NewVersion(strings.Trim(dcVersion, "\n"))
ver, err := semver.NewVersion(strings.TrimSpace(dcVersion))
if err != nil {
return nil, errors.Wrapf(err, "docker compose version is not a valid semver (value: %s)", dcVersion)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ func ContainerID(containerName string) (string, error) {
if err != nil {
return "", errors.Wrapf(err, "could not find \"%s\" container (stderr=%q)", containerName, errOutput.String())
}
containerIDs := bytes.Split(bytes.TrimSpace(output), []byte{'\n'})
containerIDs := strings.Fields(string(output))
if len(containerIDs) != 1 {
return "", fmt.Errorf("expected single %s container", containerName)
}
return string(containerIDs[0]), nil
return containerIDs[0], nil
}

// InspectNetwork function returns the network description for the selected network.
Expand Down

0 comments on commit 01d3a31

Please sign in to comment.