Skip to content

Commit

Permalink
strip local user suffix off goal definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Norton committed Jan 2, 2024
1 parent b330d7f commit a294e21
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion policy/policy_handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package policy_handler
import (
"context"
"fmt"
"os/user"
"strings"
"time"

"github.com/atomist-skills/go-skill"
Expand Down Expand Up @@ -113,8 +115,16 @@ func (h EventHandler) evaluate(ctx context.Context, req skill.RequestContext, da
paramValues[p.Name] = p.Value
}

// atm-skill local appends the current user's name to the skill name
// we can strip that suffix off before calling evalSelector to let it match on the original name
goalDefName := goalName
u, err := user.Current()
if err == nil && strings.HasSuffix(goalDefName, fmt.Sprintf("-%s", u.Username)) {
goalDefName = goalDefName[0 : len(goalDefName)-len(u.Username)-1]
}

goal := goals.Goal{
Definition: goalName,
Definition: goalDefName,
Configuration: cfg,
Args: paramValues,
}
Expand Down

0 comments on commit a294e21

Please sign in to comment.