sigs.k8s.io/prow@v0.0.0-20240503223140-c5e374dc7eb1/cmd/gcsupload/main.go (about) 1 /* 2 Copyright 2018 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 // gcsupload uploads the files and folders specified 18 // to GCS using the Prow-defined job configuration 19 package main 20 21 import ( 22 "context" 23 24 "github.com/sirupsen/logrus" 25 "sigs.k8s.io/prow/pkg/pod-utils/downwardapi" 26 "sigs.k8s.io/prow/pkg/pod-utils/options" 27 28 "sigs.k8s.io/prow/pkg/gcsupload" 29 "sigs.k8s.io/prow/pkg/logrusutil" 30 "sigs.k8s.io/prow/pkg/pod-utils/gcs" 31 ) 32 33 func main() { 34 logrusutil.ComponentInit() 35 36 o := gcsupload.NewOptions() 37 if err := options.Load(o); err != nil { 38 logrus.Fatalf("Could not resolve options: %v", err) 39 } 40 41 if err := o.Validate(); err != nil { 42 logrus.Fatalf("Invalid options: %v", err) 43 } 44 45 spec, err := downwardapi.ResolveSpecFromEnv() 46 if err != nil { 47 logrus.WithError(err).Fatal("Could not resolve job spec") 48 } 49 50 ctx := context.Background() 51 if err := o.Run(ctx, spec, map[string]gcs.UploadFunc{}); err != nil { 52 logrus.WithError(err).Fatal("Failed to upload to GCS") 53 } 54 }