Skip to content

Commit d532850

Browse files
committed
Merge remote-tracking branch 'origin/master' into CLOUDP-113344
2 parents e385bb8 + 87da562 commit d532850

File tree

987 files changed

+24227
-525
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

987 files changed

+24227
-525
lines changed

.github/workflows/docs.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout repository
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v3
1414
- name: Install Go
1515
uses: actions/setup-go@v2
1616
with:
1717
go-version: 1.17
18+
- name: Cache Dependencies
19+
uses: actions/cache@v2
20+
with:
21+
path: ~/go/pkg/mod
22+
key: Linux-go-1.17-${{ hashFiles('**/go.sum') }}
23+
restore-keys: |
24+
Linux-go-1.17-
1825
- name: Generate docs
1926
run: make gen-docs > /dev/null
2027
- name: Check for uncommited files

.github/workflows/go-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616
steps:
1717
- name: Checkout repository
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v3
1919
- name: Install Go
2020
uses: actions/setup-go@v2
2121
with:

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
name: lint
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414
- name: Install Go
1515
uses: actions/setup-go@v2
1616
with:

.github/workflows/mocks.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: Check Mock Generation
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
jobs:
9+
mocks:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v3
14+
- name: Install Go
15+
uses: actions/setup-go@v2
16+
with:
17+
go-version: 1.17
18+
- name: Cache Dependencies
19+
uses: actions/cache@v2
20+
with:
21+
path: ~/go/pkg/mod
22+
key: Linux-go-1.17-${{ hashFiles('**/go.sum') }}
23+
restore-keys: |
24+
Linux-go-1.17-
25+
- name: Intsall go-mock
26+
run: go install github.com/golang/mock/mockgen@latest
27+
- name: Generate mocks
28+
run: make gen-mocks
29+
- name: Check for uncommited files
30+
run: |
31+
export FILES=$(git ls-files -o -m --directory --exclude-standard --no-empty-directory)
32+
export LINES=$(echo "$FILES" | awk 'NF' | wc -l)
33+
if [ $LINES -ne 0 ]; then
34+
echo "Detected files that need to be committed:"
35+
echo "$FILES" | sed -e "s/^/ /"
36+
echo ""
37+
echo "Try running: make gen-mocks"
38+
exit 1
39+
fi

.github/workflows/security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
security:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v3
1212
- name: Run Snyk to check for vulnerabilities
1313
uses: snyk/actions/golang@master
1414
env:

.github/workflows/shellcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ jobs:
1010
name: shellcheck
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414
- name: Run ShellCheck
1515
uses: bewuethr/shellcheck-action@v2

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ gon_arm64.json
2828

2929
# We don't want to commit env variables
3030
*.env
31+
32+
# Tool generated files
33+
*.idea

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Flags are a way to modify the command, also may be called "options". Flags alway
111111

112112
#### Documentation Requirements
113113

