Skip to content

Commit

Permalink
Merge pull request #56 from JuliaComputing/tan/misc
Browse files Browse the repository at this point in the history
better handling in `kuber_obj` method, add debug flag
  • Loading branch information
tanmaykm authored Feb 6, 2023
2 parents 4a702bb + abd6740 commit ef40dbb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = ["Tanmay Mohapatra <[email protected]>"]
keywords = ["kubernetes", "client"]
license = "MIT"
desc = "Julia Kubernetes Client"
version = "0.7.0"
version = "0.7.1"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
12 changes: 8 additions & 4 deletions src/helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,11 @@ function kuber_type(ctx::KuberContext, T, j::Dict{String,Any})
T
end

kuber_obj(ctx::KuberContext, data::String) = kuber_obj(ctx, JSON.parse(data))
kuber_obj(ctx::KuberContext, j::Dict{String,Any}) = convert(kind_to_type(ctx, j["kind"], get(j, "apiVersion", nothing)), j)
# OpenAPI conversions insist that JSONs objects are always `Dict{String,Any}`.
# To ensure that for a user supplied Dict, we serialize that to string and parse it back as json.
kuber_obj(ctx::KuberContext, j::Dict{String,Any}) = kuber_obj(ctx, JSON.json(j))
kuber_obj(ctx::KuberContext, data::String) = _kuber_obj(ctx, JSON.parse(data))
_kuber_obj(ctx::KuberContext, j::Dict{String,Any}) = convert(kind_to_type(ctx, j["kind"], get(j, "apiVersion", nothing)), j)

show(io::IO, ctx::KuberContext) = print(io, "Kubernetes namespace ", ctx.namespace, " at ", ctx.client.root)

Expand Down Expand Up @@ -235,10 +238,11 @@ function set_server(
reset_api_versions::Bool=false;
max_tries=retries(ctx, false),
verbose::Bool=false,
debug::Bool=false,
kwargs...
)
rtfn = (return_types,response_code,response_data)->kuber_type(ctx, return_types, response_code, response_data)
ctx.client = OpenAPI.Clients.Client(uri; get_return_type=rtfn, kwargs...)
ctx.client = OpenAPI.Clients.Client(uri; get_return_type=rtfn, verbose=debug, kwargs...)
ctx.client.headers["Connection"] = "close"
reset_api_versions && set_api_versions!(
ctx;
Expand Down Expand Up @@ -453,4 +457,4 @@ end

# Add validations for the k8s spec specific int-or-string format
OpenAPI.val_format(val::Union{AbstractString,Integer}, ::Val{Symbol("int-or-string")}) = true
OpenAPI.val_format(val, ::Val{Symbol("int-or-string")}) = false
OpenAPI.val_format(val, ::Val{Symbol("int-or-string")}) = false

2 comments on commit ef40dbb

@tanmaykm
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/77098

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.1 -m "<description of version>" ef40dbb8d6de8aceb7ec6597076a923f6d092e78
git push origin v0.7.1

Please sign in to comment.