Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit f1d3390

Browse files
committed
Add update url to ReadAndWrite Hooks
1 parent e218e4b commit f1d3390

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

operator/controllers/execution/scan_controller.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ func (r *ScanReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
195195
return ctrl.Result{}, err
196196
}
197197

198+
bucketName := os.Getenv("S3_BUCKET")
199+
rawFileUploadURL, err := r.MinioClient.PresignedPutObject(bucketName, fmt.Sprintf("scan-%s/%s", scan.UID, scan.Status.RawResultFile), 12*time.Hour)
200+
if err != nil {
201+
r.Log.Error(err, "Could not get presigned url from s3 or compatible storage provider")
202+
return ctrl.Result{}, err
203+
}
204+
findingsUploadURL, err := r.MinioClient.PresignedPutObject(bucketName, fmt.Sprintf("scan-%s/findings.json", scan.UID), 12*time.Hour)
205+
if err != nil {
206+
r.Log.Error(err, "Could not get presigned url from s3 or compatible storage provider")
207+
return ctrl.Result{}, err
208+
}
209+
198210
var hook executionv1.ScanCompletionHook
199211
err = r.Get(ctx, types.NamespacedName{Name: nonCompletedHook.HookName, Namespace: scan.Namespace}, &hook)
200212
if err != nil {
@@ -249,6 +261,8 @@ func (r *ScanReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
249261
Args: []string{
250262
rawFileURL,
251263
findingsFileURL,
264+
rawFileUploadURL.String(),
265+
findingsUploadURL.String(),
252266
},
253267
Env: append(hook.Spec.Env, standardEnvVars...),
254268
ImagePullPolicy: "IfNotPresent",

0 commit comments

Comments
 (0)