github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/hack/validate-bindata.sh (about)

     1  #!/bin/bash
     2  # validates bindata templates are generated correctly.
     3  # bindata is generated using github.com/kevinburke/go-bindata/go-bindata@v3.22.0
     4  
     5  help_exit(){
     6  cat <<EOF
     7  
     8  Usage: validate-bindata.sh
     9  Notes:
    10  Regenerate bindata using github.com/kevinburke/go-bindata/go-bindata@v3.22.0
    11  Fail when bindata.go is modified after regenreate.
    12  Original generate command is in generator/shared.go
    13  EOF
    14  exit 1;
    15  }
    16  
    17  check_bindata_installed(){
    18      which go-bindata || { echo "go-bindata is not installed."; help_exit; } 
    19  }
    20  
    21  check_bindata_version(){
    22      echo $(go-bindata -v) | grep "3.22.0" || { echo "go-bindata version is not 3.22.0"; help_exit; } 
    23  }
    24  
    25  regenerate_templates(){
    26      go generate ./generator/...
    27  }
    28  
    29  check_no_file_changed()
    30  {
    31      git diff --exit-code --name-only -- ./generator  || { echo "bindata.go not up to date. Please commit bindata.go in current state."; help_exit; }
    32  }
    33  
    34  check_bindata_installed
    35  
    36  check_bindata_version
    37  
    38  regenerate_templates
    39  
    40  check_no_file_changed
    41  
    42  echo "Success: bindata is valid."