114-
f you are adding a brand new command, or updating a command that has no doc annotations, please define the following doc structures for the command. For more information on all command structs, see [Cobra](https://pkg.go.dev/github.com/spf13/cobra#Command).
114+
If you are adding a brand new command, or updating a command that has no doc annotations, please define the following doc structures for the command. For more information on all command structs, see [Cobra](https://pkg.go.dev/github.com/spf13/cobra#Command).
115115
- Add `Use` - (Required) Shows the command and arguments if applicable. Will show up in 'help' output.
116116
- Add `Short` - (Required) Briefly describes the command. Will show up in 'help' output.
117117
- Add `Example` - (Required) Example of how to use the command. Will show up in 'help' output.

Makefile

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
# A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
22

3-
43
GOLANGCI_VERSION=v1.43.0
54
COVERAGE=coverage.out
65

7-
86
MCLI_SOURCE_FILES?=./cmd/mongocli
97
MCLI_BINARY_NAME=mongocli
10-
MCLI_VERSION?=$(shell git describe --always --tags)
8+
MCLI_VERSION?=$(shell git tag --list 'mongocli/v*' --sort=committerdate | tail -1 | cut -d "v" -f 2 | xargs -I % sh -c 'echo %-next' )
119
MCLI_GIT_SHA?=$(shell git rev-parse HEAD)
1210
MCLI_DESTINATION=./bin/$(MCLI_BINARY_NAME)
1311
MCLI_INSTALL_PATH="${GOPATH}/bin/$(MCLI_BINARY_NAME)"
1412
MCLI_E2E_BINARY?=../../bin/${MCLI_BINARY_NAME}
1513

16-
1714
ATLAS_SOURCE_FILES?=./cmd/atlas
1815
ATLAS_BINARY_NAME=atlas
16+
ATLAS_VERSION?=$(shell git tag --list 'atlascli/v*' --sort=committerdate | tail -1 | cut -d "v" -f 2 | xargs -I % sh -c 'echo %-next' )
1917
ATLAS_DESTINATION=./bin/$(ATLAS_BINARY_NAME)
2018
ATLAS_INSTALL_PATH="${GOPATH}/bin/$(ATLAS_BINARY_NAME)"
2119

22-
LINKER_FLAGS=-s -w -X github.com/mongodb/mongocli/internal/version.Version=${MCLI_VERSION} -X github.com/mongodb/mongocli/internal/version.GitCommit=${MCLI_GIT_SHA}
23-
MCLI_LINKER_FLAGS=${LINKER_FLAGS} -X github.com/mongodb/mongocli/internal/config.ToolName=$(MCLI_BINARY_NAME)
24-
ATLAS_LINKER_FLAGS=${LINKER_FLAGS} -X github.com/mongodb/mongocli/internal/config.ToolName=atlascli
20+
21+
ifeq ($(ATLAS_VERSION),) # use git describe if we don't have an atlascli tag
22+
ATLAS_VERSION=$(shell git describe --always --tags | cut -d "v" -f 2)
23+
endif
24+
25+
26+
LINKER_FLAGS=-s -w -X github.com/mongodb/mongocli/internal/version.GitCommit=${MCLI_GIT_SHA}
27+
MCLI_LINKER_FLAGS=${LINKER_FLAGS} -X github.com/mongodb/mongocli/internal/config.ToolName=$(MCLI_BINARY_NAME) -X github.com/mongodb/mongocli/internal/version.Version=${MCLI_VERSION}
28+
ATLAS_LINKER_FLAGS=${LINKER_FLAGS} -X github.com/mongodb/mongocli/internal/config.ToolName=atlascli -X github.com/mongodb/mongocli/internal/version.Version=${ATLAS_VERSION}
2529
ATLAS_E2E_BINARY?=../../bin/${ATLAS_BINARY_NAME}
2630

2731
DEBUG_FLAGS=all=-N -l
@@ -91,9 +95,15 @@ gen-mocks: ## Generate mocks
9195
go generate ./internal...
9296

9397
.PHONY: gen-docs
94-
gen-docs: ## Generate docs for commands
95-
@echo "==> Generating docs"
96-
go run ./internal/docs/main.go
98+
gen-docs: gen-docs-mongocli gen-docs-atlascli ## Generate docs for commands
99+
100+
gen-docs-mongocli: ## Generate docs for mongocli commands
101+
@echo "==> Generating docs for mongocli"
102+
go run ./internal/docs/mongocli/main.go
103+
104+
gen-docs-atlascli: ## Generate docs for atlascli commands
105+
@echo "==> Generating docs for atlascli"
106+
go run ./internal/docs/atlascli/main.go
97107

98108
.PHONY: build
99109
build: build-mongocli ## Generate a binary for mongocli

README.md

Lines changed: 5 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,18 @@
1-
<p align="center">
2-
<img width="80" height="80" src="https://raw.github.com/mongodb/mongocli/master/mongocli.svg" alt="MongoDB CLI Logo">
3-
</p>
4-
1+
## MongoDB Atlas CLI
52

63
![GO tests](https://github.com/mongodb/mongocli/workflows/GO%20tests/badge.svg)
74
![golangci-lint](https://github.com/mongodb/mongocli/workflows/golangci-lint/badge.svg)
85

9-
The MongoDB CLI is a modern command line interface that enables you to manage your MongoDB services from the terminal.
10-
11-
![mongocli-atlas-quickstart](https://user-images.githubusercontent.com/461027/126986233-0dd5c82a-2c75-4887-ab66-eb018c59e093.gif)
6+
The MongoDB Atlas CLI repository contains the following modern command line interfaces:
7+
- [Atlas CLI](atlascli.md)
8+
- [MongoDB CLI](mongocli.md)
129

1310
Use simple, one-line commands to interact with MongoDB Atlas, Cloud Manager, or Ops Manager, and to automate management tasks for your deployments.
1411

15-
## Documentation
16-
17-
See the [official docs](https://docs.mongodb.com/mongocli/stable/) for instructions on how to
18-
install, set up, and reference available commands.
19-
20-
## Installing
21-
22-
### Homebrew on macOS
23-
24-
```bash
25-
brew install mongocli
26-
```
27-
28-
### Pre-built Binaries
29-
30-
Download the appropriate version for your platform from [mongocli releases](https://github.com/mongodb/mongocli/releases).
31-
Once downloaded, the binary can be run from anywhere.
32-
You don't need to install it into a global location.
33-
This works well for shared hosts and other systems where you don't have a privileged account.
34-
35-
Ideally, you should place this binary somewhere in your `PATH` for easy use.
36-
`/usr/local/bin` is the most probable location.
37-
38-
### Build From Source
39-
40-
#### Prerequisite Tools
41-
- [Git](https://git-scm.com/)
42-
- [Go (at least Go 1.17)](https://golang.org/dl/)
43-
44-
#### Fetch Source
45-
46-
```bash
47-
git clone https://github.com/mongodb/mongocli.git
48-
cd mongocli
49-
```
50-
51-
#### Build
52-
53-
To build `mongocli`, run:
54-
55-
```bash
56-
make build
57-
```
58-
59-
The resulting `mongocli` binary is placed in `./bin`.
60-
61-
#### Install
62-
63-
To install the `mongocli` binary in `$GOPATH/bin`, run:
64-
65-
```bash
66-
make install
67-
```
68-
69-
**Note:** running `make build` is not needed when running `make install`.
70-
71-
## Usage
72-
73-
Run `mongocli help` for a list of available commands
74-
or check our [online documentation](https://docs.mongodb.com/mongocli/master/) for more details.
75-
76-
### Getting API Keys
77-
78-
To use `mongocli` you'll need to get API keys, to get them follow the documentation
79-
appropriate for the service you're using,
80-
[Atlas](https://docs.atlas.mongodb.com/configure-api-access/),
81-
[Ops Manager](https://docs.opsmanager.mongodb.com/current/tutorial/configure-public-api-access/),
82-
or [Cloud Manager](https://docs.cloudmanager.mongodb.com/tutorial/manage-programmatic-api-keys/)
83-
84-
### Configuring `mongocli`
85-
86-
Run `mongocli config` to set up your credentials,
87-
this is optional, you can use [env variables](https://docs.mongodb.com/mongocli/stable/configure/environment-variables/) instead.
88-
89-
If you're working with Atlas Gov, Ops Manager or Cloud Manager you need to define the service using `--service`
90-
91-
For Atlas Gov, `mongocli config --service cloudgov`.
92-
93-
For Ops Manager, `mongocli config --service ops-manager`.
94-
95-
For Cloud Manager, `mongocli config --service cloud-manager`.
96-
97-
### Shell Completions
98-
99-
If you install via [homebrew](#hombrew-on-macos) no additional actions are needed.
100-
101-
To get specific instructions for your preferred shell run:
102-
103-
```bash
104-
mongocli completion <bash|zsh|fish|powershell> --help
105-
```
106-
10712
## Contributing
10813

10914
See our [CONTRIBUTING.md](CONTRIBUTING.md) guide.
11015

11116
## License
11217

113-
MongoDB CLI is released under the Apache 2.0 license. See [LICENSE](LICENSE)
18+
MongoDB CLI and Atlas CLI are released under the Apache 2.0 license. See [LICENSE](LICENSE)

atlascli.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Atlas CLI (Pre-Release)
2+
3+
The MongoDB Atlas CLI is a modern command line interface that enables you to manage MongoDB Atlas from the terminal.
4+
5+
![atlascli-atlas-quickstart](https://user-images.githubusercontent.com/5663078/156184669-57c8ddce-6f0a-4e84-9311-2d996cb27942.gif)
6+
7+
## Installing
8+
9+
Atlas CLI is currently in the pre-release phase. Do not use it in a production environment.
10+
11+
### Pre-built Binaries
12+
13+
Download the appropriate version for your platform from [Atlas CLI releases](https://github.com/mongodb/mongocli/releases).
14+
After you download the library, you can run it from anywhere and don't need to install it into a global location.
15+
This works well for shared hosts and other systems where you don't have a privileged account.
16+
17+
You can place this binary somewhere in your `PATH` for ease of use.
18+
`/usr/local/bin` is the most probable location.
19+
20+
### Build From Source
21+
22+
#### Fetch Source
23+
24+
```bash
25+
git clone https://github.com/mongodb/mongocli.git
26+
cd mongocli
27+
```
28+
29+
#### Build
30+
31+
To build `atlascli`, run:
32+
33+
```bash
34+
make build-atlascli
35+
```
36+
37+
The resulting `atlas` binary is placed in `./bin`.
38+
39+
#### Install
40+
41+
To install the `atlas` binary in `$GOPATH/bin`, run:
42+
43+
```bash
44+
make install-atlascli
45+
```
46+
47+
**Note:** running `make build-atlascli` is not needed when running `make install-atlascli`.
48+
49+
50+
## Usage
51+
52+
To get a list of available commands, run `atlas help`
53+
or check our documentation for more details.
54+
55+
### Configuring Atlas CLI
56+
To use `atlascli`, open your terminal, run `atlas auth login`, and follow the prompted steps.
57+
58+
### Shell Completions
59+
60+
If you install via [homebrew](#hombrew-on-macos) no additional actions are needed.
61+
62+
To get specific instructions for your preferred shell, run:
63+
64+
```bash
65+
atlas completion <bash|zsh|fish|powershell> --help
66+
```

0 commit comments

Comments
 (0)