Skip to content

Commit 1a3ca83

Browse files
committed
Fixes: #486
1 parent 07c24d2 commit 1a3ca83

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

cmd/k8s-bigip-ctlr/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,15 @@ func init() {
292292
_init()
293293
}
294294

295+
func hasCommonPartition(partitions []string) bool {
296+
for _, x := range partitions {
297+
if x == "Common" {
298+
return true
299+
}
300+
}
301+
return false
302+
}
303+
295304
func verifyArgs() error {
296305
*logLevel = strings.ToUpper(*logLevel)
297306
logErr := initLogger(*logLevel)
@@ -305,6 +314,11 @@ func verifyArgs() error {
305314

306315
if len(*bigIPPartitions) == 0 {
307316
return fmt.Errorf("missing a BIG-IP partition")
317+
} else if len(*bigIPPartitions) > 0 {
318+
err := hasCommonPartition(*bigIPPartitions)
319+
if false != err {
320+
return fmt.Errorf("Common cannot be one of the specified partitions.")
321+
}
308322
}
309323

310324
if (len(*bigIPURL) == 0 || len(*bigIPUsername) == 0 ||

cmd/k8s-bigip-ctlr/main_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,38 @@ var _ = Describe("Main Tests", func() {
253253
Expect(isNodePort).To(BeFalse())
254254
})
255255

256+
It("verifies Common not in list of partitions", func() {
257+
defer _init()
258+
os.Args = []string{
259+
"./bin/k8s-bigip-ctlr",
260+
"--namespace=testing",
261+
"--bigip-partition=velcro1",
262+
"--bigip-partition=velcro2",
263+
"--bigip-password=admin",
264+
"--bigip-url=bigip.example.com",
265+
"--bigip-username=admin",
266+
"--vs-snat-pool-name=test-snat-pool"}
267+
flags.Parse(os.Args)
268+
argError := verifyArgs()
269+
Expect(argError).To(BeNil())
270+
hasCommon := hasCommonPartition(*bigIPPartitions)
271+
Expect(hasCommon).To(BeFalse())
272+
273+
os.Args = []string{
274+
"./bin/k8s-bigip-ctlr",
275+
"--namespace=testing",
276+
"--bigip-partition=velcro1",
277+
"--bigip-partition=Common",
278+
"--bigip-partition=velcro2",
279+
"--bigip-password=admin",
280+
"--bigip-url=bigip.example.com",
281+
"--bigip-username=admin",
282+
"--vs-snat-pool-name=test-snat-pool"}
283+
flags.Parse(os.Args)
284+
hasCommon = hasCommonPartition(*bigIPPartitions)
285+
Expect(hasCommon).To(BeTrue())
286+
})
287+
256288
It("verifies args labels", func() {
257289
defer _init()
258290
os.Args = []string{

0 commit comments

Comments
 (0)