github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/helper/raftutil/generate_msgtypes.sh (about)

     1  #!/bin/sh
     2  
     3  set -e
     4  
     5  generate_file() {
     6      cat <<EOF
     7  // Code generated by go generate; DO NOT EDIT.
     8  package raftutil
     9  
    10  import "github.com/hashicorp/nomad/nomad/structs"
    11  
    12  var msgTypeNames = map[structs.MessageType]string{
    13  EOF
    14  
    15      cat ../../nomad/structs/structs.go \
    16          | grep -A500 'MessageType = 0' \
    17          | grep -v -e '//'              \
    18          | grep -v -e '^$'              \
    19          | awk '/^\)$/ { exit; } /.*/ { printf "  structs.%s: \"%s\",\n", $1, $1}'
    20  
    21      echo '}'
    22  }
    23  
    24  echo "==> Generating type map..."
    25  generate_file > msgtypes.go
    26  
    27  echo "==> Formatting type map..."
    28  gofmt -w msgtypes.go