#!/bin/bash # Copyright 2017 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)]/.." global staging_repos := '('$(ls "${KUBE_ROOT}/staging/src/k8s.io/")) global staging_repos_pattern := $[global IFS := '"|'"; echo $(staging_repos[*])] global failed := 'false' for i in [$[find vendor/ -type d]] { global deps := $[go list -f '{{range .Deps}}{{.}}{{"\n"}}{{end}}' ./$i !2 > /dev/null || echo] global deps_on_main := $[echo $(deps) | grep -v "k8s.io/kubernetes/vendor/" | grep "k8s.io/kubernetes" || echo] if test -n $(deps_on_main) { echo "Package $(i) has a cyclic dependency on the main repository." global failed := 'true' } global deps_on_staging := $[echo $(deps) | grep "k8s.io/kubernetes/vendor/k8s.io" | grep -E "k8s.io\/$(staging_repos_pattern)\>" || echo] if test -n $(deps_on_staging) { echo "Package $(i) has a cyclic dependency on staging repository packages: $(deps_on_staging)" global failed := 'true' } } if [[ "${failed}" == "true" ]] { 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] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:staging_repos) op: Equal rhs: { (ArrayLiteralPart words: [ { (CommandSubPart command_list: (CommandList children: [(C {(ls)} {(DQ (${ VSub_Name KUBE_ROOT) (/staging/src/k8s.io/))})] ) left_token: spids: [78 87] ) } ] ) } spids: [76] ) ] spids: [76] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:staging_repos_pattern) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Sentence child: (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:IFS) op: Equal rhs: {(DQ ("|"))} spids: [92] ) ] spids: [92] ) terminator: ) (C {(echo)} { (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Arith_Star) spids: [101 106] ) ) } ) ] ) left_token: spids: [91 108] ) } spids: [90] ) ] spids: [90] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:failed) op:Equal rhs:{(false)} spids:[111])] spids: [111] ) (ForEach iter_name: i iter_words: [ { (CommandSubPart command_list: (CommandList children:[(C {(find)} {(vendor/)} {(-type)} {(d)})]) left_token: spids: [120 128] ) } ] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:deps) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (AndOr children: [ (SimpleCommand words: [ {(go)} {(list)} {(-f)} {(SQ <"{{range .Deps}}{{.}}{{\"\\n\"}}{{end}}">)} {(./) ($ VSub_Name "$i")} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [149] ) ] ) (C {(echo)} {(DQ )}) ] op_id: Op_DPipe ) ] ) left_token: spids: [135 159] ) } spids: [134] ) ] spids: [134] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:deps_on_main) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (AndOr children: [ (Pipeline children: [ (C {(echo)} {(DQ (${ VSub_Name deps))}) (C {(grep)} {(-v)} {(DQ (k8s.io/kubernetes/vendor/))}) (C {(grep)} {(DQ (k8s.io/kubernetes))}) ] negated: False ) (C {(echo)} {(DQ )}) ] op_id: Op_DPipe ) ] ) left_token: spids: [163 196] ) } spids: [162] ) ] spids: [162] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-n)} {(DQ (${ VSub_Name deps_on_main))} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(echo)} { (DQ ("Package ") (${ VSub_Name i) (" has a cyclic dependency on the main repository.") ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:failed) op: Equal rhs: {(true)} spids: [228] ) ] spids: [228] ) ] spids: [-1 214] ) ] spids: [-1 232] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:deps_on_staging) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (AndOr children: [ (Pipeline children: [ (C {(echo)} {(DQ (${ VSub_Name deps))}) (C {(grep)} {(DQ (k8s.io/kubernetes/vendor/k8s.io))}) (C {(grep)} {(-E)} { (DQ (k8s.io) (EscapedLiteralPart token: ) (${ VSub_Name staging_repos_pattern) (EscapedLiteralPart token:">) ) } ) ] negated: False ) (C {(echo)} {(DQ )}) ] op_id: Op_DPipe ) ] ) left_token: spids: [236 274] ) } spids: [235] ) ] spids: [235] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-n)} {(DQ (${ VSub_Name deps_on_staging))} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} { (DQ ("Package ") (${ VSub_Name i) (" has a cyclic dependency on staging repository packages: ") (${ VSub_Name deps_on_staging) ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:failed) op: Equal rhs: {(true)} spids: [309] ) ] spids: [309] ) ] spids: [-1 292] ) ] spids: [-1 313] ) ] spids: [131 315] ) spids: [119 129] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ (${ VSub_Name failed))} right: {(DQ (true))} ) ) terminator: ) ] action: [(C {(exit)} {(1)})] spids: [-1 337] ) ] spids: [-1 344] ) ] )