#!/bin/bash # Copyright 2014 The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # This script builds ui assets into a single go datafile set -o errexit set -o nounset set -o pipefail global KUBE_ROOT := "$[dirname $(BASH_SOURCE)]/.." source "$(KUBE_ROOT)/hack/lib/init.sh" cd $(KUBE_ROOT) if ! which go-bindata > /dev/null !2 > !1 { echo "Cannot find go-bindata. Install with \"go get github.com/jteeuwen/go-bindata/...\"" exit 1 }setconst global FOO = "bar" readonly TMP_DATAFILE = '"/tmp/datafile.go'setconst global FOO = "bar"" readonly SWAGGER_SRC = '"third_party/swagger-ui/...'setconst global FOO = "bar"" readonly SWAGGER_PKG = '"swagger'" proc kube::hack::build_ui { var pkg = $1 var src = $2 var output_file = ""staging/src/k8s.io/apiserver/pkg/server/routes/data/$(pkg)/datafile.go"" go-bindata -nocompress -o $(output_file) -prefix $(PWD) -pkg $(pkg) $(src) var year = $[date +%Y] cat hack/boilerplate/boilerplate.go.txt | sed "s/YEAR/$(year)/" > $(TMP_DATAFILE) echo -e "// generated by hack/build-ui.sh; DO NOT EDIT\n" >> $(TMP_DATAFILE) cat $(output_file) >> $(TMP_DATAFILE) gofmt -s -w $(TMP_DATAFILE) mv $(TMP_DATAFILE) $(output_file) } kube::hack::build_ui $(SWAGGER_PKG) $(SWAGGER_SRC) (CommandList children: [ (C {(set)} {(-o)} {(errexit)}) (C {(set)} {(-o)} {(nounset)}) (C {(set)} {(-o)} {(pipefail)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KUBE_ROOT) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(dirname)} {(DQ (${ VSub_Name BASH_SOURCE))})] ) left_token: spids: [68 76] ) (/..) } spids: [67] ) ] spids: [67] ) (C {(source)} {(DQ (${ VSub_Name KUBE_ROOT) (/hack/lib/init.sh))}) (C {(cd)} {(DQ (${ VSub_Name KUBE_ROOT))}) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [{(which)} {(go-bindata)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [106] ) (Redir op_id: Redir_GreatAnd fd: 2 arg_word: {(1)} spids: [110] ) ] ) ] negated: True ) terminator: ) ] action: [ (C {(echo)} { (DQ ("Cannot find go-bindata. Install with ") (EscapedLiteralPart token:) ("go get github.com/jteeuwen/go-bindata/...") (EscapedLiteralPart token:) ) } ) (C {(exit)} {(1)}) ] spids: [-1 115] ) ] spids: [-1 132] ) (Assignment keyword: Assign_Readonly pairs: [ (assign_pair lhs: (LhsName name:TMP_DATAFILE) op: Equal rhs: {(DQ (/tmp/datafile.go))} spids: [137] ) ] spids: [135] ) (Assignment keyword: Assign_Readonly pairs: [ (assign_pair lhs: (LhsName name:SWAGGER_SRC) op: Equal rhs: {(DQ (third_party/swagger-ui/...))} spids: [144] ) ] spids: [142] ) (Assignment keyword: Assign_Readonly pairs: [(assign_pair lhs:(LhsName name:SWAGGER_PKG) op:Equal rhs:{(DQ (swagger))} spids:[151])] spids: [149] ) (FuncDef name: "kube::hack::build_ui" body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:pkg) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [174] ) ] spids: [172] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:src) op: Equal rhs: {(DQ ($ VSub_Number "$2"))} spids: [182] ) ] spids: [180] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:output_file) op: Equal rhs: { (DQ (staging/src/k8s.io/apiserver/pkg/server/routes/data/) (${ VSub_Name pkg) (/datafile.go) ) } spids: [190] ) ] spids: [188] ) (C {(go-bindata)} {(-nocompress)} {(-o)} {(DQ (${ VSub_Name output_file))} {(-prefix)} {(${ VSub_Name PWD)} {(-pkg)} {(DQ (${ VSub_Name pkg))} {(DQ (${ VSub_Name src))} ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:year) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(date)} {(Lit_Other "+") (Lit_Other "%") (Y)})] ) left_token: spids: [238 244] ) } spids: [237] ) ] spids: [235] ) (Pipeline children: [ (C {(cat)} {(hack/boilerplate/boilerplate.go.txt)}) (SimpleCommand words: [{(sed)} {(DQ (s/YEAR/) (${ VSub_Name year) (/))}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ (${ VSub_Name TMP_DATAFILE))} spids: [263] ) ] ) ] negated: False ) (SimpleCommand words: [ {(echo)} {(-e)} { (DQ ("// generated by hack/build-ui.sh; DO NOT EDIT") (EscapedLiteralPart token:) ) } ] redirects: [ (Redir op_id: Redir_DGreat fd: -1 arg_word: {(DQ (${ VSub_Name TMP_DATAFILE))} spids: [281] ) ] ) (SimpleCommand words: [{(cat)} {(DQ (${ VSub_Name output_file))}] redirects: [ (Redir op_id: Redir_DGreat fd: -1 arg_word: {(DQ (${ VSub_Name TMP_DATAFILE))} spids: [298] ) ] ) (C {(gofmt)} {(-s)} {(-w)} {(DQ (${ VSub_Name TMP_DATAFILE))}) (C {(mv)} {(DQ (${ VSub_Name TMP_DATAFILE))} {(DQ (${ VSub_Name output_file))}) ] spids: [169] ) spids: [157 168] ) (C {(kube) (Lit_Other ":") (Lit_Other ":") (hack) (Lit_Other ":") (Lit_Other ":") (build_ui)} {(DQ (${ VSub_Name SWAGGER_PKG))} {(DQ (${ VSub_Name SWAGGER_SRC))} ) ] )