Skip to content

Commit

Permalink
refactor: update nginx controller
Browse files Browse the repository at this point in the history
chore: When a leader is lost, it is now immediately aborted.
chore: When the NginxCluster spec is changed, the pod is restarted.
  • Loading branch information
kahirokunn committed May 19, 2024
1 parent 4fe5a14 commit d542641
Show file tree
Hide file tree
Showing 10 changed files with 725 additions and 1,058 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
"author": "",
"license": "MIT",
"dependencies": {
"@kubekit/client": "0.1.18"
"@kubekit/client": "0.2.10",
"object-hash": "^3.0.0"
},
"devDependencies": {
"@kubekit/client-gen": "^0.1.0",
"@kubekit/client-gen": "0.1.4",
"@kubekit/sync": "0.1.3",
"@types/node": "^20.12.12",
"@types/object-hash": "^3.0.6",
"esbuild": "^0.20.2",
"esbuild-runner": "^2.2.2",
"npm-run-all": "^4.1.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
type Options,
type WatchExtraOptions,
} from '@kubekit/client'
type Id<T> = {
export type Id<T> = {
[K in keyof T]: T[K]
} & {}
type NoWatch<T> = Omit<T, 'watch'> & {
Expand All @@ -12,10 +12,10 @@ type NoWatch<T> = Omit<T, 'watch'> & {
type RequiredAndDefined<T> = {
[P in keyof T]-?: Exclude<T[P], null | undefined>
}
type PartialRequired<T, K extends keyof T> = Id<
export type PartialRequired<T, K extends keyof T> = Id<
RequiredAndDefined<Pick<T, K>> & Omit<T, K>
>
type MinimumRequiredGet<T> = Id<
export type Strict<T> = Id<
T extends {
metadata?: any
apiVersion?: any
Expand All @@ -27,12 +27,12 @@ type MinimumRequiredGet<T> = Id<
> & {
metadata: PartialRequired<
RequiredAndDefined<T>['metadata'],
'name' | 'namespace' | 'creationTimestamp' | 'resourceVersion'
'name' | 'namespace' | 'creationTimestamp' | 'resourceVersion' | 'uid'
>
}
: T
>
type MinimumRequiredList<T> = Id<
type StrictList<T> = Id<
T extends {
items: {
metadata?: any
Expand All @@ -41,36 +41,35 @@ type MinimumRequiredList<T> = Id<
}[]
}
? Omit<T, 'items'> & {
items: MinimumRequiredGet<T['items'][number]>[]
items: Strict<T['items'][number]>[]
}
: T
>
export const getCoordinationV1ApiResources = (options?: Options) => {
return apiClient<
MinimumRequiredGet<GetCoordinationV1ApiResourcesApiResponse>
>({ path: `/apis/coordination.k8s.io/v1/` }, options)
return apiClient<Strict<GetCoordinationV1ApiResourcesApiResponse>>(
{ path: `/apis/coordination.k8s.io/v1/` },
options
)
}
export function listCoordinationV1LeaseForAllNamespaces(
args: NoWatch<ListCoordinationV1LeaseForAllNamespacesApiArg>,
options?: Options
): Promise<
MinimumRequiredList<ListCoordinationV1LeaseForAllNamespacesApiResponse>
>
): Promise<StrictList<ListCoordinationV1LeaseForAllNamespacesApiResponse>>
export function listCoordinationV1LeaseForAllNamespaces(
args: ListCoordinationV1LeaseForAllNamespacesApiArg & {
watch: true
},
options: Options &
WatchExtraOptions<
MinimumRequiredList<ListCoordinationV1LeaseForAllNamespacesApiResponse>
StrictList<ListCoordinationV1LeaseForAllNamespacesApiResponse>
>
): Promise<void>
export function listCoordinationV1LeaseForAllNamespaces(
args: any,
options: any
): any {
return apiClient<
MinimumRequiredList<ListCoordinationV1LeaseForAllNamespacesApiResponse>
StrictList<ListCoordinationV1LeaseForAllNamespacesApiResponse>
>(
{
path: `/apis/coordination.k8s.io/v1/leases`,
Expand All @@ -94,23 +93,19 @@ export function listCoordinationV1LeaseForAllNamespaces(
export function listCoordinationV1NamespacedLease(
args: NoWatch<ListCoordinationV1NamespacedLeaseApiArg>,
options?: Options
): Promise<MinimumRequiredList<ListCoordinationV1NamespacedLeaseApiResponse>>
): Promise<StrictList<ListCoordinationV1NamespacedLeaseApiResponse>>
export function listCoordinationV1NamespacedLease(
args: ListCoordinationV1NamespacedLeaseApiArg & {
watch: true
},
options: Options &
WatchExtraOptions<
MinimumRequiredList<ListCoordinationV1NamespacedLeaseApiResponse>
>
WatchExtraOptions<StrictList<ListCoordinationV1NamespacedLeaseApiResponse>>
): Promise<void>
export function listCoordinationV1NamespacedLease(
args: any,
options: any
): any {
return apiClient<
MinimumRequiredList<ListCoordinationV1NamespacedLeaseApiResponse>
>(
return apiClient<StrictList<ListCoordinationV1NamespacedLeaseApiResponse>>(
{
path: `/apis/coordination.k8s.io/v1/namespaces/${args['namespace']}/leases`,
params: {
Expand All @@ -134,9 +129,7 @@ export const createCoordinationV1NamespacedLease = (
args: CreateCoordinationV1NamespacedLeaseApiArg,
options?: Options
) => {
return apiClient<
MinimumRequiredGet<CreateCoordinationV1NamespacedLeaseApiResponse>
>(
return apiClient<Strict<CreateCoordinationV1NamespacedLeaseApiResponse>>(
{
path: `/apis/coordination.k8s.io/v1/namespaces/${args['namespace']}/leases`,
method: 'POST',
Expand All @@ -157,7 +150,7 @@ export const deleteCoordinationV1CollectionNamespacedLease = (
options?: Options
) => {
return apiClient<
MinimumRequiredGet<DeleteCoordinationV1CollectionNamespacedLeaseApiResponse>
Strict<DeleteCoordinationV1CollectionNamespacedLeaseApiResponse>
>(
{
path: `/apis/coordination.k8s.io/v1/namespaces/${args['namespace']}/leases`,
Expand Down Expand Up @@ -187,9 +180,7 @@ export const readCoordinationV1NamespacedLease = (
args: ReadCoordinationV1NamespacedLeaseApiArg,
options?: Options
) => {
return apiClient<
MinimumRequiredGet<ReadCoordinationV1NamespacedLeaseApiResponse>
>(
return apiClient<Strict<ReadCoordinationV1NamespacedLeaseApiResponse>>(
{
path: `/apis/coordination.k8s.io/v1/namespaces/${args['namespace']}/leases/${args.name}`,
params: { pretty: args.pretty },
Expand All @@ -201,9 +192,7 @@ export const replaceCoordinationV1NamespacedLease = (
args: ReplaceCoordinationV1NamespacedLeaseApiArg,
options?: Options
) => {
return apiClient<
MinimumRequiredGet<ReplaceCoordinationV1NamespacedLeaseApiResponse>
>(
return apiClient<Strict<ReplaceCoordinationV1NamespacedLeaseApiResponse>>(
{
path: `/apis/coordination.k8s.io/v1/namespaces/${args['namespace']}/leases/${args.name}`,
method: 'PUT',
Expand All @@ -223,9 +212,7 @@ export const deleteCoordinationV1NamespacedLease = (
args: DeleteCoordinationV1NamespacedLeaseApiArg,
options?: Options
) => {
return apiClient<
MinimumRequiredGet<DeleteCoordinationV1NamespacedLeaseApiResponse>
>(
return apiClient<Strict<DeleteCoordinationV1NamespacedLeaseApiResponse>>(
{
path: `/apis/coordination.k8s.io/v1/namespaces/${args['namespace']}/leases/${args.name}`,
method: 'DELETE',
Expand All @@ -246,9 +233,7 @@ export const patchCoordinationV1NamespacedLease = (
args: PatchCoordinationV1NamespacedLeaseApiArg,
options?: Options
) => {
return apiClient<
MinimumRequiredGet<PatchCoordinationV1NamespacedLeaseApiResponse>
>(
return apiClient<Strict<PatchCoordinationV1NamespacedLeaseApiResponse>>(
{
path: `/apis/coordination.k8s.io/v1/namespaces/${args['namespace']}/leases/${args.name}`,
method: 'PATCH',
Expand All @@ -270,7 +255,7 @@ export const watchCoordinationV1LeaseListForAllNamespaces = (
options?: Options
) => {
return apiClient<
MinimumRequiredList<WatchCoordinationV1LeaseListForAllNamespacesApiResponse>
StrictList<WatchCoordinationV1LeaseListForAllNamespacesApiResponse>
>(
{
path: `/apis/coordination.k8s.io/v1/watch/leases`,
Expand All @@ -296,7 +281,7 @@ export const watchCoordinationV1NamespacedLeaseList = (
options?: Options
) => {
return apiClient<
MinimumRequiredList<WatchCoordinationV1NamespacedLeaseListApiResponse>
StrictList<WatchCoordinationV1NamespacedLeaseListApiResponse>
>(
{
path: `/apis/coordination.k8s.io/v1/watch/namespaces/${args['namespace']}/leases`,
Expand All @@ -321,9 +306,7 @@ export const watchCoordinationV1NamespacedLease = (
args: WatchCoordinationV1NamespacedLeaseApiArg,
options?: Options
) => {
return apiClient<
MinimumRequiredList<WatchCoordinationV1NamespacedLeaseApiResponse>
>(
return apiClient<StrictList<WatchCoordinationV1NamespacedLeaseApiResponse>>(
{
path: `/apis/coordination.k8s.io/v1/watch/namespaces/${args['namespace']}/leases/${args.name}`,
params: {
Expand Down
Loading

0 comments on commit d542641

Please sign in to comment.