-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ui - enhance flow typing #3002
Merged
Merged
ui - enhance flow typing #3002
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5aaf416
ui: Introduce result type to represent an entity or an error
JBWatenbergScality c01d9ce
ui: Add kubernetes client typing to client wrapper
JBWatenbergScality e875195
ui: Add volume reducer typing
JBWatenbergScality 550c4da
ui: Add constant typing
JBWatenbergScality bbe82c3
ui: Add config and theme typing
JBWatenbergScality f708dea
ui: Start monitoring typing
JBWatenbergScality c269126
ui: Start node typing
JBWatenbergScality f46450a
ui: Add notification typings
JBWatenbergScality 1420c1f
ui: Add pods reducer typing
JBWatenbergScality 4f312b3
ui: Start salt reducer typing
JBWatenbergScality 056857a
ui: Start solutions reducer typing
JBWatenbergScality 07e99ff
ui: Add prometheus alert type
JBWatenbergScality 1022311
ui: Add root state typing
JBWatenbergScality e2509d7
ui: Introduce useTypedSelector to enable simpler typed selection of r…
JBWatenbergScality 48e97b3
ui: Introduce useTypedSelector in volume page
JBWatenbergScality 3db0858
ui: Add a flow typed client generator
JBWatenbergScality 29428b9
ui: Use redux-saga Effect in saga typings
JBWatenbergScality 0ed1ba9
ui: Use generated metalk8s client and types
JBWatenbergScality 28b33c3
ui: Prettier all the things
JBWatenbergScality dbc6f8b
ui: Add Namespaced scope support to meatlk8s client generator
JBWatenbergScality File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## Metalk8s client generator | ||
|
||
It generates a flow client based on `@kubernetes/client` custom objects client from kubernetes `CustomResourceDefinition` of metalk8s volumes. | ||
|
||
### Usage | ||
|
||
```bash | ||
$ npm run generate -- src/__TESTS__/storage.metalk8s.scality.com_volumes_crd.yaml sample/GeneratedClient.js | ||
``` | ||
|
||
### How to contribute ? | ||
|
||
#### Install dependencies | ||
|
||
```bash | ||
$ npm i | ||
``` | ||
|
||
#### Run tests | ||
|
||
```bash | ||
$ npm run test -- --watch | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
presets: [ | ||
['@babel/preset-env', {targets: {node: 'current'}}], | ||
'@babel/preset-typescript', | ||
], | ||
}; | ||
|
||
|
13,376 changes: 13,376 additions & 0 deletions
13,376
ui-metalk8s-client-generator/package-lock.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "metalk8s-client-generator", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "jest", | ||
"generate": "ts-node src/index.ts" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"openapi-to-flowtype": "^0.9.1", | ||
"prettier": "^2.2.1", | ||
"yaml": "^1.10.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.12.10", | ||
"@babel/preset-env": "^7.12.11", | ||
"@babel/preset-typescript": "^7.12.7", | ||
"@types/jest": "^26.0.19", | ||
"babel-jest": "^26.6.3", | ||
"jest": "^26.6.3", | ||
"ts-node": "^9.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,309 @@ | ||
//@flow | ||
// /!\ WARNING : THIS FILE IS AUTOGENERATED FROM A KUBERNETES CUSTOM RESOURCE DEFINITION FILE. DO NOT CHANGE IT, use ui-metalk8s-client-generator to update it. | ||
import { customObjects } from "./api"; | ||
export type Result<T> = T | { error: any }; | ||
|
||
export type Metalk8sV1alpha1Volume = { | ||
apiVersion?: string, | ||
kind?: string, | ||
metadata?: {}, | ||
spec?: { | ||
mode?: "Filesystem" | "Block", | ||
nodeName: string, | ||
rawBlockDevice?: { devicePath: string }, | ||
sparseLoopDevice?: { size: number | string }, | ||
storageClassName: string, | ||
template?: { | ||
metadata?: {}, | ||
spec?: { | ||
accessModes?: Array<string>, | ||
awsElasticBlockStore?: { | ||
fsType?: string, | ||
partition?: number, | ||
readOnly?: boolean, | ||
volumeID: string, | ||
}, | ||
azureDisk?: { | ||
cachingMode?: string, | ||
diskName: string, | ||
diskURI: string, | ||
fsType?: string, | ||
kind?: string, | ||
readOnly?: boolean, | ||
}, | ||
azureFile?: { | ||
readOnly?: boolean, | ||
secretName: string, | ||
secretNamespace?: string, | ||
shareName: string, | ||
}, | ||
capacity?: {}, | ||
cephfs?: { | ||
monitors: Array<string>, | ||
path?: string, | ||
readOnly?: boolean, | ||
secretFile?: string, | ||
secretRef?: { name?: string, namespace?: string }, | ||
user?: string, | ||
}, | ||
cinder?: { | ||
fsType?: string, | ||
readOnly?: boolean, | ||
secretRef?: { name?: string, namespace?: string }, | ||
volumeID: string, | ||
}, | ||
claimRef?: { | ||
apiVersion?: string, | ||
fieldPath?: string, | ||
kind?: string, | ||
name?: string, | ||
namespace?: string, | ||
resourceVersion?: string, | ||
uid?: string, | ||
}, | ||
csi?: { | ||
controllerExpandSecretRef?: { name?: string, namespace?: string }, | ||
controllerPublishSecretRef?: { name?: string, namespace?: string }, | ||
driver: string, | ||
fsType?: string, | ||
nodePublishSecretRef?: { name?: string, namespace?: string }, | ||
nodeStageSecretRef?: { name?: string, namespace?: string }, | ||
readOnly?: boolean, | ||
volumeAttributes?: {}, | ||
volumeHandle: string, | ||
}, | ||
fc?: { | ||
fsType?: string, | ||
lun?: number, | ||
readOnly?: boolean, | ||
targetWWNs?: Array<string>, | ||
wwids?: Array<string>, | ||
}, | ||
flexVolume?: { | ||
driver: string, | ||
fsType?: string, | ||
options?: {}, | ||
readOnly?: boolean, | ||
secretRef?: { name?: string, namespace?: string }, | ||
}, | ||
flocker?: { datasetName?: string, datasetUUID?: string }, | ||
gcePersistentDisk?: { | ||
fsType?: string, | ||
partition?: number, | ||
pdName: string, | ||
readOnly?: boolean, | ||
}, | ||
glusterfs?: { | ||
endpoints: string, | ||
endpointsNamespace?: string, | ||
path: string, | ||
readOnly?: boolean, | ||
}, | ||
hostPath?: { path: string, type?: string }, | ||
iscsi?: { | ||
chapAuthDiscovery?: boolean, | ||
chapAuthSession?: boolean, | ||
fsType?: string, | ||
initiatorName?: string, | ||
iqn: string, | ||
iscsiInterface?: string, | ||
lun: number, | ||
portals?: Array<string>, | ||
readOnly?: boolean, | ||
secretRef?: { name?: string, namespace?: string }, | ||
targetPortal: string, | ||
}, | ||
local?: { fsType?: string, path: string }, | ||
mountOptions?: Array<string>, | ||
nfs?: { path: string, readOnly?: boolean, server: string }, | ||
nodeAffinity?: { | ||
required?: { | ||
nodeSelectorTerms: Array<{ | ||
matchExpressions?: Array<{ | ||
key: string, | ||
operator: string, | ||
values?: Array<string>, | ||
}>, | ||
matchFields?: Array<{ | ||
key: string, | ||
operator: string, | ||
values?: Array<string>, | ||
}>, | ||
}>, | ||
}, | ||
}, | ||
persistentVolumeReclaimPolicy?: string, | ||
photonPersistentDisk?: { fsType?: string, pdID: string }, | ||
portworxVolume?: { | ||
fsType?: string, | ||
readOnly?: boolean, | ||
volumeID: string, | ||
}, | ||
quobyte?: { | ||
group?: string, | ||
readOnly?: boolean, | ||
registry: string, | ||
tenant?: string, | ||
user?: string, | ||
volume: string, | ||
}, | ||
rbd?: { | ||
fsType?: string, | ||
image: string, | ||
keyring?: string, | ||
monitors: Array<string>, | ||
pool?: string, | ||
readOnly?: boolean, | ||
secretRef?: { name?: string, namespace?: string }, | ||
user?: string, | ||
}, | ||
scaleIO?: { | ||
fsType?: string, | ||
gateway: string, | ||
protectionDomain?: string, | ||
readOnly?: boolean, | ||
secretRef: { name?: string, namespace?: string }, | ||
sslEnabled?: boolean, | ||
storageMode?: string, | ||
storagePool?: string, | ||
system: string, | ||
volumeName?: string, | ||
}, | ||
storageClassName?: string, | ||
storageos?: { | ||
fsType?: string, | ||
readOnly?: boolean, | ||
secretRef?: { | ||
apiVersion?: string, | ||
fieldPath?: string, | ||
kind?: string, | ||
name?: string, | ||
namespace?: string, | ||
resourceVersion?: string, | ||
uid?: string, | ||
}, | ||
volumeName?: string, | ||
volumeNamespace?: string, | ||
}, | ||
volumeMode?: string, | ||
vsphereVolume?: { | ||
fsType?: string, | ||
storagePolicyID?: string, | ||
storagePolicyName?: string, | ||
volumePath: string, | ||
}, | ||
}, | ||
}, | ||
}, | ||
status?: { | ||
conditions?: Array<{ | ||
lastTransitionTime?: string, | ||
lastUpdateTime?: string, | ||
message?: string, | ||
reason?: | ||
| "Pending" | ||
| "Terminating" | ||
| "InternalError" | ||
| "CreationError" | ||
| "DestructionError" | ||
| "UnavailableError", | ||
status: "True" | "False" | "Unknown", | ||
type: "Ready", | ||
}>, | ||
deviceName?: string, | ||
job?: string, | ||
}, | ||
}; | ||
export type Metalk8sV1alpha1VolumeList = { | ||
body: { items: Metalk8sV1alpha1Volume[] }, | ||
}; | ||
|
||
export async function getMetalk8sV1alpha1VolumeList(): Promise< | ||
Result<Metalk8sV1alpha1VolumeList> | ||
> { | ||
if (!customObjects) { | ||
return { error: "customObject has not yet been initialized" }; | ||
} | ||
try { | ||
return await customObjects.listClusterCustomObject( | ||
"storage.metalk8s.scality.com", | ||
"v1alpha1", | ||
"volumes" | ||
); | ||
} catch (error) { | ||
return { error }; | ||
} | ||
} | ||
|
||
export async function getMetalk8sV1alpha1Volume( | ||
Metalk8sV1alpha1VolumeName: string | ||
): Promise<Result<Metalk8sV1alpha1Volume>> { | ||
if (!customObjects) { | ||
return { error: "customObject has not yet been initialized" }; | ||
} | ||
try { | ||
return await customObjects.getClusterCustomObject( | ||
"storage.metalk8s.scality.com", | ||
"v1alpha1", | ||
"volumes", | ||
Metalk8sV1alpha1VolumeName | ||
); | ||
} catch (error) { | ||
return { error }; | ||
} | ||
} | ||
|
||
export async function deleteMetalk8sV1alpha1Volume( | ||
Metalk8sV1alpha1VolumeName: string | ||
) { | ||
if (!customObjects) { | ||
return { error: "customObject has not yet been initialized" }; | ||
} | ||
try { | ||
return await customObjects.deleteClusterCustomObject( | ||
"storage.metalk8s.scality.com", | ||
"v1alpha1", | ||
"volumes", | ||
Metalk8sV1alpha1VolumeName, | ||
{} | ||
); | ||
} catch (error) { | ||
return { error }; | ||
} | ||
} | ||
|
||
export async function createMetalk8sV1alpha1Volume( | ||
body: Metalk8sV1alpha1Volume | ||
): Promise<Result<Metalk8sV1alpha1Volume>> { | ||
if (!customObjects) { | ||
return { error: "customObject has not yet been initialized" }; | ||
} | ||
try { | ||
return await customObjects.createClusterCustomObject( | ||
"storage.metalk8s.scality.com", | ||
"v1alpha1", | ||
"volumes", | ||
body | ||
); | ||
} catch (error) { | ||
return { error }; | ||
} | ||
} | ||
|
||
export async function patchMetalk8sV1alpha1Volume( | ||
body: $Shape<Metalk8sV1alpha1Volume> | ||
): Promise<Result<Metalk8sV1alpha1Volume>> { | ||
if (!customObjects) { | ||
return { error: "customObject has not yet been initialized" }; | ||
} | ||
try { | ||
return await customObjects.patchClusterCustomObject( | ||
"storage.metalk8s.scality.com", | ||
"v1alpha1", | ||
"volumes", | ||
body | ||
); | ||
} catch (error) { | ||
return { error }; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome 👍