github.com/zppinho/prow@v0.0.0-20240510014325-1738badeb017/cmd/deck/runlocal (about) 1 #!/usr/bin/env bash 2 # Copyright 2017 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 set -o errexit 17 set -o nounset 18 set -o pipefail 19 20 if [[ "${1:-}" == '--help' ]]; then 21 echo "Usage: [NO_DOCKER=yes] $(basename "$0") [--skip-pregenerated|HOST] [--skip-typescript]" >&2 22 echo >&2 23 echo " --skip-pregenerated: do not fetch pregenerated cluster data from a prod instance" >&2 24 echo " HOST: fetch pregenerated cluster data from a prod instance, eg https://prow.k8s.io" >&2 25 echo " --skip-typescript: do not compile typescript" >&2 26 echo >&2 27 echo " NO_DOCKER=yes: Run Makefile commands on host machine, rather than a container" >&2 28 exit 1 29 fi 30 31 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 32 cd "${DIR}" 33 34 fetch() { 35 echo "* $@" >&2 36 curl -s "$@" 37 } 38 39 update-pregenerated() { 40 local readonly HOST=$1 41 42 echo "Updating pregenerated data from ${HOST}: " >&2 43 44 cd localdata 45 fetch "${HOST}/plugin-help.js?var=allHelp" > plugin-help.js 46 fetch "${HOST}/pr-data.js" > pr-data.js 47 fetch "${HOST}/prowjobs.js" > prowjobs.json 48 fetch "${HOST}/tide-history.js?var=tideHistory" > tide-history.js 49 fetch "${HOST}/tide.js?var=tideData" > tide.js 50 cd .. 51 echo "DONE" 52 } 53 54 if [[ "${1:-}" != '--skip-pregenerated' ]]; then 55 HOST=${1:-"https://prow.k8s.io"} 56 if [[ "${1:-}" == "openshift" ]]; then 57 HOST="https://prow.ci.openshift.org" 58 fi 59 update-pregenerated "$HOST" 60 shift || true 61 else 62 shift 63 fi 64 65 compile-typescript() { 66 echo "Compiling typescript..." >&2 67 ./gather-static.sh 68 } 69 70 if [[ "${1:-}" != '--skip-typescript' ]]; then 71 compile-typescript 72 fi 73 ( 74 set -o xtrace 75 go run . \ 76 --pregenerated-data=${DIR}/localdata \ 77 --static-files-location="$DIR/kodata/static" \ 78 --template-files-location="$DIR/kodata/template" \ 79 --spyglass-files-location="$DIR/kodata/lenses" \ 80 --config-path "${DIR}/../../test/integration/config/prow/deck.yaml" \ 81 --spyglass 82 )