mirror of
https://github.com/containers/podman.git
synced 2025-06-23 10:38:20 +08:00
systemd.parser: Add GetTemplateParts()
This helper splits out a templated filename into the base template and the instance name. This will be used later. Signed-off-by: Alexander Larsson <alexl@redhat.com>
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
@ -919,3 +920,13 @@ func (f *UnitFile) PrependComment(groupName string, comments ...string) {
|
|||||||
group.prependComment(newUnitLine("", "# "+comments[i], true))
|
group.prependComment(newUnitLine("", "# "+comments[i], true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *UnitFile) GetTemplateParts() (string, string) {
|
||||||
|
ext := filepath.Ext(f.Filename)
|
||||||
|
basename := strings.TrimSuffix(f.Filename, ext)
|
||||||
|
parts := strings.SplitN(basename, "@", 2)
|
||||||
|
if len(parts) < 2 {
|
||||||
|
return "", ""
|
||||||
|
}
|
||||||
|
return parts[0] + "@" + ext, parts[1]
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user