Skip to content

Commit

Permalink
feat(repo): tell what repo is concerned
Browse files Browse the repository at this point in the history
  • Loading branch information
yyewolf committed Nov 22, 2023
1 parent 975f9aa commit 3b8d952
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/docker/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ func UpdateContainers(token string) error {
// Prepare discord's message
message := fmt.Sprintf("Updating %d container(s):\n", len(list))
for _, c := range list {
message += fmt.Sprintf("- **%s**\n", c.Inspect.Name)
lbl := labels.MapToGoCDLabels(c.Inspect.Config.Labels)
if lbl.Repo == "" {
message += fmt.Sprintf("- **%s**\n", c.Inspect.Name)
} else {
message += fmt.Sprintf("- **[%s](%s)**\n", c.Inspect.Name, lbl.Repo)
}
}

discord.SendMessage(message)
Expand Down
2 changes: 2 additions & 0 deletions internal/labels/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package labels
type GoCDLabels struct {
Enable bool `json:"gocd.enable"`
Token string `json:"gocd.token"`
Repo string `json:"gocd.repo"`
}

func MapToGoCDLabels(labels map[string]string) GoCDLabels {
return GoCDLabels{
Enable: labels["gocd.enable"] == "true",
Token: labels["gocd.token"],
Repo: labels["gocd.repo"],
}
}

0 comments on commit 3b8d952

Please sign in to comment.