Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduce sloctl docs auto generation #179

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,20 @@ check/format:
$(call _print_step,Checking if files are formatted)
./scripts/check-formatting.sh

.PHONY: generate generate/code
.PHONY: generate generate/code generate/docs
## Auto generate files.
generate: generate/code
generate: generate/code generate/docs

## Generate Golang code.
generate/code:
echo "Generating Go code..."
go generate ./...

## Generate sloctl docs.
generate/docs:
echo "Generating sloctl docs..."
go run internal/cmd/docgen/main.go

.PHONY: format format/go format/cspell
## Format files.
format: format/go format/cspell
Expand Down
11 changes: 9 additions & 2 deletions cmd/sloctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@
// example configuration file can be found in this repository samples/config.toml.
package main

import "github.com/nobl9/sloctl/internal"
import (
"os"

"github.com/nobl9/sloctl/internal"
)

func main() {
internal.Execute()
cmd := internal.NewRootCmd()
if err := cmd.Execute(); err != nil {
os.Exit(1)
}
}
32 changes: 32 additions & 0 deletions docs/sloctl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## sloctl

Create, get and delete SLO definitions from command line easily.

### Synopsis

All available commands for execution are listed below.
Use this tool to work with definitions of SLO in YAML files.
For every command more detailed help is available.

### Options

```
-A, --all-projects Displays the objects from all of the projects.
--config string Config file path.
-c, --context string Overrides the default context for the duration of the selected command.
-h, --help Help for sloctl.
--no-config-file Don't create config.toml, operate only on env variables.
-p, --project string Overrides the default project from active Delete for the duration of the selected command.
```

### SEE ALSO

* [sloctl apply](sloctl_apply.md) - Apply object definition in YAML or JSON format
* [sloctl aws-iam-ids](sloctl_aws-iam-ids.md) - Returns IAM IDs used in AWS integrations
* [sloctl config](sloctl_config.md) - Configuration management
* [sloctl delete](sloctl_delete.md) - Delete object definition by name or definition file
* [sloctl get](sloctl_get.md) - Display one or more than one resource
* [sloctl replay](sloctl_replay.md) - Retrieve historical SLI data and recalculate their SLO error budgets.
* [sloctl version](sloctl_version.md) - Print the sloctl version

###### Auto generated by spf13/cobra on 2-Aug-2024
70 changes: 70 additions & 0 deletions docs/sloctl_apply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
## sloctl apply

Apply object definition in YAML or JSON format

### Synopsis

The apply command commits the changes by sending the updates to the application.
Sloctl supports glob patterns when using '-f' flag, it uses the standard Go glob patterns grammar and extends it with support of '**' for recursive reading of files and directories.
The standard Go grammar can be found here: https://pkg.go.dev/path/filepath#Match.
Only files with extensions: '.yaml', '.yml' and '.json' are processed when using glob patterns.
Additionally, before processing the file contents, sloctl checks if it contains Nobl9 API version with the following regex: '"?apiVersion"?\s*:\s*"?n9'.
Remember that glob patterns must be quoted to prevent the shell from evaluating them.


```
sloctl apply [flags]
```

### Examples

```
# Apply the configuration from slo.yaml.
sloctl apply -f ./slo.yaml

# Apply resources from multiple different sources at once.
sloctl apply -f ./slo.yaml -f test/config.yaml -f https://nobl9.com/slo.yaml

# Apply the YAML or JSON passed directly into stdin.
cat slo.yaml | sloctl apply -f -

# Apply the configuration from slo.yaml and set project if it is not defined in file.
sloctl apply -f ./slo.yaml -p slo

# Apply the configurations from all the files located at cwd recursively.
sloctl apply -f '**'

# Apply the configurations from files with 'annotations' name within the whole directory tree.
sloctl apply -f '**/annotations*'

# Apply the SLO(s) from slo.yaml and import its/their data from 2023-03-02T15:00:00Z until now.
sloctl apply -f ./slo.yaml --replay --from=2023-03-02T15:00:00Z

```

