@@ -12,6 +12,7 @@ import (
12
12
"github.com/carabiner-dev/vcslocator"
13
13
"github.com/spf13/cobra"
14
14
15
+ "github.com/slsa-framework/slsa-source-poc/pkg/auth"
15
16
"github.com/slsa-framework/slsa-source-poc/pkg/ghcontrol"
16
17
"github.com/slsa-framework/slsa-source-poc/pkg/sourcetool/models"
17
18
)
@@ -122,7 +123,16 @@ func (bo *branchOptions) EnsureDefaults() error {
122
123
return nil
123
124
}
124
125
125
- gcx := ghcontrol .NewGhConnection (bo .owner , bo .repository , "" ).WithAuthToken (githubToken )
126
+ t := githubToken
127
+ var err error
128
+ if t == "" {
129
+ t , err = auth .New ().ReadToken ()
130
+ if err != nil {
131
+ return err
132
+ }
133
+ }
134
+
135
+ gcx := ghcontrol .NewGhConnection (bo .owner , bo .repository , "" ).WithAuthToken (t )
126
136
branch , err := gcx .GetDefaultBranch (context .Background ())
127
137
if err != nil {
128
138
return fmt .Errorf ("reading repository default branch: %w" , err )
@@ -181,7 +191,16 @@ func (co *commitOptions) EnsureDefaults() error {
181
191
}
182
192
183
193
if co .commit == "" {
184
- gcx := ghcontrol .NewGhConnection (co .owner , co .repository , "" ).WithAuthToken (githubToken )
194
+ t := githubToken
195
+ var err error
196
+ if t == "" {
197
+ t , err = auth .New ().ReadToken ()
198
+ if err != nil {
199
+ return err
200
+ }
201
+ }
202
+
203
+ gcx := ghcontrol .NewGhConnection (co .owner , co .repository , "" ).WithAuthToken (t )
185
204
digest , err := gcx .GetLatestCommit (context .Background (), co .branch )
186
205
if err != nil {
187
206
return fmt .Errorf ("fetching last commit from %q: %w" , co .branch , err )
0 commit comments