Skip to content

Commit

Permalink
Merge pull request #459 from sarub0b0/v1.5.0
Browse files Browse the repository at this point in the history
Release version 1.5.0
  • Loading branch information
sarub0b0 authored Jan 13, 2024
2 parents 7bb3548 + 7891862 commit 634af75
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kubetui"
version = "1.4.2"
version = "1.5.0"
authors = ["kosay <[email protected]>"]
edition = "2021"
license = "MIT"
Expand Down
119 changes: 117 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ It provides an easy-to-use interface for developers and operators to access impo
- [Installation](#installation)
- [Features](#features)
- [Usage](#usage)
- [Log Query](#log-query)
- [Usage Example](#usage-example)
- [Supported Queries](#supported-queries)
- [Query String Escaping](#query-string-escaping)
- [Key Bindings](#key-bindings)
- [General](#general)
- [Key Map](#key-map)
Expand All @@ -26,12 +30,12 @@ It provides an easy-to-use interface for developers and operators to access impo

</details>

![Demo](./assets/demo.gif)
![Demo](./assets/demo.webp)

<details>
<summary>Demo slow version</summary>

![Demo slow version](./assets/demo-slow.gif)
![Demo slow version](./assets/demo-slow.webp)

</details>

Expand Down Expand Up @@ -100,6 +104,116 @@ Options:
-s, --split-mode <v|h> Window split mode [possible values: v, h, vertical, horizontal]
```

## Log Query

The Log Query feature empowers you to retrieve logs from multiple Pods and their containers. Using regular expressions, selectors, and specified resources, you can precisely define the log retrieval targets. This functionality also allows you to filter logs using regular expressions, providing a powerful and flexible log querying experience.

### Usage Example

```
pod:app container:nginx log:401
```

When entering `?` or `help` in the log query form, the help popup will be displayed.

### Supported Queries

| Query | Alias | Description |
| ------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------- |
| pod:\<regex> | pods, po, p | Include Pods that match the regular expression in log retrieval target. |
| !pod:\<regex> | !pods, !po, !p | Exclude Pods that match the regular expression from log retrieval target. Can be defined multiple times. |
| container:\<regex> | containers, co, c | Include containers that match the regular expression in log retrieval target. |
| !container:\<regex> | !containers, !co, !c | Exclude containers that match the regular expression from log retrieval target. Can be defined multiple times. |
| log:\<regex> | logs, lo, l | Retrieve logs that match the regular expression. Can be defined multiple times. |
| !log:\<regex> | !logs, !lo, !l | Exclude logs that match the regular expression. Can be defined multiple times. |
| label:\<selector> | labels | Include Pods with labels matching the selector in log retrieval target. Cannot be specified with resource. |
| field:\<selector> | fields | Include Pods with fields matching the selector in log retrieval target. |
| \<resource>/\<name> | | Include Pods belonging to the specified resource in log retrieval target. Cannot be specified with label. |

Supported resources:

| Resource | Alias |
| ----------- | ------------------- |
| pod | po, pods |
| replicaset | rs, replicasets |
| deployment | deploy, deployments |
| statefulset | sts, statefulsets |
| daemonset | ds, daemonsets |
| job | jobs |
| service | svc, services |

### Query String Escaping

When including spaces in queries such as `<regex>` or `<selector>`, enclose the string with `"` or `'`. For example:

```
pod:"a b"
label:"environment in (production, qa)"
```

If you use `"`, `'`, or `\` within the quoted string, escape them with `\`. For example:

```
pod:"a\\b"
```

<details>
<summary>Query Syntax</summary>

```
**Lexer and Parser**
LOG_QUERIES = QUERY ( " "+ QUERY )*
QUERY = POD
| EXCLUDE_POD
| CONTAINER
| EXCLUDE_CONTAINER
| LOG
| EXCLUDE_LOG
| LABEL
| FIELD
| SPECIFIED_RESOURCE
POD = ( "pods" | "pod" | "po" | "p" ) ":" REGEX
EXCLUDE_POD = "!" POD
CONTAINER = ( "containers" | "container" | "co" | "c" ) ":" REGEX
EXCLUDE_CONTAINER = "!" CONTAINER
LOG = ( "logs" | "log" | "lo" | "l" ) ":" REGEX
EXCLUDE_LOG = "!" LOG
REGEX = QUOTED_STRING | UNQUOTED_STRING
LABEL = ( "labels" | "label" ) ":" SELECTOR
FIELD = ( "fields" | "field" ) ":" SELECTOR
SELECTOR = QUOTED_STRING | UNQUOTED_STRING
SPECIFIED_RESOURCE = RESOURCE "/" NAME
RESOURCE = ( "pods" | "pod" | "po" )
| ( "replicasets" | "replicaset" | "rs" )
| ( "deployments" | "deployment" | "deploy" )
| ( "statefulsets" | "statefulset" | "sts" )
| ( "daemonsets" | "daemonset" | "ds" )
| ( "services" | "service" | "svc" )
| ( "jobs" | "job" )
NAME = ALPHANUMERIC ( ALPHANUMERIC | "-" | "." )* ALPHANUMERIC
UNQUOTED_STRING = ~['" \t\r\n] ( ~[ \t\r\n] )* // without spaces
QUOTED_STRING = "\"" ESCAPED_STRING "\"" | "'" ESCAPED_STRING "'"
ESCAPED_STRING = ( ESCAPED_CHAR | ~[\"'] )\*
ESCAPED_CHAR = "\\" | "\"" | "\'"
```

</details>

## Key Bindings

### General
Expand All @@ -111,6 +225,7 @@ Options:
| <kbd>n</kbd> | Open the popup for selecting the namespace |
| <kbd>N</kbd> | Open the popup for selecting multiple namespaces |
| <kbd>c</kbd> | Open the popup for selecting the context |
| <kbd>y</kbd> | Open the popup for yaml |
| <kbd>Tab</kbd>, <kbd>Shift+Tab</kbd> | Change the focus of the view within the active tab |
| <kbd>number</kbd> | Switch to the tab (number: 1~6) |
| <kbd>ESC</kbd> | Close the window or terminate the app (when the popup is not open) |
Expand Down
Binary file removed assets/demo-slow.gif
Binary file not shown.
Binary file added assets/demo-slow.webp
Binary file not shown.
Binary file removed assets/demo.gif
Binary file not shown.
Binary file added assets/demo.webp
Binary file not shown.

0 comments on commit 634af75

Please sign in to comment.