#!/bin/bash # Copyright 2015 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. set -o errexit set -o nounset set -o pipefail global KUBE_ROOT := "$[dirname $(BASH_SOURCE)]/.." source "$(KUBE_ROOT)/cluster/common.shTODO " declare -r KUBE_RELEASE_BUCKET_URL = '"https://storage.googleapis.com/kubernetes-release'TODO " declare -r KUBE_DEV_RELEASE_BUCKET_URL = '"https://storage.googleapis.com/kubernetes-release-dev'TODO " declare -r KUBE_TAR_NAME = '"kubernetes.tar.gz'" proc usage { echo "$(0) [-v] " echo " -v: Don't get tars, just print the version number" echo "" echo ' Version number or publication is either a proper version number' echo ' (e.g. "v1.0.6", "v1.2.0-alpha.1.881+376438b69c7612") or a version' echo ' publication of the form / (e.g. "release/stable",' echo ' "ci/latest-1"). Some common ones are:' echo ' - "release/stable"' echo ' - "release/latest"' echo ' - "ci/latest"' echo ' See the docs on getting builds for more information about version' echo ' publication.' } global print_version := 'false' while getopts ":vh" opt { matchstr $(opt) { v { global print_version := '"true'" } h { usage exit 0 } \? { echo "Invalid option: -$OPTARG" > !2 usage exit 1 } } } shift $(OPTIND-1) if [[ $# -ne 1 ]] { usage exit 1 } set_binary_version $(1) if [[ "${print_version}" == "true" ]] { echo $(KUBE_VERSION) } else { echo "Using version at $(1): $(KUBE_VERSION)" > !2 if [[ ${KUBE_VERSION} =~ ${KUBE_RELEASE_VERSION_REGEX} ]] { curl --fail -o "kubernetes-$(KUBE_VERSION).tar.gz" "$(KUBE_RELEASE_BUCKET_URL)/release/$(KUBE_VERSION)/$(KUBE_TAR_NAME)" } elif [[ ${KUBE_VERSION} =~ ${KUBE_CI_VERSION_REGEX} ]] { curl --fail -o "kubernetes-$(KUBE_VERSION).tar.gz" "$(KUBE_DEV_RELEASE_BUCKET_URL)/ci/$(KUBE_VERSION)/$(KUBE_TAR_NAME)" } else { echo "Version doesn't match regexp" > !2 exit 1 } } (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: [64 72] ) (/..) } spids: [63] ) ] spids: [63] ) (C {(source)} {(DQ (${ VSub_Name KUBE_ROOT) (/cluster/common.sh))}) (Assignment keyword: Assign_Declare flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:KUBE_RELEASE_BUCKET_URL) op: Equal rhs: {(DQ ("https://storage.googleapis.com/kubernetes-release"))} spids: [90] ) ] spids: [86] ) (Assignment keyword: Assign_Declare flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:KUBE_DEV_RELEASE_BUCKET_URL) op: Equal rhs: {(DQ ("https://storage.googleapis.com/kubernetes-release-dev"))} spids: [99] ) ] spids: [95] ) (Assignment keyword: Assign_Declare flags: ["'-r'"] pairs: [ (assign_pair lhs: (LhsName name:KUBE_TAR_NAME) op: Equal rhs: {(DQ (kubernetes.tar.gz))} spids: [108] ) ] spids: [104] ) (FuncDef name: usage body: (BraceGroup children: [ (C {(echo)} {(DQ (${ VSub_Number 0) (" [-v] "))}) (C {(echo)} {(DQ (" -v: Don't get tars, just print the version number"))}) (C {(echo)} {(DQ )}) (C {(echo)} {(SQ <" Version number or publication is either a proper version number">)}) (C {(echo)} {(SQ <" (e.g. \"v1.0.6\", \"v1.2.0-alpha.1.881+376438b69c7612\") or a version">)} ) (C {(echo)} {(SQ <" publication of the form / (e.g. \"release/stable\",">)} ) (C {(echo)} {(SQ <" \"ci/latest-1\"). Some common ones are:">)}) (C {(echo)} {(SQ <" - \"release/stable\"">)}) (C {(echo)} {(SQ <" - \"release/latest\"">)}) (C {(echo)} {(SQ <" - \"ci/latest\"">)}) (C {(echo)} {(SQ <" See the docs on getting builds for more information about version">)}) (C {(echo)} {(SQ <" publication.">)}) ] spids: [118] ) spids: [114 117] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:print_version) op:Equal rhs:{(false)} spids:[209])] spids: [209] ) (While cond: [(Sentence child:(C {(getopts)} {(DQ (":vh"))} {(opt)}) terminator:)] body: (DoGroup children: [ (Case to_match: {(${ VSub_Name opt)} arms: [ (case_arm pat_list: [{(v)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:print_version) op: Equal rhs: {(DQ (true))} spids: [240] ) ] spids: [240] ) ] spids: [236 237 246 -1] ) (case_arm pat_list: [{(h)}] action: [(C {(usage)}) (C {(exit)} {(0)})] spids: [249 250 261 -1] ) (case_arm pat_list: [{(EscapedLiteralPart token:)}] action: [ (SimpleCommand words: [{(echo)} {(DQ ("Invalid option: -") ($ VSub_Name "$OPTARG"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[275])] ) (C {(usage)}) (C {(exit)} {(1)}) ] spids: [264 265 287 -1] ) ] spids: [227 233 290] ) ] spids: [224 292] ) ) (C {(shift)} { (ArithSubPart anode: (ArithBinary op_id: Arith_Minus left: (ArithVarRef name:OPTIND) right: (ArithWord w:{(Lit_Digits 1)}) ) spids: [296 301] ) } ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_ne left:{($ VSub_Pound "$#")} right:{(1)}) ) terminator: ) ] action: [(C {(usage)}) (C {(exit)} {(1)})] spids: [-1 317] ) ] spids: [-1 327] ) (C {(set_binary_version)} {(DQ (${ VSub_Number 1))}) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ (${ VSub_Name print_version))} right: {(DQ (true))} ) ) terminator: ) ] action: [(C {(echo)} {(DQ (${ VSub_Name KUBE_VERSION))})] spids: [-1 358] ) ] else_action: [ (SimpleCommand words: [ {(echo)} {(DQ ("Using version at ") (${ VSub_Number 1) (": ") (${ VSub_Name KUBE_VERSION))} ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[385])] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_EqualTilde left: {(${ VSub_Name KUBE_VERSION)} right: {(${ VSub_Name KUBE_RELEASE_VERSION_REGEX)} ) ) terminator: ) ] action: [ (C {(curl)} {(--fail)} {(-o)} {(DQ (kubernetes-) (${ VSub_Name KUBE_VERSION) (.tar.gz))} { (DQ (${ VSub_Name KUBE_RELEASE_BUCKET_URL) (/release/) (${ VSub_Name KUBE_VERSION) (/) (${ VSub_Name KUBE_TAR_NAME) ) } ) ] spids: [-1 406] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_EqualTilde left: {(${ VSub_Name KUBE_VERSION)} right: {(${ VSub_Name KUBE_CI_VERSION_REGEX)} ) ) terminator: ) ] action: [ (C {(curl)} {(--fail)} {(-o)} {(DQ (kubernetes-) (${ VSub_Name KUBE_VERSION) (.tar.gz))} { (DQ (${ VSub_Name KUBE_DEV_RELEASE_BUCKET_URL) (/ci/) (${ VSub_Name KUBE_VERSION) (/) (${ VSub_Name KUBE_TAR_NAME) ) } ) ] spids: [438 455] ) ] else_action: [ (SimpleCommand words: [{(echo)} {(DQ ("Version doesn't match regexp"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[496])] ) (C {(exit)} {(1)}) ] spids: [487 505] ) ] spids: [369 507] ) ] )