prettyDirectoryPath returns a prettified path when inside the users home directory. Falls back to dir if the users home directory cannot discerned. This function calls filepath.Clean on the result.
(dir string)
| 521 | // home directory. Falls back to dir if the users home directory cannot |
| 522 | // discerned. This function calls filepath.Clean on the result. |
| 523 | func prettyDirectoryPath(dir string) string { |
| 524 | dir = filepath.Clean(dir) |
| 525 | homeDir, err := os.UserHomeDir() |
| 526 | if err != nil { |
| 527 | return dir |
| 528 | } |
| 529 | prettyDir := dir |
| 530 | if strings.HasPrefix(prettyDir, homeDir) { |
| 531 | prettyDir = strings.TrimPrefix(prettyDir, homeDir) |
| 532 | prettyDir = "~" + prettyDir |
| 533 | } |
| 534 | return prettyDir |
| 535 | } |
| 536 | |
| 537 | func handleMissingTemplateVariables(inv *serpent.Invocation, args createValidTemplateVersionArgs, failedVersionID uuid.UUID) (*codersdk.TemplateVersion, error) { |
| 538 | client := args.Client |