Skip to content

pkg/ioutils: TempDir: move to pkg/longpath#44515

Merged
thaJeztah merged 4 commits intomoby:masterfrom
thaJeztah:move_ioutils_tempdir
Dec 21, 2022
Merged

pkg/ioutils: TempDir: move to pkg/longpath#44515
thaJeztah merged 4 commits intomoby:masterfrom
thaJeztah:move_ioutils_tempdir

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah commented Nov 23, 2022

This utility wasn't very related to all other utilities in pkg/ioutils.
Moving it to longpath to also make it more clear what it does.

It looks like there's only a single (public) external consumer of this
utility, and only used in a test, and it's not 100% clear if it was
intentional to use our package, of if it was a case of "I actually meant
io/ioutil.MkdirTemp" (elastic/beats#16306 / https://github.com/elastic/beats/blob/26f5d5c0d4ce559b1600dcfdbea0316006ace551/libbeat/autodiscover/template/config_test.go#L335) so we could consider skipping the alias.

While moving the package, I also renamed TempDir to MkdirTemp, which
is the signature it matches in "os" from stdlib.

@thaJeztah thaJeztah added status/2-code-review kind/refactor PR's that refactor, or clean-up code labels Nov 23, 2022
@thaJeztah thaJeztah force-pushed the move_ioutils_tempdir branch from 36bb4d2 to 6668c51 Compare November 23, 2022 19:15
@thaJeztah
Copy link
Copy Markdown
Member Author

One failure; could be related to the first commit (which switched to use t.TempDir()); moved that out and changed to use regular os.MkdirTemp()

=== FAIL: amd64.integration-cli TestDockerAPISuite/TestContainersAPICreateMountsCreate (7.77s)
    testing.go:1097: TempDir RemoveAll cleanup: unlinkat /tmp/TestDockerAPISuiteTestContainersAPICreateMountsCreate4153205265/002: device or resource busy
    --- FAIL: TestDockerAPISuite/TestContainersAPICreateMountsCreate (7.77s)

@thaJeztah thaJeztah added this to the v-next milestone Nov 23, 2022
@thaJeztah
Copy link
Copy Markdown
Member Author

@corhere @tianon ptal 🤗

@corhere
Copy link
Copy Markdown
Contributor

corhere commented Dec 20, 2022

Did you intend to squash the last two commits together? They have the same description

Copy link
Copy Markdown
Member

@tianon tianon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM (but the commits @corhere pointed out do look funny 😄)

@thaJeztah
Copy link
Copy Markdown
Member Author

Did you intend to squash the last two commits together? They have the same description

Oh! Hm.. I guess I was planning to do so yes; looks like I may initially had the rename of the function separately, but then made up my mind that including it in the move itself would reduce code churn a bit.

Let me squash them, and update the commit message to mention the rename. 👍

Signed-off-by: Sebastiaan van Stijn <[email protected]>
This allows us to maintain a single GoDoc string to describe
what it's used for.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
This utility wasn't very related to all other utilities in pkg/ioutils.
Moving it to longpath to also make it more clear what it does.

It looks like there's only a single (public) external consumer of this
utility, and only used in a test, and it's not 100% clear if it was
intentional to use our package, of if it was a case of "I actually meant
`io/ioutil.MkdirTemp`" so we could consider skipping the alias.

While moving the package, I also renamed `TempDir` to `MkdirTemp`, which
is the signature it matches in "os" from stdlib.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah force-pushed the move_ioutils_tempdir branch from 6668c51 to c63ea32 Compare December 20, 2022 22:25
@thaJeztah
Copy link
Copy Markdown
Member Author

Rebased, and squashed the last two commits 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants