Skip to content

Commit

Permalink
Remove old jq scripts
Browse files Browse the repository at this point in the history
Signed-off-by: kazk <[email protected]>
  • Loading branch information
kazk committed Oct 27, 2021
1 parent 48621f3 commit 98de653
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 3,904 deletions.
121 changes: 0 additions & 121 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,124 +57,3 @@ We should be able to find the following:
- Namespaced if any possible path contains `/namespaces/{namespace}/`
- May also have paths for all namespaces for some verbs (e.g., `list` all pods)
- Subresource if path contains `/{name}/` (`/` after `{name}`)

### Transforming

Transform `swagger.json` to something easier to explore.

#### Like APIResourceList

```bash
cat swagger.json \
| jq -f list-resources.jq \
> api-resources.json
```

```bash
cat swagger.json | jq -f list-resources.jq | jq '.[0]'
```

```json
{
"apiGroupVersion": "admissionregistration.k8s.io/v1",
"resources": [
{
"name": "mutatingwebhookconfigurations",
"namespaced": false,
"apiGroupVersion": "admissionregistration.k8s.io/v1",
"group": "admissionregistration.k8s.io",
"version": "v1",
"kind": "MutatingWebhookConfiguration",
"verbs": [
"create",
"delete",
"deletecollection",
"get",
"list",
"patch",
"update"
]
},
{
"name": "validatingwebhookconfigurations",
"namespaced": false,
"apiGroupVersion": "admissionregistration.k8s.io/v1",
"group": "admissionregistration.k8s.io",
"version": "v1",
"kind": "ValidatingWebhookConfiguration",
"verbs": [
"create",
"delete",
"deletecollection",
"get",
"list",
"patch",
"update"
]
}
]
}
```

#### Paths

```typescript
type ResourcePath = {
// Request path.
path: string;
// `x-kubernetes-action` or `method`.
verb: string;
// Group and version of API. Can be different from `group` and `version` for subresources.
apiGroupVersion: string;
// GVK
group: string;
version: string;
kind: string;
// True if the path contains `/namespaces/{namespace}/`
namespaced: boolean;
// True if the path contains a segment after `{name}`.
subresource: boolean;
// MIME types of supported content types. Comma separated.
consumes: string;
// MIME types of supported responses. Comma separated.
produces: string;
// Plural name. Includes subresources like APIResourceList.
name: string;
};
```

```bash
cat swagger.json | jq -f list-paths.jq
```

```bash
cat swagger.json \
| jq -f list-paths.jq \
| jq 'map(select(.kind == "Pod" and .verb == "get" and .subresource == false))'
```

```json
[
{
"path": "/api/v1/namespaces/{namespace}/pods/{name}",
"verb": "get",
"apiGroupVersion": "v1",
"group": "",
"version": "v1",
"kind": "Pod",
"namespaced": true,
"subresource": false,
"consumes": "*/*",
"produces": "application/json, application/yaml, application/vnd.kubernetes.protobuf",
"name": "pods"
}
]
```

Group by `name`:

```bash
cat swagger.json \
| jq -f list-paths.jq \
| jq 'group_by(.name)'
```
Loading

0 comments on commit 98de653

Please sign in to comment.