@@ -133,7 +133,7 @@ func (b *provenanceOnlyBuild) URI() string {
133
133
}
134
134
135
135
// attestCmd returns the 'attest' command.
136
- func attestCmd () * cobra.Command {
136
+ func attestCmd (provider slsa. ClientProvider ) * cobra.Command {
137
137
var predicatePath string
138
138
var attPath string
139
139
var subjects string
@@ -148,15 +148,13 @@ run in the context of a Github Actions workflow.`,
148
148
Run : func (cmd * cobra.Command , args []string ) {
149
149
ghContext , err := github .GetWorkflowContext ()
150
150
check (err )
151
-
152
- // Verify the extension path and extension.
153
- err = utils .VerifyAttestationPath (attPath )
154
- check (err )
155
-
156
151
var parsedSubjects []intoto.Subject
157
152
// We don't actually care about the subjects if we aren't writing an attestation.
158
153
if attPath != "" {
159
- var err error
154
+ // Verify the extension path and extension.
155
+ err = utils .VerifyAttestationPath (attPath )
156
+ check (err )
157
+
160
158
parsedSubjects , err = parseSubjects (subjects )
161
159
check (err )
162
160
@@ -170,15 +168,23 @@ run in the context of a Github Actions workflow.`,
170
168
b := provenanceOnlyBuild {
171
169
GithubActionsBuild : slsa .NewGithubActionsBuild (parsedSubjects , ghContext ),
172
170
}
173
- // TODO(github.com/slsa-framework/slsa-github-generator/issues/124): Remove
174
- if utils .IsPresubmitTests () {
175
- b .WithClients (& slsa.NilClientProvider {})
171
+ if provider != nil {
172
+ b .WithClients (provider )
173
+ } else {
174
+ // TODO(github.com/slsa-framework/slsa-github-generator/issues/124): Remove
175
+ if utils .IsPresubmitTests () {
176
+ b .WithClients (& slsa.NilClientProvider {})
177
+ }
176
178
}
177
179
178
180
g := slsa .NewHostedActionsGenerator (& b )
179
- // TODO(github.com/slsa-framework/slsa-github-generator/issues/124): Remove
180
- if utils .IsPresubmitTests () {
181
- g .WithClients (& slsa.NilClientProvider {})
181
+ if provider != nil {
182
+ g .WithClients (provider )
183
+ } else {
184
+ // TODO(github.com/slsa-framework/slsa-github-generator/issues/124): Remove
185
+ if utils .IsPresubmitTests () {
186
+ g .WithClients (& slsa.NilClientProvider {})
187
+ }
182
188
}
183
189
184
190
p , err := g .Generate (ctx )
0 commit comments