@@ -143,17 +143,20 @@ function get(ctx::Union{KuberContext,KuberWatchContext}, O::Symbol, name::String
143
143
max_tries:: Integer = retries (ctx),
144
144
watch= isa (ctx, KuberWatchContext),
145
145
resource_version= nothing ,
146
+ namespace:: Union{String,Nothing} = _kubectx (ctx). namespace,
146
147
kwargs... )
147
148
apictx = _get_apictx (ctx, O, apiversion; max_tries= max_tries)
149
+ namespaced = (namespace != = nothing ) && ! isempty (namespace)
150
+ allnamespaces = namespaced && (namespace == " *" )
148
151
149
152
eventstream = isa (ctx, KuberWatchContext) ? ctx. stream : nothing
150
153
result = nothing
151
154
args = Any[name]
152
155
_O_ = to_snake_case (string (O))
153
- if (apicall = _api_function (ctx, " read_$(_O_) " )) != = nothing
156
+ if namespaced && ! allnamespaces && (apicall = _api_function (ctx, " read_namespaced_$(_O_) " )) != = nothing
157
+ push! (args, namespace)
158
+ elseif (apicall = _api_function (ctx, " read_$(_O_) " )) != = nothing
154
159
# nothing
155
- elseif (apicall = _api_function (ctx, " read_namespaced_$(_O_) " )) != = nothing
156
- push! (args, _kubectx (ctx). namespace)
157
160
else
158
161
throw (ArgumentError (" No API functions could be located using $O " ))
159
162
end
@@ -189,17 +192,22 @@ function get(ctx::Union{KuberContext,KuberWatchContext}, O::Symbol;
189
192
resource_version= nothing ,
190
193
kwargs... )
191
194
apictx = _get_apictx (ctx, O, apiversion; max_tries= max_tries)
195
+ namespaced = (namespace != = nothing ) && ! isempty (namespace)
196
+ allnamespaces = namespaced && (namespace == " *" )
192
197
193
198
eventstream = isa (ctx, KuberWatchContext) ? ctx. stream : nothing
194
199
result = nothing
195
200
args = Any[]
196
201
_O_ = to_snake_case (string (O))
197
202
apiname = " list_$(_O_) "
198
- namespace === nothing && (apiname *= " _for_all_namespaces" )
199
- if (apicall = _api_function (ctx, apiname)) != = nothing
200
- # nothing
201
- elseif (apicall = _api_function (ctx, " list_namespaced_$(_O_) " )) != = nothing
203
+ if allnamespaces && (apicall = _api_function (ctx, apiname * " _for_all_namespaces" )) != = nothing
204
+ # nothing
205
+ elseif namespaced && (apicall = _api_function (ctx, " list_namespaced_$(_O_) " )) != = nothing
202
206
push! (args, namespace)
207
+ elseif (apicall = _api_function (ctx, apiname)) != = nothing
208
+ # nothing
209
+ elseif (apicall = _api_function (ctx, apiname * " _for_all_namespaces" )) != = nothing
210
+ # nothing
203
211
else
204
212
throw (ArgumentError (" No API functions could be located using $O " ))
205
213
end
0 commit comments