#!/bin/bash # Copyright 2016 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)/hack/lib/init.sh" kube::golang::setup_env global BINS := '( 'cmd/clicheck ) make -C $(KUBE_ROOT) WHAT="$(BINS[*])" global clicheck := $[kube::util::find-binary "clicheck] if ! global output := $[$clicheck !2 > !1] { echo $output echo echo "FAILURE: CLI is not following one or more required conventions." exit 1 } else { echo $output echo echo "SUCCESS: CLI is following all tested conventions." } (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) (/hack/lib/init.sh))}) (C {(kube) (Lit_Other ":") (Lit_Other ":") (golang) (Lit_Other ":") (Lit_Other ":") (setup_env)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BINS) op: Equal rhs: {(ArrayLiteralPart words:[{(cmd/clicheck)}])} spids: [94] ) ] spids: [94] ) (C {(make)} {(-C)} {(DQ (${ VSub_Name KUBE_ROOT))} {(Lit_VarLike "WHAT=") (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Arith_Star) spids: [114 119] ) ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:clicheck) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(kube) (Lit_Other ":") (Lit_Other ":") (util) (Lit_Other ":") (Lit_Other ":") (find-binary) } {(DQ (clicheck))} ) ] ) left_token: spids: [124 136] ) } spids: [123] ) ] spids: [123] ) (If arms: [ (if_arm cond: [ (Pipeline children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:output) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [{($ VSub_Name "$clicheck")}] redirects: [ (Redir op_id: Redir_GreatAnd fd: 2 arg_word: {(1)} spids: [147] ) ] ) ] ) left_token: spids: [144 149] ) } spids: [143] ) ] spids: [143] ) ] negated: True ) ] action: [ (C {(echo)} {(DQ ($ VSub_Name "$output"))}) (C {(echo)}) (C {(echo)} {(DQ ("FAILURE: CLI is not following one or more required conventions."))}) (C {(exit)} {(1)}) ] spids: [-1 151] ) ] else_action: [ (C {(echo)} {(DQ ($ VSub_Name "$output"))}) (C {(echo)}) (C {(echo)} {(DQ ("SUCCESS: CLI is following all tested conventions."))}) ] spids: [175 194] ) ] )