prow/gcsupload/run.go
func (o Options) Run(spec *downwardapi.JobSpec, extra map[string]gcs.UploadFunc) error {
	uploadTargets := o.assembleTargets(spec, extra)

	if !o.DryRun {
		ctx := context.Background()
		gcsClient, err := storage.NewClient(ctx, option.WithCredentialsFile(o.GcsCredentialsFile))
		if err != nil {
			return fmt.Errorf("could not connect to GCS: %v", err)
		}

		if err := gcs.Upload(gcsClient.Bucket(o.Bucket), uploadTargets); err != nil {
			return fmt.Errorf("failed to upload to GCS: %v", err)
		}
	} else {
		for destination := range uploadTargets {
			logrus.WithField("dest", destination).Info("Would upload")
		}
	}

	logrus.Info("Finished upload to GCS")
	return nil
}
func (o Options) Run(spec *downwardapi.JobSpec, extra map[string]gcs.UploadFunc) error {
	uploadTargets := o.assembleTargets(spec, extra)

	if !o.DryRun {
		ctx := context.Background()
		gcsClient, err := storage.NewClient(ctx, option.WithCredentialsFile(o.GcsCredentialsFile))
		if err != nil {
			return fmt.Errorf("could not connect to GCS: %v", err)
		}

		if err := gcs.Upload(gcsClient.Bucket(o.Bucket), uploadTargets); err != nil {
			return fmt.Errorf("failed to upload to GCS: %v", err)
		}
	} else {
		for destination := range uploadTargets {
			logrus.WithField("dest", destination).Info("Would upload")
		}
	}

	logrus.Info("Finished upload to GCS")
	return nil
}
func ( o Options ) Run ( spec * downwardapi . JobSpec , extra map [ string ] gcs . UploadFunc ) error { uploadTargets := o . assembleTargets ( spec , extra ) if ! o . DryRun { ctx := context . Background ( ) gcsClient , err := storage . NewClient ( ctx , option . WithCredentialsFile ( o . GcsCredentialsFile ) ) if err != nil { return fmt . Errorf ( " " , err ) } if err := gcs . Upload ( gcsClient . Bucket ( o . Bucket ) , uploadTargets ) ; err != nil { return fmt . Errorf ( " " , err ) } } else { for destination := range uploadTargets { logrus . WithField ( " " , destination ) . Info ( " " ) } } logrus . Info ( " " ) return nil }
// Run will upload files to GCS as prescribed by
// the options. Any extra files can be passed as
// a parameter and will have the prefix prepended
// to their destination in GCS, so the caller can
// operate relative to the base of the GCS dir.
Run will upload files to GCS as prescribed by the options . Any extra files can be passed as a parameter and will have the prefix prepended to their destination in GCS so the caller can operate relative to the base of the GCS dir .