Skip to content
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 20 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
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 Jan 8, 2021
c01d9ce
ui: Add kubernetes client typing to client wrapper
JBWatenbergScality Dec 24, 2020
e875195
ui: Add volume reducer typing
JBWatenbergScality Dec 24, 2020
550c4da
ui: Add constant typing
JBWatenbergScality Dec 24, 2020
bbe82c3
ui: Add config and theme typing
JBWatenbergScality Dec 24, 2020
f708dea
ui: Start monitoring typing
JBWatenbergScality Dec 24, 2020
c269126
ui: Start node typing
JBWatenbergScality Dec 24, 2020
f46450a
ui: Add notification typings
JBWatenbergScality Dec 24, 2020
1420c1f
ui: Add pods reducer typing
JBWatenbergScality Dec 24, 2020
4f312b3
ui: Start salt reducer typing
JBWatenbergScality Dec 24, 2020
056857a
ui: Start solutions reducer typing
JBWatenbergScality Dec 24, 2020
07e99ff
ui: Add prometheus alert type
JBWatenbergScality Dec 24, 2020
1022311
ui: Add root state typing
JBWatenbergScality Dec 24, 2020
e2509d7
ui: Introduce useTypedSelector to enable simpler typed selection of r…
JBWatenbergScality Jan 8, 2021
48e97b3
ui: Introduce useTypedSelector in volume page
JBWatenbergScality Dec 24, 2020
3db0858
ui: Add a flow typed client generator
JBWatenbergScality Dec 29, 2020
29428b9
ui: Use redux-saga Effect in saga typings
JBWatenbergScality Dec 29, 2020
0ed1ba9
ui: Use generated metalk8s client and types
JBWatenbergScality Jan 8, 2021
28b33c3
ui: Prettier all the things
JBWatenbergScality Dec 29, 2020
dbc6f8b
ui: Add Namespaced scope support to meatlk8s client generator
JBWatenbergScality Dec 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui-metalk8s-client-generator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
23 changes: 23 additions & 0 deletions ui-metalk8s-client-generator/README.md
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 👍


### 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
```
8 changes: 8 additions & 0 deletions ui-metalk8s-client-generator/babel.config.js
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 ui-metalk8s-client-generator/package-lock.json

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions ui-metalk8s-client-generator/package.json
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"
}
}
309 changes: 309 additions & 0 deletions ui-metalk8s-client-generator/sample/GeneratedClient.js
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 };
}
}
Loading