mirror of
https://github.com/3bbbeau/tfvars-atlantis-config.git
synced 2024-11-21 21:40:52 +00:00
fix: remove directory from project name when context is self
This commit is contained in:
parent
6c13d2d7f9
commit
4a8ad0cc09
@ -9,8 +9,15 @@ import (
|
|||||||
func ptr[T any](v T) *T { return &v }
|
func ptr[T any](v T) *T { return &v }
|
||||||
|
|
||||||
// friendlyName creates a contextual name used for Atlantis projects
|
// friendlyName creates a contextual name used for Atlantis projects
|
||||||
func friendlyName(path, environment string) string {
|
func friendlyName(path, varFile string) string {
|
||||||
name := []string{strings.ReplaceAll(path, "/", "-"), pathWithoutExtension(filepath.Base(environment))}
|
environment := pathWithoutExtension(filepath.Base(varFile))
|
||||||
|
|
||||||
|
// avoid constructing a joined path if the context is the current directory
|
||||||
|
if filepath.Base(path) == "." {
|
||||||
|
return environment
|
||||||
|
}
|
||||||
|
|
||||||
|
name := []string{strings.ReplaceAll(path, "/", "-"), environment}
|
||||||
return strings.TrimSuffix(strings.Join(name, "-"), "-")
|
return strings.TrimSuffix(strings.Join(name, "-"), "-")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user