### Options

```
--dry-run Submit server-side request without persisting the configured resources.
-f, --file stringArray File path, glob pattern or a URL to the configuration in YAML or JSON format. This option can be used multiple times.
--from time Sets the start of Replay time window.
-h, --help help for apply
--replay Run Replay for the applied SLOs. If Replay fails, the applied changes are not rolled back.
-y, --yes Auto confirm files threshold prompt. Threshold can be changed or disabled in config.toml or via env variables.
```

### Options inherited from parent commands

```
-A, --all-projects Displays the objects from all of the projects.
--config string Config file path.
-c, --context string Overrides the default context for the duration of the selected command.
--no-config-file Don't create config.toml, operate only on env variables.
-p, --project string Overrides the default project from active Delete for the duration of the selected command.
```

### SEE ALSO

* [sloctl](sloctl.md) - Create, get and delete SLO definitions from command line easily.

###### Auto generated by spf13/cobra on 2-Aug-2024
27 changes: 27 additions & 0 deletions docs/sloctl_aws-iam-ids.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## sloctl aws-iam-ids

Returns IAM IDs used in AWS integrations

### Options

```
-h, --help help for aws-iam-ids
```

### Options inherited from parent commands

```
-A, --all-projects Displays the objects from all of the projects.
--config string Config file path.
-c, --context string Overrides the default context for the duration of the selected command.
--no-config-file Don't create config.toml, operate only on env variables.
-p, --project string Overrides the default project from active Delete for the duration of the selected command.
```

### SEE ALSO

* [sloctl](sloctl.md) - Create, get and delete SLO definitions from command line easily.
* [sloctl aws-iam-ids dataexport](sloctl_aws-iam-ids_dataexport.md) - Returns AWS external ID, which will be used by Nobl9 to assume the IAM role when performing data export
* [sloctl aws-iam-ids direct](sloctl_aws-iam-ids_direct.md) - Returns external ID and AWS account ID for given direct name

###### Auto generated by spf13/cobra on 2-Aug-2024
29 changes: 29 additions & 0 deletions docs/sloctl_aws-iam-ids_dataexport.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## sloctl aws-iam-ids dataexport

Returns AWS external ID, which will be used by Nobl9 to assume the IAM role when performing data export

```
sloctl aws-iam-ids dataexport [flags]
```

### Options

```
-h, --help help for dataexport
```

### Options inherited from parent commands

```
-A, --all-projects Displays the objects from all of the projects.
--config string Config file path.
-c, --context string Overrides the default context for the duration of the selected command.
--no-config-file Don't create config.toml, operate only on env variables.
-p, --project string Overrides the default project from active Delete for the duration of the selected command.
```

### SEE ALSO

* [sloctl aws-iam-ids](sloctl_aws-iam-ids.md) - Returns IAM IDs used in AWS integrations

###### Auto generated by spf13/cobra on 2-Aug-2024
37 changes: 37 additions & 0 deletions docs/sloctl_aws-iam-ids_direct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## sloctl aws-iam-ids direct

Returns external ID and AWS account ID for given direct name

### Synopsis

Returns external ID and AWS account ID that can be used to create cross-account IAM roles.
More details available at: https://docs.nobl9.com/Sources/Amazon_CloudWatch/#cross-account-iam-roles-new.

```
sloctl aws-iam-ids direct [direct-name] [flags]
```

### Options

```
--field-separator string Field Separator for CSV. (default ",")
-h, --help help for direct
-o, --output string Output format: one of yaml|json|csv. (default "yaml")
--record-separator string Record Separator for CSV. (default "\n")
```

### Options inherited from parent commands

```
-A, --all-projects Displays the objects from all of the projects.
--config string Config file path.
-c, --context string Overrides the default context for the duration of the selected command.
--no-config-file Don't create config.toml, operate only on env variables.
-p, --project string Overrides the default project from active Delete for the duration of the selected command.
```

