Skip to content

Commit

Permalink
update release-sdk and go-github
Browse files Browse the repository at this point in the history
Signed-off-by: cpanato <ctadeu@gmail.com>
  • Loading branch information
cpanato committed Jan 27, 2024
1 parent c98e16a commit 23227e0
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 25 deletions.
43 changes: 35 additions & 8 deletions cmd/krel/cmd/release_notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"time"

"github.com/blang/semver/v4"
gogit "github.com/go-git/go-git/v5"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -121,18 +122,20 @@ permissions to your fork of k/sig-release and k-sigs/release-notes.`,
}

type releaseNotesOptions struct {
repoPath string
tag string
userFork string
createDraftPR bool
createWebsitePR bool
fixNotes bool
listReleaseNotesV2 bool
interactiveMode bool
updateRepo bool
useSSH bool
repoPath string
tag string
userFork string
websiteRepo string
mapProviders []string
githubOrg string
draftRepo string
interactiveMode bool
mapProviders []string
}

type releaseNotesResult struct {
Expand Down Expand Up @@ -220,6 +223,22 @@ func init() {
"interactive mode, ask before creating the PR",
)

releaseNotesCmd.PersistentFlags().BoolVarP(
&releaseNotesOpts.useSSH,
"use-ssh",
"",
true,
"use ssh to clone the repository, if false will use https (default: true)",
)

releaseNotesCmd.PersistentFlags().BoolVarP(
&releaseNotesOpts.updateRepo,
"update-repo",
"",
true,
"update the cloned repository to fetch any upstream change (default: true)",
)

rootCmd.AddCommand(releaseNotesCmd)
}

Expand Down Expand Up @@ -348,10 +367,13 @@ func createDraftPR(repoPath, tag string) (err error) {
branchname := draftBranchPrefix + tag

// Prepare the fork of k/sig-release
opts := &gogit.CloneOptions{}
sigReleaseRepo, err := github.PrepareFork(
branchname,
git.DefaultGithubOrg, git.DefaultGithubReleaseRepo,
releaseNotesOpts.githubOrg, releaseNotesOpts.draftRepo,
releaseNotesOpts.useSSH, releaseNotesOpts.updateRepo,
opts,
)
if err != nil {
return fmt.Errorf("preparing local fork of kubernetes/sig-release: %w", err)
Expand Down Expand Up @@ -658,9 +680,13 @@ func createWebsitePR(repoPath, tag string) (err error) {
branchname := websiteBranchPrefix + tag

// checkout kubernetes-sigs/release-notes
opts := &gogit.CloneOptions{}
k8sSigsRepo, err := github.PrepareFork(
branchname, defaultKubernetesSigsOrg,
defaultKubernetesSigsRepo, releaseNotesOpts.githubOrg, releaseNotesOpts.websiteRepo,
branchname,
defaultKubernetesSigsOrg, defaultKubernetesSigsRepo,
releaseNotesOpts.githubOrg, releaseNotesOpts.websiteRepo,
releaseNotesOpts.useSSH, releaseNotesOpts.updateRepo,
opts,
)
if err != nil {
return fmt.Errorf("preparing local fork branch: %w", err)
Expand Down Expand Up @@ -767,8 +793,9 @@ func releaseNotesJSON(repoPath, tag string) (jsonString string, err error) {
}

logrus.Info("Cloning kubernetes/sig-release to read mapping files")
opts := &gogit.CloneOptions{}
sigReleaseRepo, err := git.CleanCloneGitHubRepo(
git.DefaultGithubOrg, git.DefaultGithubReleaseRepo, false,
git.DefaultGithubOrg, git.DefaultGithubReleaseRepo, false, true, opts,
)
if err != nil {
return "", fmt.Errorf("performing clone of k/sig-release: %w", err)
Expand Down
4 changes: 3 additions & 1 deletion cmd/krel/cmd/sut_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"testing"
"time"

gogit "github.com/go-git/go-git/v5"
"github.com/stretchr/testify/require"

"sigs.k8s.io/release-sdk/git"
Expand Down Expand Up @@ -107,7 +108,8 @@ func newSUT(t *testing.T) *sut {
repoDir := filepath.Join(tempDir, fmt.Sprintf("test-%d", now))
require.Nil(t, command.New("cp", "-r", baseDir, repoDir).RunSuccess())

repo, err := git.CloneOrOpenRepo(repoDir, url, false)
opts := &gogit.CloneOptions{}
repo, err := git.CloneOrOpenRepo(repoDir, url, false, false, opts)
require.Nil(t, err)

// Adapt the settings
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/goark/go-cvss v1.6.6
github.com/golang/protobuf v1.5.3
github.com/google/go-containerregistry v0.18.0
github.com/google/go-github/v56 v56.0.0
github.com/google/go-github/v58 v58.0.0
github.com/google/safetext v0.0.0-20230106111101-7156a760e523
github.com/google/uuid v1.6.0
github.com/hashicorp/go-multierror v1.1.1
Expand Down Expand Up @@ -41,7 +41,7 @@ require (
sigs.k8s.io/bom v0.5.2-0.20230519223618-1ebaa9ce375f
sigs.k8s.io/mdtoc v1.1.0
sigs.k8s.io/promo-tools/v3 v3.6.0
sigs.k8s.io/release-sdk v0.10.5-0.20231219191353-f1467e0b1393
sigs.k8s.io/release-sdk v0.11.0
sigs.k8s.io/release-utils v0.7.7
sigs.k8s.io/yaml v1.4.0
)
Expand Down Expand Up @@ -228,7 +228,7 @@ require (
github.com/sigstore/cosign/v2 v2.2.2 // indirect
github.com/sigstore/fulcio v1.4.3 // indirect
github.com/sigstore/rekor v1.3.4 // indirect
github.com/sigstore/sigstore v1.8.0 // indirect
github.com/sigstore/sigstore v1.8.1 // indirect
github.com/sigstore/timestamp-authority v1.2.0 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ github.com/google/go-containerregistry v0.18.0 h1:ShE7erKNPqRh5ue6Z9DUOlk04WsnFW
github.com/google/go-containerregistry v0.18.0/go.mod h1:u0qB2l7mvtWVR5kNcbFIhFY1hLbf8eeGapA+vbFDCtQ=
github.com/google/go-github/v55 v55.0.0 h1:4pp/1tNMB9X/LuAhs5i0KQAE40NmiR/y6prLNb9x9cg=
github.com/google/go-github/v55 v55.0.0/go.mod h1:JLahOTA1DnXzhxEymmFF5PP2tSS9JVNj68mSZNDwskA=
github.com/google/go-github/v56 v56.0.0 h1:TysL7dMa/r7wsQi44BjqlwaHvwlFlqkK8CtBWCX3gb4=
github.com/google/go-github/v56 v56.0.0/go.mod h1:D8cdcX98YWJvi7TLo7zM4/h8ZTx6u6fwGEkCdisopo0=
github.com/google/go-github/v58 v58.0.0 h1:Una7GGERlF/37XfkPwpzYJe0Vp4dt2k1kCjlxwjIvzw=
github.com/google/go-github/v58 v58.0.0/go.mod h1:k4hxDKEfoWpSqFlc8LTpGd9fu2KrV1YAa6Hi6FmDNY4=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
Expand Down Expand Up @@ -788,8 +788,8 @@ github.com/sigstore/fulcio v1.4.3 h1:9JcUCZjjVhRF9fmhVuz6i1RyhCc/EGCD7MOl+iqCJLQ
github.com/sigstore/fulcio v1.4.3/go.mod h1:BQPWo7cfxmJwgaHlphUHUpFkp5+YxeJes82oo39m5og=
github.com/sigstore/rekor v1.3.4 h1:RGIia1iOZU7fOiiP2UY/WFYhhp50S5aUm7YrM8aiA6E=
github.com/sigstore/rekor v1.3.4/go.mod h1:1GubPVO2yO+K0m0wt/3SHFqnilr/hWbsjSOe7Vzxrlg=
github.com/sigstore/sigstore v1.8.0 h1:sSRWXv1JiDsK4T2wNWVYcvKCgxcSrhQ/QUJxsfCO4OM=
github.com/sigstore/sigstore v1.8.0/go.mod h1:l12B1gFlLIpBIVeqk/q1Lb+6YSOGNuN3xLExIjYH+qc=
github.com/sigstore/sigstore v1.8.1 h1:mAVposMb14oplk2h/bayPmIVdzbq2IhCgy4g6R0ZSjo=
github.com/sigstore/sigstore v1.8.1/go.mod h1:02SL1158BSj15bZyOFz7m+/nJzLZfFd9A8ab3Kz7w/E=
github.com/sigstore/sigstore/pkg/signature/kms/aws v1.7.6 h1:WzZExOcFanrFfCi7SUgkBtJicWnSNziBD9nSSQIrqhc=
github.com/sigstore/sigstore/pkg/signature/kms/aws v1.7.6/go.mod h1:3zOHOLHnCE6EXyVH+6Z/lC9O1RDsbmR045NQ1DogiHw=
github.com/sigstore/sigstore/pkg/signature/kms/azure v1.7.6 h1:wsPt9kNXF1ZZyae2wO35NLsK+cjWqPGpuPaDdXzRe0g=
Expand Down Expand Up @@ -1408,8 +1408,8 @@ sigs.k8s.io/mdtoc v1.1.0 h1:q3YtqYzmC2e0hgLXRIOm7/QLuPux1CX3ZHCwlbABxZo=
sigs.k8s.io/mdtoc v1.1.0/go.mod h1:QZLVEdHH2iNIR4uHAZyvFRtjloHgVItk8lo/mzCtq3w=
sigs.k8s.io/promo-tools/v3 v3.6.0 h1:C2L08ezrWm1aZI8Emd3iZPZQserLPRgzuqQVxvI0PUI=
sigs.k8s.io/promo-tools/v3 v3.6.0/go.mod h1:XJ3jy0hJYs+hWKt8XsLHFzGQV8PUtvllvbxjN/E5RXI=
sigs.k8s.io/release-sdk v0.10.5-0.20231219191353-f1467e0b1393 h1:ND8yeGnbqxAaJtSF7pxBQWtoTgzlmfY+ASzjGUKbpgI=
sigs.k8s.io/release-sdk v0.10.5-0.20231219191353-f1467e0b1393/go.mod h1:58XrlX6cvcQASB/0N6TEK6eGBYxDNx7k2skQoJNRxRI=
sigs.k8s.io/release-sdk v0.11.0 h1:a+zjOO3tHm1NiVZgNcUWq5QrKmv7b63UZXw+XGdPGfk=
sigs.k8s.io/release-sdk v0.11.0/go.mod h1:sjbFpskyVjCXcFBnI3Bj1iGQHGjDYPoHVyld/pT+TvU=
sigs.k8s.io/release-utils v0.7.7 h1:JKDOvhCk6zW8ipEOkpTGDH/mW3TI+XqtPp16aaQ79FU=
sigs.k8s.io/release-utils v0.7.7/go.mod h1:iU7DGVNi3umZJ8q6aHyUFzsDUIaYwNnNKGHo3YE5E3s=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
Expand Down
4 changes: 3 additions & 1 deletion pkg/anago/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"github.com/blang/semver/v4"
gogit "github.com/go-git/go-git/v5"
intoto "github.com/in-toto/in-toto-golang/in_toto"
slsa "github.com/in-toto/in-toto-golang/in_toto/slsa_provenance/v0.2"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -580,8 +581,9 @@ func (d *DefaultStage) GenerateChangelog() error {
"cloning fresh default repository for changelog",
)

opts := &gogit.CloneOptions{}
repo, err := git.CleanCloneGitHubRepo(
release.DefaultK8sOrg, release.DefaultK8sRepo, false,
release.DefaultK8sOrg, release.DefaultK8sRepo, false, true, opts,
)
if err != nil {
return fmt.Errorf("clone k/k repo: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/fastforward/fastforward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"
"testing"

gogithub "github.com/google/go-github/v56/github"
gogithub "github.com/google/go-github/v58/github"
"github.com/stretchr/testify/require"
"k8s.io/release/pkg/fastforward/fastforwardfakes"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/fastforward/fastforwardfakes/fake_impl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/fastforward/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"k8s.io/release/pkg/gcp/gcb"
"k8s.io/release/pkg/release"

gogithub "github.com/google/go-github/v56/github"
gogithub "github.com/google/go-github/v58/github"
"sigs.k8s.io/release-sdk/git"
"sigs.k8s.io/release-sdk/github"
"sigs.k8s.io/release-utils/env"
Expand Down
2 changes: 1 addition & 1 deletion pkg/notes/notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"time"
"unicode"

gogithub "github.com/google/go-github/v56/github"
gogithub "github.com/google/go-github/v58/github"
"github.com/nozzle/throttler"
"github.com/sirupsen/logrus"
"golang.org/x/text/cases"
Expand Down
2 changes: 1 addition & 1 deletion pkg/notes/notes_gatherer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"sync/atomic"
"testing"

"github.com/google/go-github/v56/github"
"github.com/google/go-github/v58/github"
"github.com/sirupsen/logrus"
"sigs.k8s.io/release-sdk/git"
"sigs.k8s.io/release-sdk/github/githubfakes"
Expand Down
3 changes: 2 additions & 1 deletion pkg/notes/options/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ func newTestRepo(t *testing.T) *testRepo {
require.Nil(t, os.RemoveAll(cloneTempDir))

// Provide a system under test inside the test repo
sut, err := kgit.CloneOrOpenRepo("", bareTempDir, false)
opts := &git.CloneOptions{}
sut, err := kgit.CloneOrOpenRepo("", bareTempDir, false, false, opts)
require.Nil(t, err)
require.Nil(t, command.NewWithWorkDir(
sut.Dir(), "git", "checkout", branchName,
Expand Down

0 comments on commit 23227e0

Please sign in to comment.