@@ -583,35 +583,37 @@ func TestRBAC(t *testing.T) {
583
583
previousResourceVersion := make (map [string ]float64 )
584
584
585
585
for j , r := range tc .requests {
586
- path := "/"
586
+ // This is a URL-path, not a local path, so we use the "path"
587
+ // package (aliased as "gopath") instead of "path/filepath".
588
+ urlPath := "/"
587
589
if r .apiGroup == "" {
588
- path = gopath .Join (path , "api/v1" )
590
+ urlPath = gopath .Join (urlPath , "api/v1" )
589
591
} else {
590
- path = gopath .Join (path , "apis" , r .apiGroup , "v1" )
592
+ urlPath = gopath .Join (urlPath , "apis" , r .apiGroup , "v1" )
591
593
}
592
594
if r .namespace != "" {
593
- path = gopath .Join (path , "namespaces" , r .namespace )
595
+ urlPath = gopath .Join (urlPath , "namespaces" , r .namespace )
594
596
}
595
597
if r .resource != "" {
596
- path = gopath .Join (path , r .resource )
598
+ urlPath = gopath .Join (urlPath , r .resource )
597
599
}
598
600
if r .name != "" {
599
- path = gopath .Join (path , r .name )
601
+ urlPath = gopath .Join (urlPath , r .name )
600
602
}
601
603
602
604
var body io.Reader
603
605
if r .body != "" {
604
606
sub := ""
605
607
if r .verb == "PUT" {
606
608
// For update operations, insert previous resource version
607
- if resVersion := previousResourceVersion [getPreviousResourceVersionKey (path , "" )]; resVersion != 0 {
609
+ if resVersion := previousResourceVersion [getPreviousResourceVersionKey (urlPath , "" )]; resVersion != 0 {
608
610
sub += fmt .Sprintf (",\" resourceVersion\" : \" %v\" " , resVersion )
609
611
}
610
612
}
611
613
body = strings .NewReader (fmt .Sprintf (r .body , sub ))
612
614
}
613
615
614
- req , err := http .NewRequest (r .verb , kubeConfig .Host + path , body )
616
+ req , err := http .NewRequest (r .verb , kubeConfig .Host + urlPath , body )
615
617
if r .verb == "PATCH" {
616
618
// For patch operations, use the apply content type
617
619
req .Header .Add ("Content-Type" , string (types .ApplyPatchType ))
@@ -662,7 +664,7 @@ func TestRBAC(t *testing.T) {
662
664
// For successful create operations, extract resourceVersion
663
665
id , currentResourceVersion , err := parseResourceVersion (b )
664
666
if err == nil {
665
- key := getPreviousResourceVersionKey (path , id )
667
+ key := getPreviousResourceVersionKey (urlPath , id )
666
668
previousResourceVersion [key ] = currentResourceVersion
667
669
} else {
668
670
t .Logf ("error in trying to extract resource version: %s" , err )
0 commit comments