An open API service indexing awesome lists of open source software.

https://github.com/huhouhua/glctl

GitLab CLI tool, designed with a declarative API ๐Ÿš€๐Ÿš€
https://github.com/huhouhua/glctl

cli command-line declarative devops gitlab gitlab-api gitlab-cli gitlab-ctl

Last synced: about 1 month ago
JSON representation

GitLab CLI tool, designed with a declarative API ๐Ÿš€๐Ÿš€

Awesome Lists containing this project

README

          


GitLab CLI


glctl is a powerful GitLab command line tool. It provides a declarative API to manage GitLab resources, making it easier for you to perform common GitLab operations from the terminal


![Workflow ci](https://github.com/huhouhua/glctl/actions/workflows/glctl.yml/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/github.com/huhouhua/glctl)](https://goreportcard.com/report/github.com/huhouhua/glctl)
[![release](https://img.shields.io/github/release-pre/huhouhua/glctl.svg)](https://github.com/huhouhua/glctl/releases)
[![Docker Pulls](https://img.shields.io/docker/pulls/huhouhua/glctl.svg?maxAge=604800)](https://hub.docker.com/r/huhouhua/glctl/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
[![GoDoc](https://godoc.org/github.com/huhouhua/glctl?status.svg)](https://godoc.org/github.com/huhouhua/glctl)
[![Test Coverage](https://codecov.io/gh/huhouhua/glctl/branch/main/graph/badge.svg)](https://codecov.io/gh/huhouhua/glctl)


Installation โ˜
Features โ˜
Quick-Start โ˜
Examples โ˜
License

```
Using environment variables for authorization

* Basic Authentication (if using a username and password)
- GITLAB_USERNAME
- GITLAB_PASSWORD
- GITLAB_URL

* Private Token (if using a private token)
- GITLAB_PRIVATE_TOKEN
- GITLAB_URL

* OAuth Token (if using an oauth token)
- GITLAB_OAUTH_TOKEN
- GITLAB_URL

Basic Commands:
get Display one or many resources
edit Edit a resource on the server
delete Delete resources by file names, stdin, resources and names, or by resources
create Create a resource from a file or from stdin

Authorization Commands:
login Login to gitlab
logout logout current gitlab

Advanced Commands:
replace Replace a repository file by file name or stdin.

all formats are accepted. If replacing an existing repository file, the
complete repository file spec must be provided. This can be obtained by

$ glctl get files PROJECT --path=my.yml --ref=BRANCH --raw

Settings Commands:
completion Output shell completion code for the specified shell (bash, zsh,
fish, or powershell)

Other Commands:
version Print the client and server version information

```

## ๐Ÿค˜ย  Features
- Manage GitLab projects, issues, merge requests, and more
- Authenticate and manage GitLab sessions
- Create, get, edit, and delete GitLab resources
- Operate on project branch files
- Shell completion support

## ๐Ÿณย  Docker Container
### Release
```
docker pull huhouhua/glctl
docker run \
-e GITLAB_URL=https://gitlab.example.com \
-e GITLAB_PRIVATE_TOKEN=305e146a4aa23fb4021a4f162102251e85f651a058a34fb2c27d633617cf8877 \
huhouhua/glctl get projects
```

๐Ÿ”” **Note:** Above examples use private token authentication by default. See [environment](#-authentication) for details. To run `glctl` against other compatible servers, start the container this way:

```
docker run -it --entrypoint=/bin/sh huhouhua/glctl
```

### ๐ŸฆŠ GitLab CI
When using the Docker container in GitLab CI, you must [set the entrypoint to an empty string](https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#override-the-entrypoint-of-an-image).

```
deploy:
image:
name: huhouhua/glctl
entrypoint: ['']
stage: deploy
before_script:
- export GITLAB_URL=https://gitlab.example.com
- export GITLAB_PRIVATE_TOKEN=305e146a4aa23fb4021a4f162102251e85f651a058a34fb2c27d633617cf8877
script:
- glctl get projects
```

## ๐Ÿ“ฆย  Installation

### ๐Ÿ“ From Binary

Download the appropriate version for your platform from the [releases page](https://github.com/huhouhua/glctl/releases).

### ๐Ÿ› ๏ธ From Source
- compile glctl and place it in _output/
```bash
git clone https://github.com/huhouhua/glctl.git
cd glctl
make build
```

## ๐Ÿš€ย  Quick Start

### ๐Ÿ“„ย Usage
```bash
glctl [flags]
```

### ๐Ÿ” Authentication

- start interactive login
```bash
glctl login https://gitlab.example.com
```
- start interactive Login by username
```bash
glctl login https://gitlab.example.com --username myname
```

- Login by specifying username and password
```bash
glctl login https://gitlab.example.com --username myname --password mypassword
```

- authenticate with private token and hostname
```bash
export GITLAB_URL=https://gitlab.example.com
export GITLAB_PRIVATE_TOKEN=305e146a4aa23fb4021a4f162102251e85f651a058a34fb2c27d633617cf8877
```

- authenticate with oauth token and hostname
```bash
export GITLAB_URL=https://gitlab.example.com
export GITLAB_OAUTH_TOKEN=aefb8b4e0895799aa60cf50eb8bcd9ae1fecf08fb6cc8249238219067e5aa926
```

- Logging in using environment variables (Not recommended for shared environments)
```bash
export GITLAB_URL=https://gitlab.example.com
export GITLAB_USERNAME=myname
export GITLAB_PASSWORD=mypassword
```

## ๐Ÿฅ™ย  Examples
- List your groups
```bash
glctl get groups
```

- List your projects:
```bash
glctl get projects
```

- List branches of group1/project1
```bash
glctl get branchs group1/project1
```

- Create a develop branch from the master branch in the group1/project1 project
```bash
glctl create branch develop --project=group1/project1 --ref=master
```

### ๐Ÿฅช Available Commands

- `login` - Authenticate with GitLab
- `logout` - Log out from GitLab
- `create` - Create new GitLab resources (projects, issues, merge requests, etc.)
- `get` - Get information about GitLab resources
- `edit` - Edit existing GitLab resources
- `delete` - Delete GitLab resources
- `replace` - Replace existing GitLab resources
- `version` - Display version information
- `completion` - Generate shell completion scripts

### ๐Ÿ—’๏ธย Logged in user authorization file
Files are stored in `$HOME/.glctl.yaml` example:
```yaml
access_token: 305e146a4aa23fb4021a4f162102251e85f651a058a34fb2c27d633617cf8877
created_at: 1.748339041e+09
host_url: https://gitlab.example.com
refresh_token: aefb8b4e0895799aa60cf50eb8bcd9ae1fecf08fb6cc8249238219067e5aa926
scope: api
token_type: Bearer
user_name: root
```

## ๐Ÿง ย TODOs

- This cli tool is still in the development stage, and most of the resources are not completed. Everyone contribute is very much needed. ๐Ÿ™‹โ€โ™‚๏ธ
- Declarative resources are still in the design stage

## ๐Ÿคย Issues

If you have an issue: report it on the [issue tracker](https://github.com/huhouhua/glctl/issues)

## ๐Ÿ‘คย Author

Kevin Berger ()

## ๐Ÿง‘โ€๐Ÿ’ปย Contributing

Contributions are always welcome. For more information, check out the [contributing guide](CONTRIBUTING.md)

## ๐Ÿ“˜ย  License

Licensed under the Apache License 2.0. See [LICENSE](LICENSE) for details.