Closed tthrone-atomic closed 1 month ago
I already came across this as well. But I think this cannot be implemented as you're not restricted to use the same name for a space multiple times. That's why a random value is added after the slug/id in addition to the actual name you chose and you have to specify the complete slug when doing anything with any Space.
@marcinwyszynski or @cube2222 can correct me if I'm wrong here. The first days I wished for a lookup by name myself but then realised it's probably not gonna happen.
Sorry for the delayed reply. Thanks for the follow up. Given the vital role of spaces in spacelift's vision, I would think that spaces should likely enforce uniqueness and to put it back on us users to come up with naming solutions to avoid conflicting. It seems like a time-bomb of other issues the longer it waits. Of course that isn't the responsibility of this project, but if you know some people you can mention it to.
Short of resolving by name, can we instead get an option to resolve by space labels? Those aren't unique either, but arguably less critical and a little warning verbiage can help solve:
"The 'Label' search will yield the first space found that matches the provided label. The yielded result can be different for each execution and there is no guarantee of consistency. Please ensure you are searching by a unique label to avoid this behavior".
Thank you.
Hey @tthrone-atomic! What @spr-mweber3 wrote is correct (thanks for responding!), but we also have a datasource to get spaces by a path made of names (not slugs), if you prefer to use that: https://registry.terraform.io/providers/spacelift-io/spacelift/latest/docs/data-sources/space_by_path
Please feel free to re-open this if finding spaces by path does not fit your requirements.
The spacelift_space data source should allow finding by the human readable name. It currently only supports finding by the slug.
An example use case
data "spacelift_space" "space" { name = "MySpace" }
resource "spacelift_policy" "policy" ... space_id = data.spacelift_space.space.id }