github.com/galamsiva2020/kubernetes-heapster-monitoring@v0.0.0-20210823134957-3c1baa7c1e70/hooks/run_vet.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2015 Google Inc. All rights reserved.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  set -o errexit
    18  set -o pipefail
    19  
    20  # Filter silly "exit status 1" lines and send main output to stdout.
    21  #
    22  # This is tricky - pipefail means any non-zero exit in a pipeline is reported,
    23  # and errexit exits on error.  Turning that into an || expression blocks the
    24  # errexit.  But $? is still not useful because grep will return an error when it
    25  # receives no input, which is exactly what go vet produces on success.  In
    26  # short, if go vet fails (produces output), grep will succeed, but if go vet
    27  # succeeds (produces no output) grep will fail.  Then we just look at
    28  # PIPESTATUS[0] which is go's exit code.
    29  rc=0
    30  go vet $(go list ./... | grep -v /vendor/) 2>&1 | grep -v "^exit status " || rc=${PIPESTATUS[0]}
    31  exit "${rc}"