Skip to content

Commit 5bfa316

Browse files
authored
Merge pull request #39 from JuliaComputing/tan/misc
use Downloads.jl instead of HTTP.jl
2 parents bc67930 + 98f4f43 commit 5bfa316

File tree

5 files changed

+73
-12
lines changed

5 files changed

+73
-12
lines changed

.github/workflows/ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [master]
5+
tags: ["*"]
6+
pull_request:
7+
jobs:
8+
test:
9+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
version:
15+
- '1.3'
16+
- '1' # automatically expands to the latest stable 1.x release of Julia
17+
- nightly
18+
os:
19+
- ubuntu-latest
20+
arch:
21+
- x64
22+
- x86
23+
include:
24+
# test macOS and Windows with latest Julia only
25+
- os: macOS-latest
26+
arch: x64
27+
version: 1
28+
- os: windows-latest
29+
arch: x64
30+
version: 1
31+
- os: windows-latest
32+
arch: x86
33+
version: 1
34+
steps:
35+
- uses: actions/checkout@v2
36+
- uses: julia-actions/setup-julia@v1
37+
with:
38+
version: ${{ matrix.version }}
39+
arch: ${{ matrix.arch }}
40+
- uses: actions/cache@v1
41+
env:
42+
cache-name: cache-artifacts
43+
with:
44+
path: ~/.julia/artifacts
45+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
46+
restore-keys: |
47+
${{ runner.os }}-test-${{ env.cache-name }}-
48+
${{ runner.os }}-test-
49+
${{ runner.os }}-
50+
- uses: julia-actions/julia-buildpkg@v1
51+
- uses: julia-actions/julia-runtest@v1
52+
- uses: julia-actions/julia-processcoverage@v1
53+
- uses: codecov/codecov-action@v1
54+
with:
55+
file: lcov.info

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ authors = ["Tanmay Mohapatra <[email protected]>"]
44
keywords = ["kubernetes", "client"]
55
license = "MIT"
66
desc = "Julia Kubernetes Client"
7-
version = "0.4.3"
7+
version = "0.5.0"
88

99
[deps]
1010
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
11-
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
11+
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
1212
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
1313
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1414
Swagger = "2d69052b-6a58-5cd9-a030-a48559c324ac"
1515
Retry = "20febd7b-183b-5ae2-ac4a-720e7ce64774"
1616

1717
[compat]
18-
HTTP = "0.8, 0.9"
19-
Swagger = "0.2"
18+
Downloads = "1"
19+
Swagger = "0.3"
2020
JSON = "0.21"
2121
Retry = "0.4"
2222
julia = "1"

src/Kuber.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ module Kuber
22

33
using JSON
44
using Swagger
5-
using HTTP
6-
using Retry, HTTP.IOExtras
5+
using Downloads
6+
using Retry
77

88
include("api/Kubernetes.jl")
99
using .Kubernetes

src/api/Kubernetes.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module Kubernetes
55

66
using Random
77
using Dates
8-
using HTTP
98
using Swagger
109
import Swagger: field_name, property_type, hasproperty, validate_property, SwaggerApi, SwaggerModel
1110
import Base: convert, propertynames

src/helpers.jl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,15 @@ end
5151
kuber_type(ctx::KuberContext, d) = kuber_type(ctx, Any, d)
5252
kuber_type(ctx::KuberContext, T, data::String) = kuber_type(ctx, T, JSON.parse(data))
5353

54-
function kuber_type(ctx::KuberContext, T, resp::HTTP.Response)
55-
ctype = HTTP.header(resp, "Content-Type", "application/json")
54+
function header(resp::Downloads.Response, name::AbstractString, defaultval::AbstractString)
55+
for (n,v) in resp.headers
56+
(n == name) && (return v)
57+
end
58+
return defaultval
59+
end
60+
61+
function kuber_type(ctx::KuberContext, T, resp::Downloads.Response)
62+
ctype = header(resp, "Content-Type", "application/json")
5663
!is_json_mime(ctype) && return T
5764
kuber_type(ctx, T, String(copy(resp.body)))
5865
end
@@ -137,7 +144,7 @@ function fetch_misc_apis_versions(ctx::KuberContext; override=nothing, verbose::
137144
vers = @repeat max_tries try
138145
getAPIVersions(ApisApi(ctx.client))
139146
catch e
140-
@retry if isa(e, IOError)
147+
@retry if isa(e, Base.IOError)
141148
@debug("Retrying getAPIVersions")
142149
sleep(2)
143150
end
@@ -181,7 +188,7 @@ function fetch_core_version(ctx::KuberContext; override=nothing, verbose::Bool=f
181188
api_vers = @repeat max_tries try
182189
getCoreAPIVersions(CoreApi(ctx.client))
183190
catch e
184-
@retry if isa(e, IOError)
191+
@retry if isa(e, Base.IOError)
185192
@debug("Retrying getCoreAPIVersions")
186193
sleep(2)
187194
end
@@ -256,7 +263,7 @@ function retry_on_error(f::Function; max_tries=1)
256263
@repeat max_tries try
257264
return f()
258265
catch e
259-
@retry if isa(e, IOError)
266+
@retry if isa(e, Base.IOError)
260267
@debug("Retrying Kubernetes API call ...")
261268
sleep(2)
262269
end

0 commit comments

Comments
 (0)