Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
himadriganguly committed Dec 22, 2020
0 parents commit ca6635f
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 0 deletions.
75 changes: 75 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Contributing

k8s-jsonpath is a GPL GNU3 Licensed project and uses the standard GitHub pull requests process to review and accept contributions.

There are several areas of **k8s-jsonpath** that you could help the project to contribute. This is just in the initial state of the project and together **WE** can make it large.

- If you are a first-time contributor, please see [Steps to Contribute](#steps-to-contribute).
- If you would like to suggest features to be added to **k8s-jsonpath**, please go ahead and [create a new issue](/~https://github.com/himadriganguly/k8s-jsonpath/issues/new) describing your requirement and why you think that it will be need on this project.
- If you would like to make code contributions, all your commits should be signed with **Developer Certificate of Origin**. See [Sign your work](#sign-your-work).

## Steps to Contribute

**K8s is required.**

0. Clone the git repository and enter into the folder

```
git clone /~https://github.com/himadriganguly/k8s-jsonpath.git
cd k8s-jsonpath
```

1. Add jsonpath code in the **jsonpath.md** file on the respective folder, such as if it is related to **nodes** then the code will be under **nodes** folder.

2. The code should be in the following format

- Serial number should be there
- Description of the code and the K8s version
- Then the code under code block

**Example**

```
1. Get the name of all the nodes and their taint effect if any. <br/>**K8s** version used - **v1.19.0**
<details>
<summary>Click to expand!</summary>
`kubectl get nodes -o jsonpath='{range $.items[*]} {.metadata.name} {.spec.taints[*].effect}{"\n"}'`
</details>
```

3. Create a new branch `git checkout -b MY_BRANCH_NAME`

- Find an issue to work on or create a new issue. The issues are maintained at [k8s-jsonpath](/~https://github.com/himadriganguly/k8s-jsonpath/issues). You can pick up from a list of [good-first-issues](/~https://github.com/himadriganguly/k8s-jsonpath/good%20first%20issue).
- Claim your issue by commenting your intent to work on it to avoid duplication of efforts.
- Fork the repository on **GitHub**.
- Create a branch from where you want to base your work (usually master).
- Make your changes.
- Commit your changes by making sure the commit messages convey the need and notes about the commit.
- Push your changes to the branch in your fork of the repository.
- Submit a pull request to the original repository. See [Pull Request checklist](#pull-request-checklist)

## Pull Request Checklist

- Rebase to the current master branch before submitting your pull request.
- Commits should be as small as possible. Each commit should follow the checklist below:

- Commit header (first line) should convey what changed
- Commit body should include details such as why the changes are required and how the proposed changes
- **DCO** Signed

## Sign your work

We use the **Developer Certificate of Origin** (**DCO**) as an additional safeguard for the **k8s-jsonpath** project. This is a well established and widely used mechanism to assure that contributors have confirmed their right to license their contribution under the project's license. Please add a line to every git commit message:

```
Signed-off-by: Random Developer <random@developer.example.org>
```

Use your real name (sorry, no pseudonyms or anonymous contributions). The email id should match the email id provided in your **GitHub profile**.

If you set your `user.name` and `user.email` in **git config**, you can sign your commit automatically with `git commit -s`.

You can also use git [aliases](https://git-scm.com/book/tr/v2/Git-Basics-Git-Aliases) like `git config --global alias.ci 'commit -s'`. Now you can commit with `git ci` and the commit will be signed.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# K8s JsonPath

This repo contains sample **jsonpath** code related to **Kubernetes**.

# JSONPath Syntax

| JSONPath | Description |
| ------------------ | -------------------------------------------------------------------- |
| `$` | The root object/element |
| `@` | The current object/element |
| `.` or `[]` | Child member operator |
| `..` | Recursive descendant operator; JSONPath borrows this syntax from E4X |
| `*` | Wildcard matching all objects/elements regardless their names |
| `[]` | Subscript operator |
| `[,]` | Union operator for alternate names or array indices as a set |
| `[start:end:step]` | Array slice operator borrowed from ES4 / Python |
| `?()` | Applies a filter (script) expression via static evaluation |
| `()` | Script expression via static evaluation |

## About Us

K8s is maintained by:

<table>
<tr>
<td align="center"><a href="https://www.linkedin.com/in/hganguly/"><img src="https://avatars0.githubusercontent.com/u/5839433?s=88&u=6ed858dba3762eb0d929b48649b787ac9db112b7&v=4" width="100px;" alt="himadriganguly"/><br /><sub><b>Himadri Ganguly</b></sub></a><br /><a href="/~https://github.com/himadriganguly" title="Code">:octocat:</a> <a href="https://twitter.com/himadritech" title="Twitter">:bird:</a></td>
</tr>
</table>

## Contributing

Please see our [CONTRIBUTING.md](/CONTRIBUTING.md).

## LICENSE

k8s-jsonpath is GNU GPL3 licensed. See the LICENSE file for details.
33 changes: 33 additions & 0 deletions docs/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Pull Request Template

## Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

- [ ] Test A
- [ ] Test B

## Checklist:

- [x] I have performed a self-review of my own code.
- [x] Code belongs to me and I have full right to share.
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] Any dependent changes have been merged and published in downstream modules
- [ ] I have checked my code and corrected any misspellings
8 changes: 8 additions & 0 deletions nodes/jsonpath.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
1. Get the name of all the nodes and their taint effect if any. <br/>**K8s** version used - **v1.19.0**

<details>
<summary>Click to expand!</summary>

`kubectl get nodes -o jsonpath='{range $.items[*]} {.metadata.name} {.spec.taints[*].effect}{"\n"}'`

</details>
8 changes: 8 additions & 0 deletions pods/jsonpath.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
1. Get the IP of the pods with label app=nginx. <br/>K8s version used - **v1.19.0**

<details>
<summary>Click to expand!</summary>

`kubectl get pods -l app=nginx -o jsonpath='{range .items[*]}{.status.podIP}{"\n"}{end}'`

</details>

0 comments on commit ca6635f

Please sign in to comment.