// HookVars implements runner.Context. func (ctx *hookContext) HookVars(paths context.Paths) ([]string, error) { vars := []string{ "JUJU_CHARM_DIR=" + paths.GetCharmDir(), "JUJU_CONTEXT_ID=" + ctx.id, "JUJU_AGENT_SOCKET=" + paths.GetJujucSocket(), "JUJU_UNIT_NAME=" + ctx.unitName, } return append(vars, context.OSDependentEnvVars(paths)...), nil }
func (s *EnvSuite) TestEnvSetsPath(c *gc.C) { paths := context.OSDependentEnvVars(MockEnvPaths{}) c.Assert(paths, gc.Not(gc.HasLen), 0) vars, err := keyvalues.Parse(paths, true) c.Assert(err, jc.ErrorIsNil) key := "PATH" if runtime.GOOS == "windows" { key = "Path" } c.Assert(vars[key], gc.Not(gc.Equals), "") }
// HookVars implements runner.Context. func (ctx *limitedContext) HookVars(paths context.Paths) ([]string, error) { vars := []string{ "JUJU_CHARM_DIR=" + paths.GetCharmDir(), "JUJU_CONTEXT_ID=" + ctx.id, "JUJU_AGENT_SOCKET=" + paths.GetJujucSocket(), "JUJU_UNIT_NAME=" + ctx.unitName, } for key, val := range ctx.env { vars = append(vars, fmt.Sprintf("%s=%s", key, val)) } return append(vars, context.OSDependentEnvVars(paths)...), nil }