From d7400806f6ea5ba2ea80afa79b266b6e3a2ff268 Mon Sep 17 00:00:00 2001 From: Bradley D Date: Thu, 10 Oct 2024 16:30:50 -0600 Subject: [PATCH] Dev/glamorous help (#7) * updates * replace tables with lipgloss tables --- .hugo/hugo.yaml | 2 +- docs/docs/cli/_index.md | 56 +++++++++- docs/docs/cli/carbon.md | 45 -------- docs/docs/cli/carbon_completion.md | 16 ++- docs/docs/cli/carbon_config.md | 60 +++++++---- docs/docs/cli/carbon_docs.md | 36 ------- docs/docs/cli/carbon_image.md | 26 ++--- docs/docs/cli/carbon_image_bootstrap.md | 31 +++--- docs/docs/cli/carbon_image_build.md | 29 +++-- docs/docs/cli/carbon_image_destroy.md | 31 +++--- docs/docs/cli/carbon_image_list.md | 33 +++--- docs/docs/cli/carbon_project.md | 18 ++-- docs/docs/cli/carbon_project_add-machine.md | 28 +++-- docs/docs/cli/carbon_project_add.md | 41 ------- docs/docs/cli/carbon_project_apply.md | 28 +++-- docs/docs/cli/carbon_project_list.md | 26 ++--- docs/docs/cli/carbon_update.md | 53 +++++---- docs/docs/cli/carbon_vm.md | 30 ++---- docs/docs/cli/carbon_vm_destroy.md | 28 +++-- docs/docs/cli/carbon_vm_launch.md | 28 +++-- docs/docs/cli/carbon_vm_list.md | 41 ++++--- docs/docs/cli/carbon_vm_restart.md | 28 +++-- docs/docs/cli/carbon_vm_ssh.md | 47 +++++--- docs/docs/cli/carbon_vm_start.md | 28 +++-- docs/docs/cli/carbon_vm_stop.md | 26 +++-- docs/docs/cli/carbon_vm_vnc.md | 28 +++-- go.mod | 18 +++- go.sum | 42 ++++++-- main.go | 11 +- pkg/cmd/{root.go => carbon.go} | 56 ++++++---- pkg/cmd/config.go | 40 +++++-- pkg/cmd/dev.go | 2 +- pkg/cmd/dev_vm.go | 26 ----- pkg/cmd/image.go | 6 +- pkg/cmd/image_boostrap.go | 12 +-- pkg/cmd/image_build.go | 12 +-- pkg/cmd/image_destroy.go | 12 +-- pkg/cmd/image_list.go | 82 +++++++++----- pkg/cmd/project.go | 5 +- ...{project_add.go => project_add_machine.go} | 13 +-- pkg/cmd/project_apply.go | 13 +-- pkg/cmd/project_list.go | 13 +-- pkg/cmd/vm.go | 102 ++++++++++++------ pkg/cmd/vm_destroy.go | 13 +-- pkg/cmd/vm_launch.go | 13 +-- pkg/cmd/vm_list.go | 17 ++- pkg/cmd/vm_restart.go | 13 +-- pkg/cmd/vm_ssh.go | 22 +++- pkg/cmd/vm_start.go | 13 +-- pkg/cmd/vm_stop.go | 5 +- pkg/cmd/vm_vnc.go | 7 +- pkg/providers/qemu/api/qemu.go | 1 - 52 files changed, 695 insertions(+), 717 deletions(-) delete mode 100644 docs/docs/cli/carbon.md delete mode 100644 docs/docs/cli/carbon_docs.md delete mode 100644 docs/docs/cli/carbon_project_add.md rename pkg/cmd/{root.go => carbon.go} (62%) delete mode 100644 pkg/cmd/dev_vm.go rename pkg/cmd/{project_add.go => project_add_machine.go} (87%) diff --git a/.hugo/hugo.yaml b/.hugo/hugo.yaml index 5e901b4..562efd3 100644 --- a/.hugo/hugo.yaml +++ b/.hugo/hugo.yaml @@ -84,7 +84,7 @@ markup: style: monokai noClasses: false # Uncomment if you want your chosen highlight style used for code blocks without a specified language - # guessSyntax: true + guessSyntax: true # Everything below this are Site Params diff --git a/docs/docs/cli/_index.md b/docs/docs/cli/_index.md index 58656e1..2f6dad0 100644 --- a/docs/docs/cli/_index.md +++ b/docs/docs/cli/_index.md @@ -1,5 +1,59 @@ --- -title: CLI +title: Carbon CLI description: Carbon CLI Reference +no_list: true weight: 1 --- +## Synopsis + +Infrastructure automation for offensive operations. +> Checkout the latest docs [here](https://analog-substance.github.io/carbon/) +> Have a problem? [Create an Issue](https://github.com/analog-substance/carbon/issues/new?title=Something%20is%20broken) + +## Purpose +*** + +Carbon's primary purpose is to provide a consistent execution environment to +facilitate offensive security assessments. + +## Dependencies + +- Packer to build images. +- Terraform to provision infrastructure. +- Golang project structure. + +## Supported Providers + +- AWS +- QEMU (Local) +- VirtualBox (Local) +- vSphere (in progress) +- Multipass (Local) + +There are plans to bring support to the following: + +- GCP +- Azure +- VMware (Local) +- QEMU (Remote) + + +## Options + +``` + --config string config file (default is $HOME/.carbon.yaml) + --debug Debug mode + -h, --help help for carbon + -j, --json Output in JSON +``` + +## SEE ALSO + +* [carbon completion](carbon_completion.md) - Generate completion script +* [carbon config](carbon_config.md) - View and manage configuration values. +* [carbon image](carbon_image.md) - View or manage images and image builds. +* [carbon project](carbon_project.md) - Manage and interact with projects +* [carbon update](carbon_update.md) - Update {{.Use}} to latest version +* [carbon vm](carbon_vm.md) - Manage and interact with VMs. + +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon.md b/docs/docs/cli/carbon.md deleted file mode 100644 index fb748b0..0000000 --- a/docs/docs/cli/carbon.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: Carbon -description: Infrastructure Ops simplified ---- - -## carbon - -Infrastructure Ops simplified - -### Synopsis - -Manage and use infrastructure with a consistent interface, regardless of where it lives. - -Simple things like SSH and VNC. - - carbon vm ssh -n vm-name - carbon vm vnc -n vm-name - -Starting and stopping VMs - - carbon vm start -n vm-name - carbon vm stop -n vm-name - -Carbon supports AWS, QEMU, VirtualBox, and vSphere. - - -### Options - -``` - --config string config file (default is $HOME/.carbon.yaml) - --debug Debug mode - -h, --help help for carbon - -j, --json Output in JSON -``` - -### SEE ALSO - -* [carbon completion](carbon_completion.md) - Generate completion script -* [carbon config](carbon_config.md) - Get/Set config information -* [carbon image](carbon_image.md) - manage images and image builds -* [carbon project](carbon_project.md) - Manage and interact with projects -* [carbon update](carbon_update.md) - Update {{.Use}} to latest version -* [carbon vm](carbon_vm.md) - Manage and interact with VMs - -###### Auto generated by spf13/cobra on 9-Oct-2024 diff --git a/docs/docs/cli/carbon_completion.md b/docs/docs/cli/carbon_completion.md index fc8f560..bbaf73b 100644 --- a/docs/docs/cli/carbon_completion.md +++ b/docs/docs/cli/carbon_completion.md @@ -3,11 +3,7 @@ title: Completion description: Generate completion script --- -## carbon completion - -Generate completion script - -### Synopsis +## Synopsis To load completions: @@ -52,13 +48,13 @@ PowerShell: carbon completion [bash|zsh|fish|powershell] ``` -### Options +## Options ``` -h, --help help for completion ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -66,8 +62,8 @@ carbon completion [bash|zsh|fish|powershell] -j, --json Output in JSON ``` -### SEE ALSO +## SEE ALSO -* [carbon](carbon.md) - Infrastructure Ops simplified +* [carbon](carbon.md) - Carbon - Infrastructure automation for offensive operations. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_config.md b/docs/docs/cli/carbon_config.md index ac03518..e5450b8 100644 --- a/docs/docs/cli/carbon_config.md +++ b/docs/docs/cli/carbon_config.md @@ -1,29 +1,51 @@ --- title: Config -description: Get/Set config information +description: View and manage configuration values. --- -## carbon config +## Synopsis + +View and manage configuration values. + +Carbon loads configuration files from your home directory, then merges it with +a configuration file in the current directory (if it exists). This should allow +you the flexibility you need. +## Configuration keys +- carbon.default.dir + - carbon.deployments.dir + - carbon.images.dir + - carbon.packer.dir + - carbon.projects.dir + - carbon.providers.aws.enabled + - carbon.providers.aws.profiles.default.enabled + - carbon.providers.multipass.enabled + - carbon.providers.multipass.profiles.default.enabled + - carbon.providers.qemu.enabled + - carbon.providers.qemu.profiles.default.enabled + - carbon.providers.virtualbox.enabled + - carbon.providers.virtualbox.profiles.default.enabled + - carbon.terraform.dir -Get/Set config information - -### Synopsis - -Get/Set config information. - -Set vSphere credentials +``` +carbon config [flags] +``` - carbon config carbon.credentials.vsphere_server.provider vsphere - carbon config carbon.credentials.vsphere_server.username vsphere_user@vsphere.example - carbon config carbon.credentials.vsphere_server.password_command 'op read op://Private/vSphere Creds/password' +## Examples +```bash +# Configure vSphere credentials +carbon config carbon.credentials.vsphere_server.provider vsphere +carbon config carbon.credentials.vsphere_server.username vsphere_user@vsphere.example +carbon config carbon.credentials.vsphere_server.password_command 'op read op://Private/vSphere Creds/password' +``` +```bash +# Set a default project directory +carbon config carbon.default.dir ~/my/path/haxors -``` -carbon config [flags] ``` -### Options +## Options ``` -h, --help help for config @@ -32,7 +54,7 @@ carbon config [flags] -k, --sub-keys display only the sub-keys ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -40,8 +62,8 @@ carbon config [flags] -j, --json Output in JSON ``` -### SEE ALSO +## SEE ALSO -* [carbon](carbon.md) - Infrastructure Ops simplified +* [carbon](carbon.md) - Carbon - Infrastructure automation for offensive operations. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_docs.md b/docs/docs/cli/carbon_docs.md deleted file mode 100644 index c4b7d1b..0000000 --- a/docs/docs/cli/carbon_docs.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: Docs -description: Generate docs ---- - -## carbon docs - -Generate docs - -### Synopsis - -Generate documentation markdown files from the source code. - -``` -carbon docs [flags] -``` - -### Options - -``` - -h, --help help for docs -``` - -### Options inherited from parent commands - -``` - --config string config file (default is $HOME/.carbon.yaml) - --debug Debug mode - -j, --json Output in JSON -``` - -### SEE ALSO - -* [carbon](carbon.md) - Infrastructure Ops simplified - -###### Auto generated by spf13/cobra on 9-Oct-2024 diff --git a/docs/docs/cli/carbon_image.md b/docs/docs/cli/carbon_image.md index 3e33972..2745745 100644 --- a/docs/docs/cli/carbon_image.md +++ b/docs/docs/cli/carbon_image.md @@ -1,23 +1,19 @@ --- title: Image -description: manage images and image builds +description: View or manage images and image builds. --- -## carbon image +## Synopsis -manage images and image builds +View or manage images and image builds. -### Synopsis - -manage images and image builds - -### Options +## Options ``` -h, --help help for image ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -25,12 +21,12 @@ manage images and image builds -j, --json Output in JSON ``` -### SEE ALSO +## SEE ALSO -* [carbon](carbon.md) - Infrastructure Ops simplified -* [carbon image bootstrap](carbon_image_bootstrap.md) - create image build configs -* [carbon image build](carbon_image_build.md) - build an image -* [carbon image destroy](carbon_image_destroy.md) - destroy/delete images +* [carbon](carbon.md) - Carbon - Infrastructure automation for offensive operations. +* [carbon image bootstrap](carbon_image_bootstrap.md) - Create packer files and other image build configs. +* [carbon image build](carbon_image_build.md) - Build an image. +* [carbon image destroy](carbon_image_destroy.md) - Delete images. * [carbon image list](carbon_image_list.md) - list images -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_image_bootstrap.md b/docs/docs/cli/carbon_image_bootstrap.md index 9f84140..021f8ea 100644 --- a/docs/docs/cli/carbon_image_bootstrap.md +++ b/docs/docs/cli/carbon_image_bootstrap.md @@ -1,26 +1,23 @@ --- title: Image Bootstrap -description: create image build configs +description: Create packer files and other image build configs. --- -## carbon image bootstrap - -create image build configs - -### Synopsis - -create image build configs. -Example - - carbon image bootstrap -n operator-desktop-aws -s aws -t ubuntu-desktop - +## Synopsis +Create packer files and other image build configs. ``` carbon image bootstrap [flags] ``` -### Options +## Examples + +```bash +carbon image bootstrap -n operator-desktop-aws -s aws -t ubuntu-desktop +``` + +## Options ``` -h, --help help for bootstrap @@ -29,7 +26,7 @@ carbon image bootstrap [flags] -t, --template string Template to use (default "ubuntu-24.04") ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -37,8 +34,8 @@ carbon image bootstrap [flags] -j, --json Output in JSON ``` -### SEE ALSO +## SEE ALSO -* [carbon image](carbon_image.md) - manage images and image builds +* [carbon image](carbon_image.md) - View or manage images and image builds. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_image_build.md b/docs/docs/cli/carbon_image_build.md index 78c700d..b3eabda 100644 --- a/docs/docs/cli/carbon_image_build.md +++ b/docs/docs/cli/carbon_image_build.md @@ -1,26 +1,23 @@ --- title: Image Build -description: build an image +description: Build an image. --- -## carbon image build - -build an image - -### Synopsis +## Synopsis build an image. -Example - - carbon image build -m ubuntu-desktop -t qemu - - ``` carbon image build [flags] ``` -### Options +## Examples + +```bash +carbon image build -t aws -n operator-desktop-aws +``` + +## Options ``` -h, --help help for build @@ -29,7 +26,7 @@ carbon image build [flags] -a, --provisioner string Name of provisioner to use (default "cloud-init") ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -37,8 +34,8 @@ carbon image build [flags] -j, --json Output in JSON ``` -### SEE ALSO +## SEE ALSO -* [carbon image](carbon_image.md) - manage images and image builds +* [carbon image](carbon_image.md) - View or manage images and image builds. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_image_destroy.md b/docs/docs/cli/carbon_image_destroy.md index 6675a6c..fcc522b 100644 --- a/docs/docs/cli/carbon_image_destroy.md +++ b/docs/docs/cli/carbon_image_destroy.md @@ -1,33 +1,30 @@ --- title: Image Destroy -description: destroy/delete images +description: Delete images. --- -## carbon image destroy - -destroy/delete images - -### Synopsis - -destroy/delete images. -Example - - carbon image destroy -i qemu/some-image-123123123 - +## Synopsis +Delete images. ``` carbon image destroy [flags] ``` -### Options +## Examples + +```bash +carbon image destroy -i qemu/some-image-123123123 +``` + +## Options ``` -h, --help help for destroy -i, --image-id string ID of image to delete ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -35,8 +32,8 @@ carbon image destroy [flags] -j, --json Output in JSON ``` -### SEE ALSO +## SEE ALSO -* [carbon image](carbon_image.md) - manage images and image builds +* [carbon image](carbon_image.md) - View or manage images and image builds. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_image_list.md b/docs/docs/cli/carbon_image_list.md index da2f3c3..ece8c78 100644 --- a/docs/docs/cli/carbon_image_list.md +++ b/docs/docs/cli/carbon_image_list.md @@ -3,32 +3,35 @@ title: Image List description: list images --- -## carbon image list - -list images - -### Synopsis +## Synopsis list images and image builds. -Example - - carbon image list - carbon image list -b +``` +carbon image list [flags] +``` +## Examples +```bash +# List all images +carbon image list ``` -carbon image list [flags] + +```bash +#list image builds +carbon image list -b + ``` -### Options +## Options ``` -b, --builds List build configs -h, --help help for list ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -36,8 +39,8 @@ carbon image list [flags] -j, --json Output in JSON ``` -### SEE ALSO +## SEE ALSO -* [carbon image](carbon_image.md) - manage images and image builds +* [carbon image](carbon_image.md) - View or manage images and image builds. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_project.md b/docs/docs/cli/carbon_project.md index dce0e38..4317e91 100644 --- a/docs/docs/cli/carbon_project.md +++ b/docs/docs/cli/carbon_project.md @@ -3,24 +3,20 @@ title: Project description: Manage and interact with projects --- -## carbon project - -Manage and interact with projects - -### Synopsis +## Synopsis Manage projects. Projects are directories with terraform code to manage resources for the project. -### Options +## Options ``` -h, --help help for project -p, --project string Name of the project. ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -28,11 +24,11 @@ Projects are directories with terraform code to manage resources for the project -j, --json Output in JSON ``` -### SEE ALSO +## SEE ALSO -* [carbon](carbon.md) - Infrastructure Ops simplified -* [carbon project add-machine](carbon_project_add-machine.md) - Add resources to a project +* [carbon](carbon.md) - Carbon - Infrastructure automation for offensive operations. +* [carbon project add-machine](carbon_project_add-machine.md) - Add a new machine to a project * [carbon project apply](carbon_project_apply.md) - Run terraform apply * [carbon project list](carbon_project_list.md) - Manage and interact with projects -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_project_add-machine.md b/docs/docs/cli/carbon_project_add-machine.md index 23de34b..f3be6d0 100644 --- a/docs/docs/cli/carbon_project_add-machine.md +++ b/docs/docs/cli/carbon_project_add-machine.md @@ -1,27 +1,23 @@ --- title: Project Add-Machine -description: Add resources to a project +description: Add a new machine to a project --- -## carbon project add-machine - -Add resources to a project - -### Synopsis +## Synopsis Add a new machine to the project. -Example: - - carbon project add -p example-qemu-carbon -n testbrad2 -P qemu -i carbon-ubuntu-desktop-20241008201758 - - - ``` carbon project add-machine [flags] ``` -### Options +## Examples + +```bash +carbon project add-machine -p example-qemu-carbon -n modlishka -P qemu -i carbon-ubuntu-desktop-20241008201758 +``` + +## Options ``` -h, --help help for add-machine @@ -30,7 +26,7 @@ carbon project add-machine [flags] -P, --provider-type string Provider for the new machine ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -39,8 +35,8 @@ carbon project add-machine [flags] -p, --project string Name of the project. ``` -### SEE ALSO +## SEE ALSO * [carbon project](carbon_project.md) - Manage and interact with projects -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_project_add.md b/docs/docs/cli/carbon_project_add.md deleted file mode 100644 index 1f3a2b0..0000000 --- a/docs/docs/cli/carbon_project_add.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -title: Project Add ---- - -## carbon project add - -Add resources to a project - -### Synopsis - -Basically lazy wrappers around tedious things. - -So you type less and be more productive! - -``` -carbon project add [flags] -``` - -### Options - -``` - -h, --help help for add - -i, --image string Name of the VM to add. - -n, --name string Name of the VM to add. - -P, --provider-type string Provider for the new machine -``` - -### Options inherited from parent commands - -``` - --config string config file (default is $HOME/.carbon.yaml) - --debug Debug mode - -j, --json Output in JSON - -p, --project string Name of the project. -``` - -### SEE ALSO - -* [carbon project](carbon_project.md) - Manage and interact with deployments - -###### Auto generated by spf13/cobra on 8-Oct-2024 diff --git a/docs/docs/cli/carbon_project_apply.md b/docs/docs/cli/carbon_project_apply.md index a83ea8e..69e6958 100644 --- a/docs/docs/cli/carbon_project_apply.md +++ b/docs/docs/cli/carbon_project_apply.md @@ -3,31 +3,27 @@ title: Project Apply description: Run terraform apply --- -## carbon project apply - -Run terraform apply - -### Synopsis - -Apply terraform. - -Example: - - carbon project apply -p project-name - +## Synopsis +Apply terraform. No need to change dirs. ``` carbon project apply [flags] ``` -### Options +## Examples + +```bash +carbon project apply -p project-name +``` + +## Options ``` -h, --help help for apply ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -36,8 +32,8 @@ carbon project apply [flags] -p, --project string Name of the project. ``` -### SEE ALSO +## SEE ALSO * [carbon project](carbon_project.md) - Manage and interact with projects -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_project_list.md b/docs/docs/cli/carbon_project_list.md index 6324b8f..87699f0 100644 --- a/docs/docs/cli/carbon_project_list.md +++ b/docs/docs/cli/carbon_project_list.md @@ -3,31 +3,27 @@ title: Project List description: Manage and interact with projects --- -## carbon project list - -Manage and interact with projects - -### Synopsis +## Synopsis List projects. -Example: - - carbon project list - - - ``` carbon project list [flags] ``` -### Options +## Examples + +```bash +carbon project list +``` + +## Options ``` -h, --help help for list ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -36,8 +32,8 @@ carbon project list [flags] -p, --project string Name of the project. ``` -### SEE ALSO +## SEE ALSO * [carbon project](carbon_project.md) - Manage and interact with projects -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_update.md b/docs/docs/cli/carbon_update.md index 134b4f8..3f1f56e 100644 --- a/docs/docs/cli/carbon_update.md +++ b/docs/docs/cli/carbon_update.md @@ -3,43 +3,40 @@ title: Update description: Update {{.Use}} to latest version --- -## carbon update - -Update {{.Use}} to latest version - -### Synopsis +## Synopsis Update or check for updates. The default update method is to download the latest release from GitHub. -Example 1: Update to latest GitHub - - carbon update - -Example 2: Use go install to update - - carbon update -g - - -Example 3: Download from a specific URL +``` +carbon update [flags] +``` -Not sure why anyone else would need this. I use it for quickly testing builds -on different machines. +## Examples - carbon update -u http://10.0.0.2:8000/dist/carbon_darwin_arm64/carbon +```bash +# Update to latest version +carbon update +``` -This is typically used after I run the following: +```bash +# Use go install to update +carbon update -g +``` - goreleaser release --clean --snapshot - python -m http.server +```bash +# Download from a specific URL +# Not sure why anyone else would need this. I use it for quickly testing builds on different machines. +carbon update -u http://10.0.0.2:8000/dist/carbon_darwin_arm64/carbon +# This is typically used after I run the following: +# goreleaser release --clean --snapshot +# python -m http.server -``` -carbon update [flags] ``` -### Options +## Options ``` -C, --check Check for update @@ -49,7 +46,7 @@ carbon update [flags] -u, --url string URL to download from (force implies) ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -57,8 +54,8 @@ carbon update [flags] -j, --json Output in JSON ``` -### SEE ALSO +## SEE ALSO -* [carbon](carbon.md) - Infrastructure Ops simplified +* [carbon](carbon.md) - Carbon - Infrastructure automation for offensive operations. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_vm.md b/docs/docs/cli/carbon_vm.md index daf02c4..2160f46 100644 --- a/docs/docs/cli/carbon_vm.md +++ b/docs/docs/cli/carbon_vm.md @@ -1,27 +1,13 @@ --- title: Vm -description: Manage and interact with VMs +description: Manage and interact with VMs. --- -## carbon vm - -Manage and interact with VMs - -### Synopsis +## Synopsis Manage and interact with VMs. -Management functions include - -- Starting VMs -- Stopping VMs -- Rebooting VMs -- Launching VMs from images -- Destroying VMs from images - - - -### Options +## Options ``` -h, --help help for vm @@ -31,7 +17,7 @@ Management functions include -u, --user string SSH Username. (default "ubuntu") ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -39,16 +25,16 @@ Management functions include -j, --json Output in JSON ``` -### SEE ALSO +## SEE ALSO -* [carbon](carbon.md) - Infrastructure Ops simplified +* [carbon](carbon.md) - Carbon - Infrastructure automation for offensive operations. * [carbon vm destroy](carbon_vm_destroy.md) - destroy VM * [carbon vm launch](carbon_vm_launch.md) - launch a new vm from an image -* [carbon vm list](carbon_vm_list.md) - List VMs +* [carbon vm list](carbon_vm_list.md) - List VMs across all available providers, profiles, and environments. * [carbon vm restart](carbon_vm_restart.md) - Restart VM(s) * [carbon vm ssh](carbon_vm_ssh.md) - SSH to a VM * [carbon vm start](carbon_vm_start.md) - Start VMs * [carbon vm stop](carbon_vm_stop.md) - Stop VM(s) * [carbon vm vnc](carbon_vm_vnc.md) - VNC to a VM -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_vm_destroy.md b/docs/docs/cli/carbon_vm_destroy.md index c616eb7..028b3e4 100644 --- a/docs/docs/cli/carbon_vm_destroy.md +++ b/docs/docs/cli/carbon_vm_destroy.md @@ -3,31 +3,27 @@ title: Vm Destroy description: destroy VM --- -## carbon vm destroy - -destroy VM - -### Synopsis +## Synopsis Destroy a VM. -Example: - - carbon vm destroy -n vm-name - - - ``` carbon vm destroy [flags] ``` -### Options +## Examples + +```bash +carbon vm destroy -n vm-name +``` + +## Options ``` -h, --help help for destroy ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -39,8 +35,8 @@ carbon vm destroy [flags] -u, --user string SSH Username. (default "ubuntu") ``` -### SEE ALSO +## SEE ALSO -* [carbon vm](carbon_vm.md) - Manage and interact with VMs +* [carbon vm](carbon_vm.md) - Manage and interact with VMs. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_vm_launch.md b/docs/docs/cli/carbon_vm_launch.md index b6d5eb5..c4a73dc 100644 --- a/docs/docs/cli/carbon_vm_launch.md +++ b/docs/docs/cli/carbon_vm_launch.md @@ -3,25 +3,21 @@ title: Vm Launch description: launch a new vm from an image --- -## carbon vm launch - -launch a new vm from an image - -### Synopsis +## Synopsis launch a new vm from an image. -Example: - - carbon vm launch -I qemu/carbon-ubuntu-desktop-20241007212910 -n vm-name - - - ``` carbon vm launch [flags] ``` -### Options +## Examples + +```bash +carbon vm launch -I qemu/carbon-ubuntu-desktop-20241007212910 -n vm-name +``` + +## Options ``` -h, --help help for launch @@ -29,7 +25,7 @@ carbon vm launch [flags] -n, --name string Name of new VM ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -40,8 +36,8 @@ carbon vm launch [flags] -u, --user string SSH Username. (default "ubuntu") ``` -### SEE ALSO +## SEE ALSO -* [carbon vm](carbon_vm.md) - Manage and interact with VMs +* [carbon vm](carbon_vm.md) - Manage and interact with VMs. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_vm_list.md b/docs/docs/cli/carbon_vm_list.md index 2e67164..de953bb 100644 --- a/docs/docs/cli/carbon_vm_list.md +++ b/docs/docs/cli/carbon_vm_list.md @@ -1,39 +1,36 @@ --- title: Vm List -description: List VMs +description: List VMs across all available providers, profiles, and environments. --- -## carbon vm list +## Synopsis -List VMs +List VMs across all available providers, profiles, and environments. -### Synopsis - -List VMs. - -Example: - - carbon vm list - -You can also supply a name search: - - carbon vm list -n vm- +``` +carbon vm list [flags] +``` -This will list VMs with vm- in their name. +## Examples +```bash +# list all virtual machines +carbon vm list +``` +```bash +# You can also supply a name search, this wil return VMs with names containing 'vm-' +carbon vm list -n vm- -``` -carbon vm list [flags] ``` -### Options +## Options ``` -h, --help help for list ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -45,8 +42,8 @@ carbon vm list [flags] -u, --user string SSH Username. (default "ubuntu") ``` -### SEE ALSO +## SEE ALSO -* [carbon vm](carbon_vm.md) - Manage and interact with VMs +* [carbon vm](carbon_vm.md) - Manage and interact with VMs. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_vm_restart.md b/docs/docs/cli/carbon_vm_restart.md index cdde3bb..6f5b005 100644 --- a/docs/docs/cli/carbon_vm_restart.md +++ b/docs/docs/cli/carbon_vm_restart.md @@ -3,31 +3,27 @@ title: Vm Restart description: Restart VM(s) --- -## carbon vm restart - -Restart VM(s) - -### Synopsis +## Synopsis Restart VM(s). -Example: - - carbon vm restart -n vm-name - - - ``` carbon vm restart [flags] ``` -### Options +## Examples + +```bash +carbon vm restart -n vm-name +``` + +## Options ``` -h, --help help for restart ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -39,8 +35,8 @@ carbon vm restart [flags] -u, --user string SSH Username. (default "ubuntu") ``` -### SEE ALSO +## SEE ALSO -* [carbon vm](carbon_vm.md) - Manage and interact with VMs +* [carbon vm](carbon_vm.md) - Manage and interact with VMs. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_vm_ssh.md b/docs/docs/cli/carbon_vm_ssh.md index 81a040a..56afea8 100644 --- a/docs/docs/cli/carbon_vm_ssh.md +++ b/docs/docs/cli/carbon_vm_ssh.md @@ -3,33 +3,52 @@ title: Vm Ssh description: SSH to a VM --- -## carbon vm ssh +## Synopsis -SSH to a VM +SSH to a VM. +Carbon will call exec on the ssh binary. This means the SSH process takes +over the carbon process. So SSH agents should just work. -### Synopsis -SSH to a VM. +``` +carbon vm ssh [flags] +``` -Example: +## Examples - carbon vm ssh -n vm-name +```bash +# SSH to a VM +carbon vm ssh -n vm-name +``` -Carbon will call exec on the ssh binary. This means the SSH process takes -over the carbon process. So SSH agents should just work. +```bash +# execute one off command on a VM +carbon vm ssh -n vm-name -- cat /etc/passwd +``` +```bash +# proxy through a bastion +carbon vm ssh -n vm-name -- -oProxyCommand="carbon vm ssh -n bastion -- -W %h:%p" +``` +```bash +# forward ssh agent +carbon vm ssh -n vm-name -- -A ``` -carbon vm ssh [flags] + +```bash +# open socks proxy +carbon vm ssh -n vm-name -- -D 1080 + ``` -### Options +## Options ``` -h, --help help for ssh ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -41,8 +60,8 @@ carbon vm ssh [flags] -u, --user string SSH Username. (default "ubuntu") ``` -### SEE ALSO +## SEE ALSO -* [carbon vm](carbon_vm.md) - Manage and interact with VMs +* [carbon vm](carbon_vm.md) - Manage and interact with VMs. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_vm_start.md b/docs/docs/cli/carbon_vm_start.md index 6098eff..0fe10ae 100644 --- a/docs/docs/cli/carbon_vm_start.md +++ b/docs/docs/cli/carbon_vm_start.md @@ -3,31 +3,27 @@ title: Vm Start description: Start VMs --- -## carbon vm start - -Start VMs - -### Synopsis +## Synopsis start VMs. -Example: - - carbon vm start -n vm-name - - - ``` carbon vm start [flags] ``` -### Options +## Examples + +```bash +carbon vm start -n vm-name +``` + +## Options ``` -h, --help help for start ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -39,8 +35,8 @@ carbon vm start [flags] -u, --user string SSH Username. (default "ubuntu") ``` -### SEE ALSO +## SEE ALSO -* [carbon vm](carbon_vm.md) - Manage and interact with VMs +* [carbon vm](carbon_vm.md) - Manage and interact with VMs. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_vm_stop.md b/docs/docs/cli/carbon_vm_stop.md index 27c5efc..58985d9 100644 --- a/docs/docs/cli/carbon_vm_stop.md +++ b/docs/docs/cli/carbon_vm_stop.md @@ -3,18 +3,10 @@ title: Vm Stop description: Stop VM(s) --- -## carbon vm stop - -Stop VM(s) - -### Synopsis +## Synopsis Stop VM(s). -Example: - - carbon vm stop -n vm-name - By default, carbon will attempt to hibernate the machine rather than power it off. @@ -22,13 +14,19 @@ By default, carbon will attempt to hibernate the machine rather than power it of carbon vm stop [flags] ``` -### Options +## Examples + +```bash +carbon vm start -n vm-name +``` + +## Options ``` -h, --help help for stop ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -40,8 +38,8 @@ carbon vm stop [flags] -u, --user string SSH Username. (default "ubuntu") ``` -### SEE ALSO +## SEE ALSO -* [carbon vm](carbon_vm.md) - Manage and interact with VMs +* [carbon vm](carbon_vm.md) - Manage and interact with VMs. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/docs/docs/cli/carbon_vm_vnc.md b/docs/docs/cli/carbon_vm_vnc.md index 921bf64..776ba8b 100644 --- a/docs/docs/cli/carbon_vm_vnc.md +++ b/docs/docs/cli/carbon_vm_vnc.md @@ -3,19 +3,11 @@ title: Vm Vnc description: VNC to a VM --- -## carbon vm vnc - -VNC to a VM - -### Synopsis +## Synopsis VNC to a VM. - -Example: - - carbon vm vnc -n vm-name - This will: + - SSH to the target VM. - Check to see if vncserver is running. - If not, start vncserver on the remote machine @@ -29,14 +21,20 @@ This will: carbon vm vnc [flags] ``` -### Options +## Examples + +```bash +carbon vnc start -n vm-name +``` + +## Options ``` -h, --help help for vnc -k, --kill-vnc Kill VNC before starting ``` -### Options inherited from parent commands +## Options inherited from parent commands ``` --config string config file (default is $HOME/.carbon.yaml) @@ -48,8 +46,8 @@ carbon vm vnc [flags] -u, --user string SSH Username. (default "ubuntu") ``` -### SEE ALSO +## SEE ALSO -* [carbon vm](carbon_vm.md) - Manage and interact with VMs +* [carbon vm](carbon_vm.md) - Manage and interact with VMs. -###### Auto generated by spf13/cobra on 9-Oct-2024 +###### Auto generated by spf13/cobra on 10-Oct-2024 diff --git a/go.mod b/go.mod index b12686e..949cdef 100644 --- a/go.mod +++ b/go.mod @@ -4,15 +4,15 @@ go 1.23.1 require ( github.com/NoF0rte/cmd-builder v0.0.0-20220305223538-e35bfeabbbff - github.com/analog-substance/util v1.0.0 + github.com/analog-substance/util v1.0.1 github.com/aws/aws-sdk-go-v2 v1.32.2 github.com/aws/aws-sdk-go-v2/config v1.27.43 github.com/aws/aws-sdk-go-v2/service/ec2 v1.181.2 github.com/aws/aws-sdk-go-v2/service/sts v1.32.2 github.com/charmbracelet/huh v0.6.0 + github.com/charmbracelet/lipgloss v0.13.0 github.com/digitalocean/go-libvirt v0.0.0-20241007203800-ad92148935b6 github.com/hashicorp/hcl/v2 v2.22.0 - github.com/jedib0t/go-pretty/v6 v6.6.0 github.com/mitchellh/go-homedir v1.1.0 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 @@ -26,6 +26,7 @@ require ( require ( github.com/Microsoft/go-winio v0.6.2 // indirect github.com/agext/levenshtein v1.2.3 // indirect + github.com/alecthomas/chroma/v2 v2.14.0 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/atotto/clipboard v0.1.4 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.17.41 // indirect @@ -39,18 +40,20 @@ require ( github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.2 // indirect github.com/aws/smithy-go v1.22.0 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect + github.com/aymerick/douceur v0.2.0 // indirect github.com/catppuccin/go v0.2.0 // indirect github.com/charmbracelet/bubbles v0.20.0 // indirect github.com/charmbracelet/bubbletea v1.1.1 // indirect - github.com/charmbracelet/lipgloss v0.13.0 // indirect + github.com/charmbracelet/glamour v0.8.0 // indirect github.com/charmbracelet/x/ansi v0.3.2 // indirect github.com/charmbracelet/x/exp/strings v0.0.0-20241007193646-7cc13b2883e3 // indirect github.com/charmbracelet/x/term v0.2.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect + github.com/dlclark/regexp2 v1.11.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/google/go-cmp v0.6.0 // indirect + github.com/gorilla/css v1.0.1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect @@ -58,16 +61,17 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-localereader v0.0.1 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect + github.com/microcosm-cc/bluemonday v1.0.27 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect + github.com/muesli/reflow v0.3.0 // indirect github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect - github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sagikazarmark/locafero v0.6.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect @@ -75,12 +79,16 @@ require ( github.com/spf13/cast v1.7.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect + github.com/yuin/goldmark v1.7.4 // indirect + github.com/yuin/goldmark-emoji v1.0.3 // indirect github.com/zclconf/go-cty v1.15.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6 // indirect golang.org/x/mod v0.21.0 // indirect + golang.org/x/net v0.30.0 // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.26.0 // indirect + golang.org/x/term v0.25.0 // indirect golang.org/x/text v0.19.0 // indirect golang.org/x/tools v0.26.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect diff --git a/go.sum b/go.sum index e8ceda2..2207284 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,14 @@ github.com/NoF0rte/cmd-builder v0.0.0-20220305223538-e35bfeabbbff h1:GQV4BEXtKM7 github.com/NoF0rte/cmd-builder v0.0.0-20220305223538-e35bfeabbbff/go.mod h1:BW980ODOiAtIbHttRfkCrP+zdJAXjE5uEwzT73Xu98k= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/analog-substance/util v1.0.0 h1:LhatTKnW2vtWh/fNU0rh1lPSr4ANCWvfnHb8NZeHchY= -github.com/analog-substance/util v1.0.0/go.mod h1:MQ2aobwi8Lk3hr8AEpmkgr/X6P6RqZs0/IQ75ETKmeA= +github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE= +github.com/alecthomas/assert/v2 v2.7.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= +github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= +github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= +github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= +github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= +github.com/analog-substance/util v1.0.1 h1:Xqk/6t+1VqnCX/mhM8/iscmS3fx0exS/ohOjXPqCGQM= +github.com/analog-substance/util v1.0.1/go.mod h1:J0ESO2Rd8bhJgEdn/U7CIlNGR72GaH7FcMJXBDqfKsk= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= @@ -43,30 +49,38 @@ github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM= github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= +github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= +github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA= +github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= +github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= github.com/charmbracelet/bubbletea v1.1.1 h1:KJ2/DnmpfqFtDNVTvYZ6zpPFL9iRCRr0qqKOCvppbPY= github.com/charmbracelet/bubbletea v1.1.1/go.mod h1:9Ogk0HrdbHolIKHdjfFpyXJmiCzGwy+FesYkZr7hYU4= +github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= +github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8= github.com/charmbracelet/huh v0.6.0/go.mod h1:GGNKeWCeNzKpEOh/OJD8WBwTQjV3prFAtQPpLv+AVwU= github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw= github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= github.com/charmbracelet/x/ansi v0.3.2 h1:wsEwgAN+C9U06l9dCVMX0/L3x7ptvY1qmjMwyfE6USY= github.com/charmbracelet/x/ansi v0.3.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= +github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20241007193646-7cc13b2883e3 h1:gvSQygyrffOIVplbS78uZXcJvvDSwqfvhfAA8OUuVU8= github.com/charmbracelet/x/exp/strings v0.0.0-20241007193646-7cc13b2883e3/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ= github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0= github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= -github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/digitalocean/go-libvirt v0.0.0-20241007203800-ad92148935b6 h1:Bl49Fp2ksddm9qA9UGtWEYeob5iBZzNAmkB4Oz6oHQ4= github.com/digitalocean/go-libvirt v0.0.0-20241007203800-ad92148935b6/go.mod h1:2BnN3ZaDXE9uqsRk3eBTZAYHo9iGk0HP1FrgXLxyn4w= +github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= +github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= @@ -79,14 +93,16 @@ github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8= +github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl/v2 v2.22.0 h1:hkZ3nCtqeJsDhPRFz5EA9iwcG1hNWGePOTw6oyul12M= github.com/hashicorp/hcl/v2 v2.22.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= +github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= +github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jedib0t/go-pretty/v6 v6.6.0 h1:wmZVuAcEkZRT+Aq1xXpE8IGat4vE5WXOMmBpbQqERXw= -github.com/jedib0t/go-pretty/v6 v6.6.0/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -102,8 +118,11 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= +github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk= +github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= @@ -116,6 +135,8 @@ github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= +github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= +github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a h1:2MaM6YC3mGu54x+RKAA6JiFFHlHDY1UbkxqppT7wYOg= github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a/go.mod h1:hxSnBBYLK21Vtq/PHd0S2FYCxBXzBua8ov5s1RobyRQ= github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= @@ -123,12 +144,12 @@ github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xl github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= -github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk= github.com/sagikazarmark/locafero v0.6.0/go.mod h1:77OmuIc6VTraTXKXIs/uvUxKGUXjE1GbemJYHqdNjX0= @@ -154,6 +175,11 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= +github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= +github.com/yuin/goldmark v1.7.4 h1:BDXOHExt+A7gwPCJgPIIq7ENvceR7we7rOS9TNoLZeg= +github.com/yuin/goldmark v1.7.4/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= +github.com/yuin/goldmark-emoji v1.0.3 h1:aLRkLHOuBR2czCY4R8olwMjID+tENfhyFDMCRhbIQY4= +github.com/yuin/goldmark-emoji v1.0.3/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U= github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ= github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= @@ -168,6 +194,8 @@ golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6/go.mod h1:NQtJDoLvd6faHhE7m4 golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/main.go b/main.go index e5930d5..1331521 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "github.com/analog-substance/carbon/pkg/cmd" "github.com/analog-substance/util/cli/completion" "github.com/analog-substance/util/cli/docs" + "github.com/analog-substance/util/cli/glamour_help" "github.com/analog-substance/util/cli/updater/cobra_updater" ver "github.com/analog-substance/util/cli/version" ) @@ -12,9 +13,11 @@ var version = "v0.0.0" var commit = "replace" func main() { - cmd.RootCmd.Version = ver.GetVersionInfo(version, commit) - cmd.RootCmd.AddCommand(docs.CobraDocsCmd) - cobra_updater.AddToRootCmd(cmd.RootCmd) - completion.AddToRootCmd(cmd.RootCmd) + cmd.CarbonCmd.Version = ver.GetVersionInfo(version, commit) + cobra_updater.AddToRootCmd(cmd.CarbonCmd) + completion.AddToRootCmd(cmd.CarbonCmd) + cmd.CarbonCmd.AddCommand(docs.CobraDocsCmd) + glamour_help.AddToRootCmd(cmd.CarbonCmd) + cmd.Execute() } diff --git a/pkg/cmd/root.go b/pkg/cmd/carbon.go similarity index 62% rename from pkg/cmd/root.go rename to pkg/cmd/carbon.go index f30b1ee..8143f80 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/carbon.go @@ -21,23 +21,41 @@ var debug bool var carbonObj *carbon.Carbon var log *slog.Logger -// RootCmd represents the base command when called without any subcommands -var RootCmd = &cobra.Command{ +// CarbonCmd represents the base command when called without any subcommands +var CarbonCmd = &cobra.Command{ Use: "carbon", - Short: "Infrastructure Ops simplified", - Long: `Manage and use infrastructure with a consistent interface, regardless of where it lives. + Short: "Carbon - Infrastructure automation for offensive operations.", + Long: `Infrastructure automation for offensive operations. +ℹ️ Checkout the latest docs [here](https://analog-substance.github.io/carbon/) +😢 Have a problem? [Create an Issue](https://github.com/analog-substance/carbon/issues/new?title=Something%20is%20broken) +❤️ Enjoying Carbon? [Star the Repo](https://github.com/analog-substance/carbon) -Simple things like SSH and VNC. - carbon vm ssh -n vm-name - carbon vm vnc -n vm-name +## Purpose -Starting and stopping VMs +Carbon's primary purpose is to provide a consistent execution environment to +facilitate offensive security assessments. - carbon vm start -n vm-name - carbon vm stop -n vm-name +## Dependencies -Carbon supports AWS, QEMU, VirtualBox, and vSphere. +- Packer to build images. +- Terraform to provision infrastructure. +- Golang project structure. + +## Supported Providers + +- AWS +- QEMU (Local) +- VirtualBox (Local) +- vSphere (in progress) +- Multipass (Local) + +There are plans to bring support to the following: + +- GCP +- Azure +- VMware (Local) +- QEMU (Remote) `, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { @@ -53,6 +71,8 @@ Carbon supports AWS, QEMU, VirtualBox, and vSphere. } carbonObj = carbon.New(carbonConfigFile.Carbon) + updateConfigHelp() + return nil }, } @@ -60,7 +80,7 @@ Carbon supports AWS, QEMU, VirtualBox, and vSphere. // Execute adds all child commands to the root command and sets flags appropriately. // This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() { - err := RootCmd.Execute() + err := CarbonCmd.Execute() if err != nil { os.Exit(1) } @@ -70,13 +90,13 @@ func init() { log = common.WithGroup("cmd") cobra.OnInitialize(initConfig) - RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.carbon.yaml)") + CarbonCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.carbon.yaml)") // need to rethink how I want this to work - //RootCmd.PersistentFlags().StringSliceP("provider", "P", []string{}, "Provider to use vbox, aws") - //RootCmd.PersistentFlags().StringSliceVarP(&profiles, "profile", "p", []string{}, "Profile to use. Like an instance of a provider. Used to specify aws profiles") - //RootCmd.PersistentFlags().StringSliceVarP(&environments, "environment", "e", []string{}, "Environment to use. Some providers/profiles support many environments.") - RootCmd.PersistentFlags().BoolVarP(&jsonOutput, "json", "j", false, "Output in JSON") - RootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "Debug mode") + //CarbonCmd.PersistentFlags().StringSliceP("provider", "P", []string{}, "Provider to use vbox, aws") + //CarbonCmd.PersistentFlags().StringSliceVarP(&profiles, "profile", "p", []string{}, "Profile to use. Like an instance of a provider. Used to specify aws profiles") + //CarbonCmd.PersistentFlags().StringSliceVarP(&environments, "environment", "e", []string{}, "Environment to use. Some providers/profiles support many environments.") + CarbonCmd.PersistentFlags().BoolVarP(&jsonOutput, "json", "j", false, "Output in JSON") + CarbonCmd.PersistentFlags().BoolVar(&debug, "debug", false, "Debug mode") } // initConfig reads in config file and ENV variables if set. diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index 71db7cd..d009491 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -5,6 +5,7 @@ import ( "fmt" "gopkg.in/yaml.v3" "reflect" + "sort" "strconv" "strings" @@ -17,18 +18,24 @@ const defaultConfigFile = "carbon.yaml" // configCmd represents the config command var configCmd = &cobra.Command{ Use: "config", - Short: "Get/Set config information", - Long: `Get/Set config information. + Short: "View and manage configuration values.", + Long: `View and manage configuration values. -Set vSphere credentials +Carbon loads configuration files from your home directory, then merges it with +a configuration file in the current directory (if it exists). This should allow +you the flexibility you need. +`, + Example: `# Configure vSphere credentials +carbon config carbon.credentials.vsphere_server.provider vsphere +carbon config carbon.credentials.vsphere_server.username vsphere_user@vsphere.example +carbon config carbon.credentials.vsphere_server.password_command 'op read op://Private/vSphere Creds/password' - carbon config carbon.credentials.vsphere_server.provider vsphere - carbon config carbon.credentials.vsphere_server.username vsphere_user@vsphere.example - carbon config carbon.credentials.vsphere_server.password_command 'op read op://Private/vSphere Creds/password' +# Set a default project directory +carbon config carbon.default.dir ~/my/path/haxors `, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - keys := getKeys(viper.AllSettings(), "") + keys := getConfigKeys() return keys, cobra.ShellCompDirectiveNoFileComp }, Args: cobra.RangeArgs(0, 3), @@ -216,7 +223,7 @@ func splitIntoParentChild(key string) (string, string) { } func init() { - RootCmd.AddCommand(configCmd) + CarbonCmd.AddCommand(configCmd) configCmd.Flags().BoolP("save", "s", false, "save the current configuration") configCmd.Flags().BoolP("sub-keys", "k", false, "display only the sub-keys") configCmd.Flags().BoolP("remove-reset", "r", false, "remove key from the config or reset to default") @@ -225,10 +232,25 @@ func init() { func getKeys(config map[string]any, prefix string) []string { var keys []string for k, val := range config { - keys = append(keys, fmt.Sprintf("%s%s", prefix, k)) if mapVal, ok := val.(map[string]interface{}); ok { keys = append(keys, getKeys(mapVal, fmt.Sprintf("%s%s.", prefix, k))...) + } else { + keys = append(keys, fmt.Sprintf("%s%s", prefix, k)) } } return keys } + +var configKeys []string + +func getConfigKeys() []string { + if len(configKeys) == 0 { + configKeys = getKeys(viper.AllSettings(), "") + sort.Strings(configKeys) + } + return configKeys +} + +func updateConfigHelp() { + configCmd.Long += fmt.Sprintf("## Configuration keys\n- %s", strings.Join(getConfigKeys(), "\n - ")) +} diff --git a/pkg/cmd/dev.go b/pkg/cmd/dev.go index c7f75e8..5765a85 100644 --- a/pkg/cmd/dev.go +++ b/pkg/cmd/dev.go @@ -16,5 +16,5 @@ var devCmd = &cobra.Command{ } func init() { - RootCmd.AddCommand(devCmd) + CarbonCmd.AddCommand(devCmd) } diff --git a/pkg/cmd/dev_vm.go b/pkg/cmd/dev_vm.go deleted file mode 100644 index 14874af..0000000 --- a/pkg/cmd/dev_vm.go +++ /dev/null @@ -1,26 +0,0 @@ -package cmd - -import ( - "fmt" - "github.com/spf13/cobra" -) - -// devVMCmd represents the new command -var devVMCmd = &cobra.Command{ - Use: "vm", - Short: "list vms.", - Long: `list vms`, - Run: func(cmd *cobra.Command, args []string) { - for _, profiles := range carbonObj.Profiles() { - for _, env := range profiles.Environments() { - for _, vm := range env.VMs() { - fmt.Printf("%s / %s: %s (%s)\n", profiles.Name(), env.Name(), vm.Name(), vm.State()) - } - } - } - }, -} - -func init() { - devCmd.AddCommand(devVMCmd) -} diff --git a/pkg/cmd/image.go b/pkg/cmd/image.go index 1fc99b1..1165738 100644 --- a/pkg/cmd/image.go +++ b/pkg/cmd/image.go @@ -7,10 +7,10 @@ import ( // imageCmd represents the image command var imageCmd = &cobra.Command{ Use: "image", - Short: "manage images and image builds", - Long: `manage images and image builds`, + Short: "View or manage images and image builds.", + Long: `View or manage images and image builds.`, } func init() { - RootCmd.AddCommand(imageCmd) + CarbonCmd.AddCommand(imageCmd) } diff --git a/pkg/cmd/image_boostrap.go b/pkg/cmd/image_boostrap.go index 09e7167..46e4812 100644 --- a/pkg/cmd/image_boostrap.go +++ b/pkg/cmd/image_boostrap.go @@ -7,14 +7,10 @@ import ( // imageBootstrapCmd represents the image command var imageBootstrapCmd = &cobra.Command{ - Use: "bootstrap", - Short: "create image build configs", - Long: `create image build configs. -Example - - carbon image bootstrap -n operator-desktop-aws -s aws -t ubuntu-desktop - -`, + Use: "bootstrap", + Short: "Create packer files and other image build configs.", + Long: `Create packer files and other image build configs.`, + Example: `carbon image bootstrap -n operator-desktop-aws -s aws -t ubuntu-desktop`, Run: func(cmd *cobra.Command, args []string) { name, _ := cmd.Flags().GetString("name") osDir, _ := cmd.Flags().GetString("template") diff --git a/pkg/cmd/image_build.go b/pkg/cmd/image_build.go index ba437ef..fa92587 100644 --- a/pkg/cmd/image_build.go +++ b/pkg/cmd/image_build.go @@ -7,14 +7,10 @@ import ( // imageBuildCmd represents the image command var imageBuildCmd = &cobra.Command{ - Use: "build", - Short: "build an image", - Long: `build an image. -Example - - carbon image build -m ubuntu-desktop -t qemu - -`, + Use: "build", + Short: "Build an image.", + Long: `build an image.`, + Example: `carbon image build -t aws -n operator-desktop-aws`, Run: func(cmd *cobra.Command, args []string) { name, _ := cmd.Flags().GetString("name") provider, _ := cmd.Flags().GetString("provider-type") diff --git a/pkg/cmd/image_destroy.go b/pkg/cmd/image_destroy.go index b1a96f5..93e6b5d 100644 --- a/pkg/cmd/image_destroy.go +++ b/pkg/cmd/image_destroy.go @@ -7,14 +7,10 @@ import ( // imageDestroyCmd represents the image command var imageDestroyCmd = &cobra.Command{ - Use: "destroy", - Short: "destroy/delete images", - Long: `destroy/delete images. -Example - - carbon image destroy -i qemu/some-image-123123123 - -`, + Use: "destroy", + Short: "Delete images.", + Long: `Delete images.`, + Example: `carbon image destroy -i qemu/some-image-123123123`, Run: func(cmd *cobra.Command, args []string) { imageID, _ := cmd.Flags().GetString("image-id") diff --git a/pkg/cmd/image_list.go b/pkg/cmd/image_list.go index e7ce4b0..f82f19c 100644 --- a/pkg/cmd/image_list.go +++ b/pkg/cmd/image_list.go @@ -3,21 +3,24 @@ package cmd import ( "encoding/json" "fmt" - "github.com/jedib0t/go-pretty/v6/table" + "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/lipgloss/table" "github.com/spf13/cobra" "os" + "strings" ) // imageListCmd represents the image command var imageListCmd = &cobra.Command{ Use: "list", Short: "list images", - Long: `list images and image builds. -Example + Long: `list images and image builds.`, + Example: `# List all images +carbon image list - carbon image list - carbon image list -b +#list image builds +carbon image list -b `, Run: func(cmd *cobra.Command, args []string) { listBuilds, _ := cmd.Flags().GetBool("builds") @@ -53,8 +56,20 @@ Example } else { - t := table.NewWriter() - t.SetOutputMirror(os.Stdout) + re := lipgloss.NewRenderer(os.Stdout) + baseStyle := re.NewStyle().Padding(0, 1) + headerStyle := baseStyle.Foreground(lipgloss.Color("252")).Bold(true) + + CapitalizeHeaders := func(data []string) []string { + for i := range data { + data[i] = strings.ToUpper(data[i]) + } + return data + } + + data := [][]string{} + + var headers []string if listBuilds { imagesBuilds, err := carbonObj.GetImageBuilds() @@ -62,15 +77,12 @@ Example log.Info("failed to list image builds", "err", err) os.Exit(2) } - t.AppendHeader(table.Row{"Name", "Provisioner", "Provider"}) - + headers = []string{"Name", "Provisioner", "Provider"} for _, imageBuild := range imagesBuilds { - t.AppendRows([]table.Row{ - { - imageBuild.Name(), - imageBuild.Provisioner(), - imageBuild.ProviderType(), - }, + data = append(data, []string{ + imageBuild.Name(), + imageBuild.Provisioner(), + imageBuild.ProviderType(), }) } } else { @@ -80,23 +92,41 @@ Example log.Info("failed to list images", "err", err) os.Exit(2) } - t.AppendHeader(table.Row{"Name", "Created", "Env", "Profile", "Provider", "ID"}) + + headers = []string{"Name", "Created", "Env", "Profile", "Provider", "ID"} for _, image := range images { - t.AppendRows([]table.Row{ - { - image.Name(), - image.CreatedAt(), - image.Environment().Name(), - image.Environment().Profile().Name(), - image.Environment().Profile().Provider().Name(), - image.ID(), - }, + data = append(data, []string{ + image.Name(), + image.CreatedAt(), + image.Environment().Name(), + image.Environment().Profile().Name(), + image.Environment().Profile().Provider().Name(), + image.ID(), }) } } - t.Render() + + ct := table.New(). + Border(lipgloss.NormalBorder()). + BorderStyle(re.NewStyle().Foreground(lipgloss.Color("238"))). + Headers(CapitalizeHeaders(headers)...). + Rows(data...). + StyleFunc(func(row, col int) lipgloss.Style { + if row == 0 { + return headerStyle + } + + even := row%2 == 0 + + if even { + return baseStyle.Foreground(lipgloss.Color("245")) + } + return baseStyle.Foreground(lipgloss.Color("252")) + }) + fmt.Println(ct) + } }, } diff --git a/pkg/cmd/project.go b/pkg/cmd/project.go index 836ad6a..754eee1 100644 --- a/pkg/cmd/project.go +++ b/pkg/cmd/project.go @@ -12,13 +12,10 @@ var projectCmd = &cobra.Command{ Long: `Manage projects. Projects are directories with terraform code to manage resources for the project. `, - //Run: func(cmd *cobra.Command, args []string) { - // - //}, } func init() { - RootCmd.AddCommand(projectCmd) + CarbonCmd.AddCommand(projectCmd) projectCmd.PersistentFlags().StringP("project", "p", "", "Name of the project.") diff --git a/pkg/cmd/project_add.go b/pkg/cmd/project_add_machine.go similarity index 87% rename from pkg/cmd/project_add.go rename to pkg/cmd/project_add_machine.go index 8bd9021..54f7d1f 100644 --- a/pkg/cmd/project_add.go +++ b/pkg/cmd/project_add_machine.go @@ -8,15 +8,10 @@ import ( // projectAddCmd represents the config command var projectAddCmd = &cobra.Command{ - Use: "add-machine", - Short: "Add resources to a project", - Long: `Add a new machine to the project. - -Example: - - carbon project add -p example-qemu-carbon -n testbrad2 -P qemu -i carbon-ubuntu-desktop-20241008201758 - -`, + Use: "add-machine", + Short: "Add a new machine to a project", + Long: `Add a new machine to the project.`, + Example: `carbon project add-machine -p example-qemu-carbon -n modlishka -P qemu -i carbon-ubuntu-desktop-20241008201758`, Run: func(cmd *cobra.Command, args []string) { projectName, _ := cmd.Flags().GetString("project") vmName, _ := cmd.Flags().GetString("name") diff --git a/pkg/cmd/project_apply.go b/pkg/cmd/project_apply.go index ebeebc1..b3a8e3b 100644 --- a/pkg/cmd/project_apply.go +++ b/pkg/cmd/project_apply.go @@ -8,15 +8,10 @@ import ( // projectApplyCmd represents the config command var projectApplyCmd = &cobra.Command{ - Use: "apply", - Short: "Run terraform apply", - Long: `Apply terraform. - -Example: - - carbon project apply -p project-name - -`, + Use: "apply", + Short: "Run terraform apply", + Long: `Apply terraform. No need to change dirs.`, + Example: `carbon project apply -p project-name`, Run: func(cmd *cobra.Command, args []string) { name, _ := cmd.Flags().GetString("project") diff --git a/pkg/cmd/project_list.go b/pkg/cmd/project_list.go index e9e16f9..631e48e 100644 --- a/pkg/cmd/project_list.go +++ b/pkg/cmd/project_list.go @@ -8,15 +8,10 @@ import ( // projectListCmd represents the config command var projectListCmd = &cobra.Command{ - Use: "list", - Short: "Manage and interact with projects", - Long: `List projects. - -Example: - - carbon project list - -`, + Use: "list", + Short: "Manage and interact with projects", + Long: `List projects.`, + Example: `carbon project list`, Run: func(cmd *cobra.Command, args []string) { deployments, err := carbonObj.GetProjects() if err != nil { diff --git a/pkg/cmd/vm.go b/pkg/cmd/vm.go index 92c2552..059ef21 100644 --- a/pkg/cmd/vm.go +++ b/pkg/cmd/vm.go @@ -4,33 +4,22 @@ import ( "fmt" "github.com/analog-substance/carbon/pkg/types" "github.com/charmbracelet/huh" - "github.com/jedib0t/go-pretty/v6/table" + "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/lipgloss/table" "github.com/spf13/cobra" "os" + "strings" ) // vmCmd represents the config command var vmCmd = &cobra.Command{ Use: "vm", - Short: "Manage and interact with VMs", - Long: `Manage and interact with VMs. - -Management functions include - -- Starting VMs -- Stopping VMs -- Rebooting VMs -- Launching VMs from images -- Destroying VMs from images - -`, - //Run: func(cmd *cobra.Command, args []string) { - // fmt.Println("vm called") - //}, + Short: "Manage and interact with VMs.", + Long: `Manage and interact with VMs.`, } func init() { - RootCmd.AddCommand(vmCmd) + CarbonCmd.AddCommand(vmCmd) vmCmd.PersistentFlags().StringP("name", "n", "", "Name of the VM.") vmCmd.PersistentFlags().StringP("id", "i", "", "ID of machine to start.") @@ -95,10 +84,33 @@ func AskIfSure(msg string) bool { } func vmTable(vms []types.VM) { - t := table.NewWriter() - t.SetOutputMirror(os.Stdout) - t.AppendHeader(table.Row{"Name", "IP", "State", "Up Time", "Type", "Environment", "Profile", "Provider"}) + re := lipgloss.NewRenderer(os.Stdout) + baseStyle := re.NewStyle().Padding(0, 1) + headerStyle := baseStyle.Foreground(lipgloss.Color("252")).Bold(true) + typeColors := map[string]lipgloss.Color{ + "Running": lipgloss.Color("#D7FF87"), + "QEMU": lipgloss.Color("#FDFF90"), + "AWS": lipgloss.Color("#FF875F"), + "VirtualBox": lipgloss.Color("#FF87D7"), + } + dimTypeColors := map[string]lipgloss.Color{ + "Running": lipgloss.Color("#97AD64"), + "QEMU": lipgloss.Color("#FCFF5F"), + "AWS": lipgloss.Color("#C77252"), + "VirtualBox": lipgloss.Color("#C97AB2"), + } + + headers := []string{"Name", "IP", "State", "Up Time", "Type", "Environment", "Profile", "Provider"} + + CapitalizeHeaders := func(data []string) []string { + for i := range data { + data[i] = strings.ToUpper(data[i]) + } + return data + } + + data := [][]string{} for _, vm := range vms { var name string if vm.ID() == vm.Name() { @@ -106,21 +118,47 @@ func vmTable(vms []types.VM) { } else { name = fmt.Sprintf("%s (%s)", vm.Name(), vm.ID()) } - t.AppendRows([]table.Row{ - { - name, - vm.IPAddress(), - vm.State(), - vm.UpTime(), - vm.Type(), - vm.Environment().Name(), - vm.Profile().Name(), - vm.Provider().Name(), - }, + data = append(data, []string{ + name, + vm.IPAddress(), + vm.State(), + vm.UpTime().String(), + vm.Type(), + vm.Environment().Name(), + vm.Profile().Name(), + vm.Provider().Name(), }) } - t.Render() + ct := table.New(). + Border(lipgloss.NormalBorder()). + BorderStyle(re.NewStyle().Foreground(lipgloss.Color("238"))). + Headers(CapitalizeHeaders(headers)...). + Rows(data...). + StyleFunc(func(row, col int) lipgloss.Style { + if row == 0 { + return headerStyle + } + + even := row%2 == 0 + + switch col { + case 2, 7: // Type 1 + 2 + c := typeColors + if even { + c = dimTypeColors + } + + color := c[fmt.Sprint(data[row-1][col])] + return baseStyle.Foreground(color) + } + + if even { + return baseStyle.Foreground(lipgloss.Color("245")) + } + return baseStyle.Foreground(lipgloss.Color("252")) + }) + fmt.Println(ct) } diff --git a/pkg/cmd/vm_destroy.go b/pkg/cmd/vm_destroy.go index 0e333a3..64c3fa4 100644 --- a/pkg/cmd/vm_destroy.go +++ b/pkg/cmd/vm_destroy.go @@ -7,15 +7,10 @@ import ( // vmDestroyCmd represents the image command var vmDestroyCmd = &cobra.Command{ - Use: "destroy", - Short: "destroy VM", - Long: `Destroy a VM. - -Example: - - carbon vm destroy -n vm-name - -`, + Use: "destroy", + Short: "destroy VM", + Long: `Destroy a VM.`, + Example: `carbon vm destroy -n vm-name`, Run: func(cmd *cobra.Command, args []string) { vms := getVMsFromArgs(cmd, args) if len(vms) > 0 { diff --git a/pkg/cmd/vm_launch.go b/pkg/cmd/vm_launch.go index 8387c50..870bdd2 100644 --- a/pkg/cmd/vm_launch.go +++ b/pkg/cmd/vm_launch.go @@ -7,15 +7,10 @@ import ( // vmLaunchCmd represents the image command var vmLaunchCmd = &cobra.Command{ - Use: "launch", - Short: "launch a new vm from an image", - Long: `launch a new vm from an image. - -Example: - - carbon vm launch -I qemu/carbon-ubuntu-desktop-20241007212910 -n vm-name - -`, + Use: "launch", + Short: "launch a new vm from an image", + Long: `launch a new vm from an image.`, + Example: `carbon vm launch -I qemu/carbon-ubuntu-desktop-20241007212910 -n vm-name`, Run: func(cmd *cobra.Command, args []string) { name, _ := cmd.Flags().GetString("name") imageID, _ := cmd.Flags().GetString("image-id") diff --git a/pkg/cmd/vm_list.go b/pkg/cmd/vm_list.go index 752bcae..cc1915d 100644 --- a/pkg/cmd/vm_list.go +++ b/pkg/cmd/vm_list.go @@ -9,19 +9,14 @@ import ( // vmList represents the config command var vmList = &cobra.Command{ Use: "list", - Short: "List VMs", - Long: `List VMs. + Short: "List VMs across all available providers, profiles, and environments.", + Long: `List VMs across all available providers, profiles, and environments.`, + Example: `# list all virtual machines +carbon vm list -Example: - - carbon vm list - -You can also supply a name search: - - carbon vm list -n vm- - -This will list VMs with vm- in their name. +# You can also supply a name search, this wil return VMs with names containing 'vm-' +carbon vm list -n vm- `, Run: func(cmd *cobra.Command, args []string) { diff --git a/pkg/cmd/vm_restart.go b/pkg/cmd/vm_restart.go index cd7d0c2..286fb4a 100644 --- a/pkg/cmd/vm_restart.go +++ b/pkg/cmd/vm_restart.go @@ -7,15 +7,10 @@ import ( // vmRestart represents the config command var vmRestart = &cobra.Command{ - Use: "restart", - Short: "Restart VM(s)", - Long: `Restart VM(s). - -Example: - - carbon vm restart -n vm-name - -`, + Use: "restart", + Short: "Restart VM(s)", + Long: `Restart VM(s).`, + Example: `carbon vm restart -n vm-name`, Run: func(cmd *cobra.Command, args []string) { vms := getVMsFromArgs(cmd, args) if len(vms) > 0 { diff --git a/pkg/cmd/vm_ssh.go b/pkg/cmd/vm_ssh.go index a29e49b..1a1ae5d 100644 --- a/pkg/cmd/vm_ssh.go +++ b/pkg/cmd/vm_ssh.go @@ -12,13 +12,27 @@ var vmSSH = &cobra.Command{ Use: "ssh", Short: "SSH to a VM", Long: `SSH to a VM. +Carbon will call exec on the ssh binary. This means the SSH process takes +over the carbon process. So SSH agents should just work. +`, + Example: `# SSH to a VM +carbon vm ssh -n vm-name -Example: - carbon vm ssh -n vm-name +# execute one off command on a VM +carbon vm ssh -n vm-name -- cat /etc/passwd -Carbon will call exec on the ssh binary. This means the SSH process takes -over the carbon process. So SSH agents should just work. + +# proxy through a bastion +carbon vm ssh -n vm-name -- -oProxyCommand="carbon vm ssh -n bastion -- -W %h:%p" + + +# forward ssh agent +carbon vm ssh -n vm-name -- -A + + +# open socks proxy +carbon vm ssh -n vm-name -- -D 1080 `, Run: func(cmd *cobra.Command, args []string) { user, _ := cmd.Flags().GetString("user") diff --git a/pkg/cmd/vm_start.go b/pkg/cmd/vm_start.go index c5530e8..a18acd1 100644 --- a/pkg/cmd/vm_start.go +++ b/pkg/cmd/vm_start.go @@ -7,15 +7,10 @@ import ( // vmStart represents the config command var vmStart = &cobra.Command{ - Use: "start", - Short: "Start VMs", - Long: `start VMs. - -Example: - - carbon vm start -n vm-name - -`, + Use: "start", + Short: "Start VMs", + Long: `start VMs.`, + Example: `carbon vm start -n vm-name`, Run: func(cmd *cobra.Command, args []string) { vms := getVMsFromArgs(cmd, args) if len(vms) > 0 { diff --git a/pkg/cmd/vm_stop.go b/pkg/cmd/vm_stop.go index 734d8be..4552184 100644 --- a/pkg/cmd/vm_stop.go +++ b/pkg/cmd/vm_stop.go @@ -11,12 +11,9 @@ var vmStop = &cobra.Command{ Short: "Stop VM(s)", Long: `Stop VM(s). -Example: - - carbon vm stop -n vm-name - By default, carbon will attempt to hibernate the machine rather than power it off. `, + Example: `carbon vm start -n vm-name`, Run: func(cmd *cobra.Command, args []string) { vms := getVMsFromArgs(cmd, args) if len(vms) > 0 { diff --git a/pkg/cmd/vm_vnc.go b/pkg/cmd/vm_vnc.go index 2756dba..67946a8 100644 --- a/pkg/cmd/vm_vnc.go +++ b/pkg/cmd/vm_vnc.go @@ -10,12 +10,8 @@ var vmVNCCmd = &cobra.Command{ Use: "vnc", Short: "VNC to a VM", Long: `VNC to a VM. - -Example: - - carbon vm vnc -n vm-name - This will: + - SSH to the target VM. - Check to see if vncserver is running. - If not, start vncserver on the remote machine @@ -24,6 +20,7 @@ This will: - Setup a tunnel to access vnc - start vncviewer `, + Example: `carbon vnc start -n vm-name`, Run: func(cmd *cobra.Command, args []string) { user, _ := cmd.Flags().GetString("user") killVNC, _ := cmd.Flags().GetBool("kill-vnc") diff --git a/pkg/providers/qemu/api/qemu.go b/pkg/providers/qemu/api/qemu.go index bec0819..5755f7a 100644 --- a/pkg/providers/qemu/api/qemu.go +++ b/pkg/providers/qemu/api/qemu.go @@ -13,7 +13,6 @@ type QEMU struct { libVirtURL string conn *libvirt.Libvirt - leaseMap map[string][]string allNets []libvirt.Network domains []*Domain storagePools []*StoragePool