vault/tools/pipeline/internal/pkg/github/labels.go
Vault Automation d160737ced
[VAULT-42862] upgrade cloudflare/circl => v1.6.3 to partially resolve CVE-2026-1229 (#12567) (#12651)
Upgrade `cloudflare/circl` to v1.6.3 to resolve CVE-2026-1229. We had
several transient dependencies that depend on various versions of
`circl` that also needed to be updated in order to resolve the latest
version everywhere.

- github.com/ProtonMail/go-crypto v1.2.0 => v1.3.0
- github.com/google/go-github v17 => v83/v83.0.0
- github.com/google/go-github/v81 => v83/v83.0.0

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
2026-03-03 10:31:03 -07:00

54 lines
1.4 KiB
Go

// Copyright IBM Corp. 2016, 2025
// SPDX-License-Identifier: BUSL-1.1
package github
import (
"context"
"log/slog"
"strings"
libgithub "github.com/google/go-github/v83/github"
slogctx "github.com/veqryn/slog-context"
)
// filterNonBackportLabels returns a slice of label names that do not have the
// specified backport prefix, filtering out backport labels from the input labels
func filterNonBackportLabels(labels Labels, backportPrefix string) []string {
var labelsToAdd []string
for _, label := range labels {
if label.GetName() != "" && !strings.HasPrefix(label.GetName(), backportPrefix+"/") {
labelsToAdd = append(labelsToAdd, label.GetName())
}
}
return labelsToAdd
}
// addLabelsToIssue adds the given labels to the issue or pull request
func addLabelsToIssue(
ctx context.Context,
github *libgithub.Client,
owner string,
repo string,
number int,
labels []string,
) error {
if len(labels) < 1 {
slog.Default().DebugContext(ctx, "skipping label assignment because no labels were provided")
return nil
}
ctx = slogctx.Append(ctx,
slog.String("labels", strings.Join(labels, ", ")),
slog.Int("issue-number", number),
)
slog.Default().DebugContext(ctx, "adding labels to issue or pull request")
_, _, err := github.Issues.AddLabelsToIssue(ctx, owner, repo, number, labels)
if err != nil {
return err
}
slog.Default().DebugContext(ctx, "successfully added labels to issue or pull request")
return nil
}