Skip to content

Commit 8d4a84c

Browse files
Merge pull request #2118 from kubernetes-client/master
Merge `master` into `release-0.x`
2 parents b298b5b + 15c6ef8 commit 8d4a84c

File tree

854 files changed

+115455
-95490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

854 files changed

+115455
-95490
lines changed

.github/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
time: "02:00"
8+
- package-ecosystem: "npm"
9+
directory: "/"
10+
target-branch: "release-1.x"
11+
schedule:
12+
interval: "daily"
13+
time: "01:00"
14+
- package-ecosystem: "github-actions"
15+
directory: "/"
16+
schedule:
17+
interval: "daily"
18+
time: "03:00"

.github/workflows/codeql-analysis.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ on:
2121
schedule:
2222
- cron: '35 14 * * 3'
2323

24+
permissions:
25+
actions: read
26+
contents: read
27+
security-events: write
28+
2429
jobs:
2530
analyze:
2631
name: Analyze
@@ -36,11 +41,11 @@ jobs:
3641

3742
steps:
3843
- name: Checkout repository
39-
uses: actions/checkout@v2
44+
uses: actions/checkout@v4
4045

4146
# Initializes the CodeQL tools for scanning.
4247
- name: Initialize CodeQL
43-
uses: github/codeql-action/init@v1
48+
uses: github/codeql-action/init@v3
4449
with:
4550
languages: ${{ matrix.language }}
4651
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -51,7 +56,7 @@ jobs:
5156
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5257
# If this step fails, then you should remove it and run the build manually (see below)
5358
- name: Autobuild
54-
uses: github/codeql-action/autobuild@v1
59+
uses: github/codeql-action/autobuild@v3
5560

5661
# ℹ️ Command-line programs to run using the OS shell.
5762
# 📚 https://git.io/JvXDl
@@ -65,4 +70,4 @@ jobs:
6570
# make release
6671

6772
- name: Perform CodeQL Analysis
68-
uses: github/codeql-action/analyze@v1
73+
uses: github/codeql-action/analyze@v3

.github/workflows/deploy-docs.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@ on:
33
push:
44
branches:
55
- master
6+
permissions:
7+
contents: write
68
jobs:
79
build-and-deploy-docs:
810
runs-on: ubuntu-latest
911
steps:
1012
- name: Checkout
11-
uses: actions/checkout@v2.3.1
13+
uses: actions/checkout@v4
1214
- name: Setup Node.js
13-
uses: actions/setup-node@v2
15+
uses: actions/setup-node@v4
1416
with:
15-
node-version: '14.x'
17+
node-version: '20'
1618
# Pre-check to validate that versions match between package.json
1719
# and package-lock.json. Needs to run before npm install
1820
- name: Validate package.json and package-lock.json versions
@@ -23,7 +25,7 @@ jobs:
2325
run: npm run docs
2426

2527
- name: Deploy docs
26-
uses: JamesIves/github-pages-deploy-action@4.1.4
28+
uses: JamesIves/github-pages-deploy-action@v4.7.2
2729
with:
2830
branch: gh-pages # The branch the action should deploy to.
2931
folder: docs # The folder the action should deploy.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Generate
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
kubernetesBranch:
7+
type: string
8+
required: true
9+
description: 'The remote kubernetes release branch to fetch openapi spec. .e.g. "release-1.23"'
10+
genCommit:
11+
type: string
12+
required: true
13+
default: 'f0bb447'
14+
description: 'The commit to use for the kubernetes-client/gen repo'
15+
16+
17+
jobs:
18+
generate:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout Javascript
22+
uses: actions/checkout@v4
23+
- name: Setup Node
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '20'
27+
- name: Checkout Gen
28+
run: |
29+
git clone https://github.com/kubernetes-client/gen
30+
pushd gen
31+
git checkout "${{ github.event.inputs.genCommit }}"
32+
# apply https://github.com/kubernetes-client/gen/pull/224
33+
git config --global user.name "Github Actions"
34+
git config --global user.email "<>"
35+
git cherry-pick --strategy=recursive -X theirs c557f7f b32dcd6 0ef2cec 9701a7c a608a9d
36+
rm -rf gen/.git
37+
# apply https://github.com/kubernetes-client/gen/pull/237
38+
- name: Patch Dockerfile
39+
run: echo "RUN git config --system --add safe.directory /source/openapi-generator" >> gen/openapi/openapi-generator/Dockerfile
40+
- name: Generate Branch Name
41+
run: |
42+
SUFFIX=$(openssl rand -hex 4)
43+
echo "BRANCH=automated-generate-$SUFFIX" >> $GITHUB_ENV
44+
- name: Generate Openapi
45+
run: |
46+
pushd gen/openapi
47+
cat <<"EOF"> settings
48+
# kubernetes-client/gen commit to use for code generation.
49+
export GEN_COMMIT="${{ github.event.inputs.genCommit }}"
50+
# GitHub username/organization to clone kubernetes repo from.
51+
export USERNAME=kubernetes
52+
# Kubernetes branch/tag to get the OpenAPI spec from.
53+
export KUBERNETES_BRANCH="${{ github.event.inputs.kubernetesBranch }}"
54+
# client version for packaging and releasing. It can
55+
# be different than SPEC_VERSION.
56+
export CLIENT_VERSION="0.8-SNAPSHOT"
57+
# Name of the release package
58+
export PACKAGE_NAME="@kubernetes/node-client"
59+
export OPENAPI_GENERATOR_COMMIT=1314e229
60+
EOF
61+
bash typescript.sh ../../src/gen settings
62+
popd
63+
cp settings ../../settings
64+
rm -rf gen
65+
- name: Commit and push
66+
run: |
67+
# Commit and push
68+
git config user.email "k8s.ci.robot@gmail.com"
69+
git config user.name "Kubernetes Prow Robot"
70+
git checkout -b "$BRANCH"
71+
git add .
72+
git commit -s -m 'Automated openapi generation from ${{ github.event.inputs.kubernetesBranch }}'
73+
git push origin "$BRANCH"
74+
- name: Pull Request
75+
uses: repo-sync/pull-request@v2
76+
with:
77+
source_branch: ${{ env.BRANCH }}
78+
destination_branch: ${{ github.ref_name }}
79+
github_token: ${{ secrets.GITHUB_TOKEN }}
80+
pr_title: "Automated Generate from openapi ${{ github.event.inputs.kubernetesBranch }}"

.github/workflows/release.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Release
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
releaseVersion:
10+
type: string
11+
required: true
12+
description: The version of this release. Must be a semantic version of the form X.Y.Z.
13+
dry_run:
14+
type: boolean
15+
required: true
16+
default: false
17+
description: Dry run, will not push branches or upload the artifacts.
18+
pre_release:
19+
type: boolean
20+
required: true
21+
default: false
22+
description: If true, push pre-release tag.
23+
skip_tag:
24+
type: boolean
25+
required: true
26+
default: false
27+
description: If true, don't tag this release, just push it.
28+
29+
jobs:
30+
release:
31+
runs-on: ubuntu-latest
32+
environment: production
33+
steps:
34+
- name: Checkout Javascript
35+
uses: actions/checkout@v4
36+
- name: Setup Node
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: '20'
40+
registry-url: 'https://registry.npmjs.org'
41+
- name: Install dependencies
42+
run: npm install
43+
- name: Package
44+
run: ./build-package.sh
45+
- name: Upload
46+
if: ${{ github.event.inputs.dry_run != 'true' && github.event.inputs.pre_release != 'true' }}
47+
run: npm publish
48+
env:
49+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
50+
- name: Upload pre-release
51+
if: ${{ github.event.inputs.dry_run != 'true' && github.event.inputs.pre_release == 'true' }}
52+
run: npm publish --tag next
53+
env:
54+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
55+
- name: Tag release
56+
if: ${{ github.event.inputs.skip_tag != 'true' }}
57+
run: |
58+
git config --global user.name 'Github Bot'
59+
git config --global user.email '<>'
60+
git tag ${{ github.events.inputs.releaseVersion }}
61+
- name: Push tag
62+
if: ${{ github.event.inputs.dry_run != 'true' }}
63+
run: |
64+
git push ${{ github.events.inputs.releaseVersion }}

