Skip to content

Commit

Permalink
Merge pull request #2118 from kubernetes-client/master
Browse files Browse the repository at this point in the history
Merge `master` into `release-0.x`
  • Loading branch information
brendandburns authored Dec 20, 2024
2 parents b298b5b + 15c6ef8 commit 8d4a84c
Show file tree
Hide file tree
Showing 854 changed files with 115,455 additions and 95,490 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
time: "02:00"
- package-ecosystem: "npm"
directory: "/"
target-branch: "release-1.x"
schedule:
interval: "daily"
time: "01:00"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
time: "03:00"
13 changes: 9 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ on:
schedule:
- cron: '35 14 * * 3'

permissions:
actions: read
contents: read
security-events: write

jobs:
analyze:
name: Analyze
Expand All @@ -36,11 +41,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

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

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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v3
10 changes: 6 additions & 4 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ on:
push:
branches:
- master
permissions:
contents: write
jobs:
build-and-deploy-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.1
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: '14.x'
node-version: '20'
# Pre-check to validate that versions match between package.json
# and package-lock.json. Needs to run before npm install
- name: Validate package.json and package-lock.json versions
Expand All @@ -23,7 +25,7 @@ jobs:
run: npm run docs

- name: Deploy docs
uses: JamesIves/github-pages-deploy-action@4.1.4
uses: JamesIves/github-pages-deploy-action@v4.7.2
with:
branch: gh-pages # The branch the action should deploy to.
folder: docs # The folder the action should deploy.
80 changes: 80 additions & 0 deletions .github/workflows/generate-javascript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Generate

on:
workflow_dispatch:
inputs:
kubernetesBranch:
type: string
required: true
description: 'The remote kubernetes release branch to fetch openapi spec. .e.g. "release-1.23"'
genCommit:
type: string
required: true
default: 'f0bb447'
description: 'The commit to use for the kubernetes-client/gen repo'


jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout Javascript
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Checkout Gen
run: |
git clone https://github.com/kubernetes-client/gen
pushd gen
git checkout "${{ github.event.inputs.genCommit }}"
# apply https://github.com/kubernetes-client/gen/pull/224
git config --global user.name "Github Actions"
git config --global user.email "<>"
git cherry-pick --strategy=recursive -X theirs c557f7f b32dcd6 0ef2cec 9701a7c a608a9d
rm -rf gen/.git
# apply https://github.com/kubernetes-client/gen/pull/237
- name: Patch Dockerfile
run: echo "RUN git config --system --add safe.directory /source/openapi-generator" >> gen/openapi/openapi-generator/Dockerfile
- name: Generate Branch Name
run: |
SUFFIX=$(openssl rand -hex 4)
echo "BRANCH=automated-generate-$SUFFIX" >> $GITHUB_ENV
- name: Generate Openapi
run: |
pushd gen/openapi
cat <<"EOF"> settings
# kubernetes-client/gen commit to use for code generation.
export GEN_COMMIT="${{ github.event.inputs.genCommit }}"
# GitHub username/organization to clone kubernetes repo from.
export USERNAME=kubernetes
# Kubernetes branch/tag to get the OpenAPI spec from.
export KUBERNETES_BRANCH="${{ github.event.inputs.kubernetesBranch }}"
# client version for packaging and releasing. It can
# be different than SPEC_VERSION.
export CLIENT_VERSION="0.8-SNAPSHOT"
# Name of the release package
export PACKAGE_NAME="@kubernetes/node-client"
export OPENAPI_GENERATOR_COMMIT=1314e229
EOF
bash typescript.sh ../../src/gen settings
popd
cp settings ../../settings
rm -rf gen
- name: Commit and push
run: |
# Commit and push
git config user.email "[email protected]"
git config user.name "Kubernetes Prow Robot"
git checkout -b "$BRANCH"
git add .
git commit -s -m 'Automated openapi generation from ${{ github.event.inputs.kubernetesBranch }}'
git push origin "$BRANCH"
- name: Pull Request
uses: repo-sync/pull-request@v2
with:
source_branch: ${{ env.BRANCH }}
destination_branch: ${{ github.ref_name }}
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: "Automated Generate from openapi ${{ github.event.inputs.kubernetesBranch }}"
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Release

permissions:
contents: write

on:
workflow_dispatch:
inputs:
releaseVersion:
type: string
required: true
description: The version of this release. Must be a semantic version of the form X.Y.Z.
dry_run:
type: boolean
required: true
default: false
description: Dry run, will not push branches or upload the artifacts.
pre_release:
type: boolean
required: true
default: false
description: If true, push pre-release tag.
skip_tag:
type: boolean
required: true
default: false
description: If true, don't tag this release, just push it.

jobs:
release:
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout Javascript
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Package
run: ./build-package.sh
- name: Upload
if: ${{ github.event.inputs.dry_run != 'true' && github.event.inputs.pre_release != 'true' }}
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Upload pre-release
if: ${{ github.event.inputs.dry_run != 'true' && github.event.inputs.pre_release == 'true' }}
run: npm publish --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Tag release
if: ${{ github.event.inputs.skip_tag != 'true' }}
run: |
git config --global user.name 'Github Bot'
git config --global user.email '<>'
git tag ${{ github.events.inputs.releaseVersion }}
- name: Push tag
if: ${{ github.event.inputs.dry_run != 'true' }}
run: |
git push ${{ github.events.inputs.releaseVersion }}
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '16', '14', '12' ]
# Remove specific version from 20 when https://github.com/tschaub/mock-fs/issues/380 is fixed
node: [ '22', '20.7.0', '18' ]
name: Node ${{ matrix.node }} validation
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
# Pre-check to validate that versions match between package.json
Expand Down
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pretty-quick
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm test && npm run lint
10 changes: 10 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"require": "tsx",
"extensions": ["ts"],
"spec": [
"src/**/*_test.ts"
],
"watch-files": [
"src"
]
}
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ We'd love to accept your patches! Before we can accept them you need to sign Clo
## Reporting an issue
If you have any problem with the package or any suggestions, please file an [issue](https://github.com/kubernetes-client/javascript/issues).

Note: Before raising a new issue, please do check the existing issues and make sure it is not a duplicate one.

## Contributing a Patch
1. Submit an issue describing your proposed change to the repo.
2. Fork this repo, develop and test your code changes.
Expand Down
47 changes: 23 additions & 24 deletions FETCH_MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

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.

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)).
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)).

[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.
[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.

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

Edit 02/2022:

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.

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.


## Release cycle

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

- [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>
- [ ] 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>
- [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>

### Kubernetes-client repository

- [ ] 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)
- [ ] `npm install node-fetch` to install node-fetch
- [ ] Switch generate-client script to use typescript-fetch
- [ ] Import and inject node-fetch in `src/api.ts` with the following

```typescript
import fetch from 'node-fetch';

// inject node-fetch
if (!globalThis.fetch) {
// @ts-ignore
globalThis.fetch = fetch;
globalThis.Headers = Headers;
globalThis.Request = Request;
globalThis.Response = Response;
}
```

- [ ] Generate api with `npm run generate`
- [ ] Match src/gen/api.ts to new generated layout (it changes slightly)
- [ ] Fix errors in /src folder (due to new api)
- [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)
- [x] `npm install node-fetch` to install node-fetch
- [ ] ~~Switch generate-client script to use typescript-fetch~~ (see edit 02/2022)
- [ ] ~~Import and inject node-fetch in `src/api.ts`~~ (see edit 02/2022)

- [x] Generate api with `npm run generate`
- [x] Match src/gen/api.ts to new generated layout (it changes slightly)

- [ ] Fix errors in /src folder (due to new generated api)
- [ ] Migrate watch.ts to use node-fetch
- [ ] Migrate log.ts to use node-fetch
- [ ] Migrate metrics.ts to use node-fetch
- [ ] Migrate HttpError Usage to HttpException (following new OpenApiGen convention)
- [ ] Fix errors in test (due to new api)
- [ ] Test all features
- [ ] Fix examples (due to new api)
Expand Down
11 changes: 8 additions & 3 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- brendandburns
- drubin
- mstruebing
- davidgamero
- cjihrig
reviewers:
- brendandburns
- drubin
- itowlson
- mstruebing
- davidgamero
- cjihrig
emeritus_approvers:
- mbohlool # 10/22/2020
- drubin # 11/23/2023
- itowlson # 11/23/2023
Loading

0 comments on commit 8d4a84c

Please sign in to comment.