#!/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. # A library of helper functions and constant for debian os distro proc get-node-instance-metadata { var metadata = ''"" metadata := ""startup-script=$(KUBE_TEMP)/configure-vm.sh,"" metadata := ""kube-env=$(KUBE_TEMP)/node-kube-env.yaml,"" metadata := ""cluster-name=$(KUBE_TEMP)/cluster-name.txt"" echo $(metadata) } # $1: template name (required) proc create-node-instance-template { var template_name = $1 prepare-startup-script create-node-template $template_name $(scope_flags) $[get-node-instance-metadata] } (CommandList children: [ (FuncDef name: get-node-instance-metadata body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:metadata) op:Equal rhs:{(DQ )} spids:[57])] spids: [55] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:metadata) op: PlusEqual rhs: {(DQ ("startup-script=") (${ VSub_Name KUBE_TEMP) ("/configure-vm.sh,"))} spids: [62] ) ] spids: [62] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:metadata) op: PlusEqual rhs: {(DQ ("kube-env=") (${ VSub_Name KUBE_TEMP) ("/node-kube-env.yaml,"))} spids: [72] ) ] spids: [72] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:metadata) op: PlusEqual rhs: {(DQ ("cluster-name=") (${ VSub_Name KUBE_TEMP) (/cluster-name.txt))} spids: [82] ) ] spids: [82] ) (C {(echo)} {(DQ (${ VSub_Name metadata))}) ] spids: [52] ) spids: [48 51] ) (FuncDef name: create-node-instance-template body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:template_name) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [115] ) ] spids: [113] ) (C {(prepare-startup-script)}) (C {(create-node-template)} {(DQ ($ VSub_Name "$template_name"))} {(DQ (${ VSub_Name scope_flags))} { (DQ (CommandSubPart command_list: (CommandList children:[(C {(get-node-instance-metadata)})]) left_token: spids: [137 139] ) ) } ) ] spids: [110] ) spids: [106 109] ) ] )