.github/workflows/test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
node: [ '16', '14', '12' ]
14+
# Remove specific version from 20 when https://github.com/tschaub/mock-fs/issues/380 is fixed
15+
node: [ '22', '20.7.0', '18' ]
1516
name: Node ${{ matrix.node }} validation
1617
steps:
17-
- uses: actions/checkout@v2
18-
- uses: actions/setup-node@v2
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-node@v4
1920
with:
2021
node-version: ${{ matrix.node }}
2122
# Pre-check to validate that versions match between package.json

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pretty-quick

.husky/pre-push

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm test && npm run lint

.mocharc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"require": "tsx",
3+
"extensions": ["ts"],
4+
"spec": [
5+
"src/**/*_test.ts"
6+
],
7+
"watch-files": [
8+
"src"
9+
]
10+
}

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ We'd love to accept your patches! Before we can accept them you need to sign Clo
1212
## Reporting an issue
1313
If you have any problem with the package or any suggestions, please file an [issue](https://github.com/kubernetes-client/javascript/issues).
1414

15+
Note: Before raising a new issue, please do check the existing issues and make sure it is not a duplicate one.
16+
1517
## Contributing a Patch
1618
1. Submit an issue describing your proposed change to the repo.
1719
2. Fork this repo, develop and test your code changes.

FETCH_MIGRATION.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22

33
Request is fully deprecated requiring us to switch libraries (see [#414](https://github.com/kubernetes-client/javascript/issues/414) for more information). There were a few [different options](https://github.com/kubernetes-client/javascript/issues/414#issuecomment-978031677) for how this swap should be implemented but moving to a new open-api generator option was chosen since this project will acquire the advantages of an up-to-date open-api generator version.
44

5-
Fetch was selected as the new HTTP request library for this project due to its widespread adoption across the JavaScript ecosystem. Additonally, potential future updates to this project could allow this client to be available with browser JavaScript since fetch is native to the browser ([#165](https://github.com/kubernetes-client/javascript/issues/165)).
5+
Fetch was selected as the new HTTP request library for this project due to its widespread adoption across the JavaScript ecosystem. Additionally, potential future updates to this project could allow this client to be available with browser JavaScript since fetch is native to the browser ([#165](https://github.com/kubernetes-client/javascript/issues/165)).
66

7-
[Node-fetch](https://www.npmjs.com/package/node-fetch) is our specific fetch package since it is the largest Node.js compatable implementation. Fetch is not implemented by default in Node.
7+
[Node-fetch](https://www.npmjs.com/package/node-fetch) is our specific fetch package since it is the largest Node.js compatible implementation. Fetch is not implemented by default in Node.
88

99
For more details see the initial discussion ([#754](https://github.com/kubernetes-client/javascript/issues/754)).
1010

11+
Edit 02/2022:
12+
13+
Since the OpenApiGenerator project is targeting a single `typescript` generator (instead of individual networking flavors eg: typescript-fetch, typescript-axios) that includes node-fetch support, the initial plans to import and inject node-fetch is no longer optimal.
14+
15+
The proposed changes have been implemented on the new `typescript` generator which includes changes to the authentication and authorization interface that now uses a `RequestContext` object instead of directly allowing access to the https request options. In order to bridge the existing javascript client auth methods, additional exposure via custom SecurityAuthentication support has [been merged](https://github.com/OpenAPITools/openapi-generator/pull/11321) into the typescript generator.
16+
17+
1118
## Release cycle
1219

1320
The fetch generator will create breaking changes to this project's API. Consumers will have to make small modifications to their code to upgrade.
@@ -40,31 +47,23 @@ Code will be on the `master` branch.
4047
### Other repositories
4148

4249
- [x] Update [kubernetes-client/gen](https://github.com/kubernetes-client/gen)'s typescript-fetch files to let us pass in the `typescriptThreePlus` config option <sup>[1](https://github.com/OpenAPITools/openapi-generator/issues/9973) [2](https://github.com/OpenAPITools/openapi-generator/issues/3869#issuecomment-584152932)</sub>
43-
- [ ] Update [openapi-generator](https://github.com/OpenAPITools/openapi-generator)'s typescript-fetch flavor to mark parameters as optional if all parameters are optional <sup>[3](https://github.com/OpenAPITools/openapi-generator/issues/6440)</sup>
50+
- [x] Update [openapi-generator](https://github.com/OpenAPITools/openapi-generator)'s typescript-fetch flavor to mark parameters as optional if all parameters are optional <sup>[3](https://github.com/OpenAPITools/openapi-generator/issues/6440)</sup>
4451

4552
### Kubernetes-client repository
4653

47-
- [ ] Increment `OPENAPI_GENERATOR_COMMIT` to be [version 5.3.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.3.0) (with the optional parameters addition)
48-
- [ ] `npm install node-fetch` to install node-fetch
49-
- [ ] Switch generate-client script to use typescript-fetch
50-
- [ ] Import and inject node-fetch in `src/api.ts` with the following
51-
52-
```typescript
53-
import fetch from 'node-fetch';
54-
55-
// inject node-fetch
56-
if (!globalThis.fetch) {
57-
// @ts-ignore
58-
globalThis.fetch = fetch;
59-
globalThis.Headers = Headers;
60-
globalThis.Request = Request;
61-
globalThis.Response = Response;
62-
}
63-
```
64-
65-
- [ ] Generate api with `npm run generate`
66-
- [ ] Match src/gen/api.ts to new generated layout (it changes slightly)
67-
- [ ] Fix errors in /src folder (due to new api)
54+
- [x] Increment `OPENAPI_GENERATOR_COMMIT` to be [version 5.3.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.3.0) (with the optional parameters addition)
55+
- [x] `npm install node-fetch` to install node-fetch
56+
- [ ] ~~Switch generate-client script to use typescript-fetch~~ (see edit 02/2022)
57+
- [ ] ~~Import and inject node-fetch in `src/api.ts`~~ (see edit 02/2022)
58+
59+
- [x] Generate api with `npm run generate`
60+
- [x] Match src/gen/api.ts to new generated layout (it changes slightly)
61+
62+
- [ ] Fix errors in /src folder (due to new generated api)
63+
- [ ] Migrate watch.ts to use node-fetch
64+
- [ ] Migrate log.ts to use node-fetch
65+
- [ ] Migrate metrics.ts to use node-fetch
66+
- [ ] Migrate HttpError Usage to HttpException (following new OpenApiGen convention)
6867
- [ ] Fix errors in test (due to new api)
6968
- [ ] Test all features
7069
- [ ] Fix examples (due to new api)

OWNERS

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# See the OWNERS docs at https://go.k8s.io/owners
22
approvers:
33
- brendandburns
4-
- drubin
4+
- mstruebing
5+
- davidgamero
6+
- cjihrig
57
reviewers:
68
- brendandburns
7-
- drubin
8-
- itowlson
9+
- mstruebing
10+
- davidgamero
11+
- cjihrig
912
emeritus_approvers:
1013
- mbohlool # 10/22/2020
14+
- drubin # 11/23/2023
15+
- itowlson # 11/23/2023

0 commit comments

Comments
 (0)