Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basename and dirname functions #13080

Merged
merged 1 commit into from
Mar 28, 2017
Merged

Add basename and dirname functions #13080

merged 1 commit into from
Mar 28, 2017

Conversation

joshuaspence
Copy link
Contributor

Adds basename and dirname interpolation. I want to add a stack tag to our infrastructure, the value of which is set to ${basename(path.cwd)}. We currently use ${replace(path.cwd, "/^.+\\//", "")} instead, but this is extremeley unreadable. The existance of a basename function would be very useful for this use case.

I don't have an immediate use case for a dirname function, but it seemed reasonable to add it as well.

@ewbankkit
Copy link
Contributor

Use of the path package or filepath package? It seems like filepath is correct here.

@apparentlymart
Copy link
Contributor

apparentlymart commented Mar 27, 2017

Agreed with @ewbankkit that it probably makes sense to use filepath here, for correct portable behavior for Terraform on all platforms -- particularly on Windows.

Fortunately the two are API compatible to the extent that matters here. Would you mind switching that, @joshuaspence, or do you think there's a good reason to use the generic path package?

@joshuaspence
Copy link
Contributor Author

Yep done. I'm not really a golang programmer, so I didn't know about filepath.

Adds `basename` and `dirname` interpolation. I want to add a `stack` tag to our infrastructure, the value of which is set to `${basename(path.cwd)}`. We currently use `${replace(path.cwd, "/^.+\\//", "")}` instead, but this is extremeley unreadable. The existance of a `basename` function would be very useful for this use case.

I don't have an immediate use case for a `dirname` function, but it seemed reasonable to add it as well.
Copy link
Contributor

@apparentlymart apparentlymart left a comment

Choose a reason for hiding this comment

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

Looks good to me! I will come back and merge this once we get that kubernetes test failure sorted out and thus we can see your change here pass green (which I'm sure it will...)

@apparentlymart apparentlymart merged commit af2c84d into hashicorp:master Mar 28, 2017
@joshuaspence joshuaspence deleted the basename branch March 31, 2017 11:05
@ghost
Copy link

ghost commented Apr 14, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants