Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 72399ff

Browse files
committed
Merge pull request #13 from carmark/list
fix the list issues without auth for http server address
2 parents 2a1bc4d + 4ceea83 commit 72399ff

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

pkg/apiserver/resthandler.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,14 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch
279279
errorJSON(err, scope.Codec, w)
280280
return
281281
}
282-
tenant := api.TenantValue(ctx)
283-
if err := filterListInTenant(result, tenant, scope.Kind, scope.Namer); err != nil {
284-
errorJSON(err, scope.Codec, w)
285-
return
282+
//
283+
url := req.Request.URL.String()
284+
if strings.Index(url, "https://") == 0 {
285+
tenant := api.TenantValue(ctx)
286+
if err := filterListInTenant(result, tenant, scope.Kind, scope.Namer); err != nil {
287+
errorJSON(err, scope.Codec, w)
288+
return
289+
}
286290
}
287291
write(http.StatusOK, scope.APIVersion, scope.Codec, result, w, req.Request)
288292
}
@@ -846,15 +850,16 @@ func filterListInTenant(obj runtime.Object, tenant string, kind string, namer Sc
846850
}
847851
}
848852
}
849-
}
850-
if kind == "Namespace" || kind == "Network" {
853+
} else if kind == "Namespace" || kind == "Network" {
851854
for i := range items {
852855
if name, err := namer.ObjectTenant(items[i]); err == nil {
853856
if tenant == name {
854857
result = append(result, items[i])
855858
}
856859
}
857860
}
861+
} else {
862+
result = items
858863
}
859864

860865
return runtime.SetList(obj, result)

0 commit comments

Comments
 (0)