### SEE ALSO

* [sloctl aws-iam-ids](sloctl_aws-iam-ids.md) - Returns IAM IDs used in AWS integrations

###### Auto generated by spf13/cobra on 2-Aug-2024
35 changes: 35 additions & 0 deletions docs/sloctl_config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## sloctl config

Configuration management

### Synopsis

Manage configurations stored in configuration file.

### Options

```
-h, --help help for config
```

### Options inherited from parent commands

```
-A, --all-projects Displays the objects from all of the projects.
--config string Config file path.
-c, --context string Overrides the default context for the duration of the selected command.
--no-config-file Don't create config.toml, operate only on env variables.
-p, --project string Overrides the default project from active Delete for the duration of the selected command.
```

### SEE ALSO

* [sloctl](sloctl.md) - Create, get and delete SLO definitions from command line easily.
* [sloctl config add-context](sloctl_config_add-context.md) - Add new sloctl configuration context
* [sloctl config current-context](sloctl_config_current-context.md) - Display current context
* [sloctl config delete-context](sloctl_config_delete-context.md) - Delete chosen context
* [sloctl config get-contexts](sloctl_config_get-contexts.md) - Display all available contexts
* [sloctl config rename-context](sloctl_config_rename-context.md) - Rename chosen context
* [sloctl config use-context](sloctl_config_use-context.md) - Set the default context

###### Auto generated by spf13/cobra on 2-Aug-2024
33 changes: 33 additions & 0 deletions docs/sloctl_config_add-context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## sloctl config add-context

Add new sloctl configuration context

### Synopsis

Add new sloctl configuration context, an interactive command which collects parameters in wizard mode.

```
sloctl config add-context [flags]
```

### Options

```
-h, --help help for add-context
```

### Options inherited from parent commands

```
-A, --all-projects Displays the objects from all of the projects.
--config string Config file path.
-c, --context string Overrides the default context for the duration of the selected command.
--no-config-file Don't create config.toml, operate only on env variables.
-p, --project string Overrides the default project from active Delete for the duration of the selected command.
```

### SEE ALSO

* [sloctl config](sloctl_config.md) - Configuration management

###### Auto generated by spf13/cobra on 2-Aug-2024
34 changes: 34 additions & 0 deletions docs/sloctl_config_current-context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## sloctl config current-context

Display current context

### Synopsis

Display configuration for the current context set in the configuration file.

```
sloctl config current-context [flags]
```

### Options

```
-h, --help help for current-context
-v, --verbose Display verbose information about configuration
```

### Options inherited from parent commands

```
-A, --all-projects Displays the objects from all of the projects.
--config string Config file path.
-c, --context string Overrides the default context for the duration of the selected command.
--no-config-file Don't create config.toml, operate only on env variables.
-p, --project string Overrides the default project from active Delete for the duration of the selected command.
```

### SEE ALSO

* [sloctl config](sloctl_config.md) - Configuration management

###### Auto generated by spf13/cobra on 2-Aug-2024
39 changes: 39 additions & 0 deletions docs/sloctl_config_delete-context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## sloctl config delete-context

Delete chosen context

### Synopsis

Delete one of the contexts in the configuration file.

```
sloctl config delete-context [flags]
```

### Examples

```
sloctl config delete-context [context-name]
```

### Options

```
-h, --help help for delete-context
```

### Options inherited from parent commands

```
-A, --all-projects Displays the objects from all of the projects.
--config string Config file path.
-c, --context string Overrides the default context for the duration of the selected command.
--no-config-file Don't create config.toml, operate only on env variables.
-p, --project string Overrides the default project from active Delete for the duration of the selected command.
```

### SEE ALSO

* [sloctl config](sloctl_config.md) - Configuration management

###### Auto generated by spf13/cobra on 2-Aug-2024
Loading
Loading