MCPcopy Index your code
hub / github.com/coder/coder / expandDevcontainerPaths

Function expandDevcontainerPaths

agent/agentcontainers/devcontainer.go:61–83  ·  view source on GitHub ↗
(logger slog.Logger, expandPath func(string) (string, error), dc codersdk.WorkspaceAgentDevcontainer)

Source from the content-addressed store, hash-verified

59}
60
61func expandDevcontainerPaths(logger slog.Logger, expandPath func(string) (string, error), dc codersdk.WorkspaceAgentDevcontainer) codersdk.WorkspaceAgentDevcontainer {
62 logger = logger.With(slog.F("devcontainer", dc.Name), slog.F("workspace_folder", dc.WorkspaceFolder), slog.F("config_path", dc.ConfigPath))
63
64 if wf, err := expandPath(dc.WorkspaceFolder); err != nil {
65 logger.Warn(context.Background(), "expand devcontainer workspace folder failed", slog.Error(err))
66 } else {
67 dc.WorkspaceFolder = wf
68 }
69 if dc.ConfigPath != "" {
70 // Let expandPath handle home directory, otherwise assume relative to
71 // workspace folder or absolute.
72 if dc.ConfigPath[0] == '~' {
73 if cp, err := expandPath(dc.ConfigPath); err != nil {
74 logger.Warn(context.Background(), "expand devcontainer config path failed", slog.Error(err))
75 } else {
76 dc.ConfigPath = cp
77 }
78 } else {
79 dc.ConfigPath = relativePathToAbs(dc.WorkspaceFolder, dc.ConfigPath)
80 }
81 }
82 return dc
83}
84
85func relativePathToAbs(workdir, path string) string {
86 path = os.ExpandEnv(path)

Callers 1

Calls 2

relativePathToAbsFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected