github.com/abayer/test-infra@v0.0.5/prow/cmd/initupload/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  // initupload parses the logs from the clonerefs
    18  // container and determines if that container was
    19  // successful or not. Using that information, this
    20  // container uploads started.json and if necessary
    21  // finished.json as well.
    22  package main
    23  
    24  import (
    25  	"github.com/sirupsen/logrus"
    26  	"k8s.io/test-infra/prow/pod-utils/options"
    27  
    28  	"k8s.io/test-infra/prow/initupload"
    29  	"k8s.io/test-infra/prow/logrusutil"
    30  )
    31  
    32  func main() {
    33  	o := initupload.NewOptions()
    34  	if err := options.Load(o); err != nil {
    35  		logrus.Fatalf("Could not resolve options: %v", err)
    36  	}
    37  
    38  	if err := o.Validate(); err != nil {
    39  		logrus.Fatalf("Invalid options: %v", err)
    40  	}
    41  
    42  	logrus.SetFormatter(
    43  		logrusutil.NewDefaultFieldsFormatter(nil, logrus.Fields{"component": "initupload"}),
    44  	)
    45  
    46  	if err := o.Run(); err != nil {
    47  		logrus.WithError(err).Fatal("Failed to initialize job")
    48  	}
    49  }