You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project demonstrates how to script specific functionality using the Atlas SDK for Go. Code examples are included in the Atlas Architecture Center docs and available in a user-facing version of the project.
5
-
6
-
- Generated usage examples, which are included directly in the docs
7
-
- Within a
3
+
This project demonstrates how to script specific functionality using the Atlas
4
+
SDK for Go. Code examples are used in the Atlas Architecture Center docs, and
5
+
the project is made available in a user-facing repo.
8
6
9
7
## Project Structure
10
8
```text
11
9
atlas-sdk-go/
12
-
│── bluehawk/ # Bluehawk scripts to snip and copy code examples
13
-
│ ├── copy.sh
14
-
│ ├── snip.sh
15
10
│── cmd/ # Self-contained, runnable scripts
16
11
│ ├── get_logs/
17
12
│ ├── main.go
18
-
│ ├── get_metrics/
19
-
│ ├── dev/
20
-
│ ├── main.go
21
-
│ ├── prod/
22
-
│ ├── main.go
13
+
│ ├── get_metrics_disk/
14
+
│ ├── main.go
15
+
│ ├── get_metrics_process/
16
+
│ ├── main.go
23
17
│── config/ # Atlas configuration settings
24
18
│ ├── config.json
25
19
│── internal/ # Shared internal logic
26
-
│── auth/
27
-
├── auth.go
28
-
│ ├── config_loader.go
29
-
│ ├── secrets_loader.go
20
+
│ ├── auth/
21
+
| ├── client.go
22
+
│ ├── config/
23
+
| ├── json.go
24
+
| ├── secrets.go
25
+
| ├── loader.go
30
26
│── .env # Secrets file (excluded from Git)
31
27
│── go.mod
32
28
│── go.sum
33
-
│── README.md # Internal-only README (do not copy)
29
+
│── README.md # Internal-only README (do not copy with Copier Tool)
30
+
│── scripts/ # Internal-only Bluehawk scripts to snip and copy code examples
31
+
│ ├── bluehawk.sh
34
32
```
35
33
36
34
## Runnable Scripts
37
-
You can run individual scripts using `run_cmd.sh` and specifying the script's action (i.e. the parent directory for the `main.go` you want to run).
38
-
39
-
For example, to run `get_logs/main.go`:
35
+
You can run individual scripts from the terminal. For example, to run `get_logs/main.go`:
40
36
```shell
41
-
./run_cmd.sh get_logs
37
+
go run cmd/get_logs/main.go
42
38
```
43
39
44
40
## Set up
@@ -47,9 +43,11 @@ For example, to run `get_logs/main.go`:
47
43
48
44
- A [service account](https://www.mongodb.com/docs/atlas/api/service-accounts-overview/#std-label-service-accounts-overview) with access to your Atlas project
49
45
46
+
> **NOTE:** Some scripts require an M10+ cluster
47
+
50
48
### Set environment variables and config file
51
49
52
-
1. Set the following variable values, either as a `.env` file in the root directory or through your IDE
50
+
1. Set the following variable values, either as a `.env` file in the root directory or through your IDE:
@@ -67,54 +65,26 @@ For example, to run `get_logs/main.go`:
67
65
}
68
66
```
69
67
>**NOTE: Group ID == Project ID** Groups and projects are synonymous terms. Groups and projects are synonymous terms. Your group id is the same as your project id.
70
-
3.
68
+
69
+
## Write Tests
70
+
71
+
# TODO
71
72
72
73
## Generate Examples
73
74
74
-
### Generate code usage examples for docs
75
-
This project uses the following Bluehawk commands to generate the code examples:
75
+
This project uses Bluehawk to generate code examples from the source code.
76
76
77
-
- Usage examples forthe docs. These are generated using the `bluehawk snip` command based on the `snippet` markupin the code file.
78
-
```shell
79
-
./bluehawk/snip.sh
80
-
```
77
+
- Usage examples for the docs. These are generated using the `bluehawk snip`
78
+
command based on the `snippet` markup in the code file.
79
+
- Full project files for the user-facing project repo. These are generated using
80
+
the `bluehawk copy` command.
81
81
82
-
### Copy project files for user-facing project repo
82
+
Run the bluehawk script and enter either `snip` or `copy`. The selected command
83
+
runs with the defined defaults.
83
84
84
-
To copy the full project files for the user-facing artifact repo. These are generated using the `bluehawk copy` command, and any specified files are ignored.
85
85
```shell
86
-
./bluehawk/copy.sh
86
+
./scripts/bluehawk.sh
87
87
```
88
88
89
89
>**NOTE: "Copy" State** This project uses a state named "copy" specifically for any manipulations needed for code copied to the artifact repo.
90
90
91
-
## Copy Generated Examples to Other Repos
92
-
93
-
94
-
95
-
---
96
-
scratchpad:
97
-
- manually test against real infra
98
-
- pull the real data
99
-
100
-
PR Push > run on captured data
101
-
& scheduled job to validate? (or bump our sdk version along with the v release &
102
-
verify; fix any failing test)
103
-
- run the gh action locally
104
-
---
105
-
1. go sdk testing
106
-
2. atlas testing
107
-
108
-
we'd need to be notified when either change
109
-
we can test sdk automatically with the captured data
110
-
111
-
periodic manual validation step to test the infra side
112
-
- release cadence for sdk > gh
113
-
- release cadence for atlas/infra > server version? api update?
114
-
---
115
-
arch center docs versioning considerations
116
-
- how to keep arch center version in sync with code example version updates?
117
-
---
118
-
snippets in generated-examples > push to arch center repo to use in docs?
0 commit comments