Skip to content

Commit

Permalink
docs(clustertool): add more in-code documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
PrivatePuffin committed Oct 25, 2024
1 parent e09a48e commit 9d93573
Show file tree
Hide file tree
Showing 28 changed files with 90 additions and 79 deletions.
1 change: 1 addition & 0 deletions clustertool/cmd/adv.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ These are all advanced commands that should generally not be needed
var adv = &cobra.Command{
Use: "adv",
Short: "Advanced cluster maintanence commands",
Example: "clustertool adv <bootstrap/health/precommit>",
Long: advLongHelp,
SilenceUsage: true,
SilenceErrors: true,
Expand Down
9 changes: 5 additions & 4 deletions clustertool/cmd/adv_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ var advBootstrapLongHelp = strings.TrimSpace(`
`)

var bootstrap = &cobra.Command{
Use: "bootstrap",
Short: "bootstrap first Talos Node",
Long: advBootstrapLongHelp,
Run: bootstrapfunc,
Use: "bootstrap",
Short: "bootstrap first Talos Node",
Example: "clustertool adv bootstrap",
Long: advBootstrapLongHelp,
Run: bootstrapfunc,
}

func bootstrapfunc(cmd *cobra.Command, args []string) {
Expand Down
7 changes: 4 additions & 3 deletions clustertool/cmd/adv_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ var advHealthLongHelp = strings.TrimSpace(`
`)

var health = &cobra.Command{
Use: "health",
Short: "Check Talos Cluster Health",
Long: advHealthLongHelp,
Use: "health",
Short: "Check Talos Cluster Health",
Example: "clustertool adv health",
Long: advHealthLongHelp,
Run: func(cmd *cobra.Command, args []string) {
if err := sops.DecryptFiles(); err != nil {
log.Info().Msgf("Error decrypting files: %v\n", err)
Expand Down
7 changes: 4 additions & 3 deletions clustertool/cmd/adv_precommit.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ var advPrecommitLongHelp = strings.TrimSpace(`
`)

var precommit = &cobra.Command{
Use: "precommit",
Short: "Runs the PreCommit encryption check",
Long: advPrecommitLongHelp,
Use: "precommit",
Short: "Runs the PreCommit encryption check",
Example: "clustertool adv precommit",
Long: advPrecommitLongHelp,
Run: func(cmd *cobra.Command, args []string) {
if err := sops.CheckFilesAndReportEncryption(true, true); err != nil {
log.Info().Msgf("Error checking files: %v\n", err)
Expand Down
7 changes: 4 additions & 3 deletions clustertool/cmd/adv_reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ var advResetLongHelp = strings.TrimSpace(`
`)

var reset = &cobra.Command{
Use: "reset",
Short: "Reset Talos Nodes and Kubernetes",
Long: advResetLongHelp,
Use: "reset",
Short: "Reset Talos Nodes and Kubernetes",
Example: "clustertool adv reset <NodeIP>",
Long: advResetLongHelp,
Run: func(cmd *cobra.Command, args []string) {
var extraArgs []string
node := ""
Expand Down
4 changes: 2 additions & 2 deletions clustertool/cmd/adv_testcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
)

var advTestCmdlongHelp = strings.TrimSpace(`
This command is mostly just for development usage and should NEVER be used by end-users.
`)

var testcmd = &cobra.Command{
Use: "test",
Short: "test run",
Short: "tests specific code for developer usages",
Long: advTestCmdlongHelp,
Run: func(cmd *cobra.Command, args []string) {
initfiles.LoadTalEnv(false)
Expand Down
7 changes: 4 additions & 3 deletions clustertool/cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ var applyLongHelp = strings.TrimSpace(`
`)

var apply = &cobra.Command{
Use: "apply",
Short: "apply TalosConfig",
Long: applyLongHelp,
Use: "apply",
Short: "apply TalosConfig",
Example: "clustertool apply <NodeIP>",
Long: applyLongHelp,
Run: func(cmd *cobra.Command, args []string) {
var extraArgs []string
node := ""
Expand Down
9 changes: 4 additions & 5 deletions clustertool/cmd/charts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import (
)

var chartsLongHelp = strings.TrimSpace(`
charttool is a tool to help you build TrueCharts Charts
charttool was a tool to help you build TrueCharts Charts.
It has since been merged into Clustertool as "clustertool charts"
Workflow:
Create talconfig.yaml file defining your nodes information like so:
Available commands
Example commands
> charttool bump 1.2.3 patch
> charttool tagclean soemtag@somedigest
Expand All @@ -21,6 +19,7 @@ Workflow:
var charts = &cobra.Command{
Use: "charts",
Short: "A tool to help with creating Talos cluster",
Example: "charttool bump 1.2.3 patch",
Long: chartsLongHelp,
SilenceUsage: true,
SilenceErrors: true,
Expand Down
2 changes: 1 addition & 1 deletion clustertool/cmd/charts_bump.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var bumper = &cobra.Command{
Use: "bump",
Short: "generate a bumped image version",
Long: chartsBumpLongHelp,
Example: "charttool bump <version> <kind>",
Example: "clustertool charts bump <version> <kind>",
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
if err := version.Bump(args[0], args[1]); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion clustertool/cmd/charts_deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var depsCmd = &cobra.Command{
Use: "deps",
Short: "Download, Update and Verify Helm dependencies",
Long: chartsDepsLongHelp,
Example: "charttool deps <chart> <chart> <chart>",
Example: "clustertool charts deps <chart> <chart> <chart>",
Run: func(cmd *cobra.Command, args []string) {
if err := deps.LoadGPGKey(); err != nil {
log.Fatal().Err(err).Msg("failed to load gpg key")
Expand Down
2 changes: 1 addition & 1 deletion clustertool/cmd/charts_genchangelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var genChangelogCmd = &cobra.Command{
Use: "genchangelog",
Short: "Generate changelog for charts",
Long: chartsGenChangelogLongHelp,
Example: "charttool genchangelog <repo path> <template path> <charts dir>",
Example: "clustertool charts genchangelog <repo path> <template path> <charts dir>",
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 3 {
log.Fatal().Msg("Missing required arguments. Please provide the repo path, template path and charts directory.")
Expand Down
2 changes: 1 addition & 1 deletion clustertool/cmd/charts_genchartlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var genChartListCmd = &cobra.Command{
Use: "genchartlist",
Short: "Generate chart list json file",
Long: chartsGenChartsListLongHelp,
Example: "charttool genchartlist <path to charts folder>",
Example: "clustertool charts genchartlist <path to charts folder>",
Run: func(cmd *cobra.Command, args []string) {
opts := &website.ChartListOptions{
OutputPath: "./charts.json",
Expand Down
7 changes: 4 additions & 3 deletions clustertool/cmd/charts_genmeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ var chartsGenMetaLongHelp = strings.TrimSpace(`
`)

var genMetaCmd = &cobra.Command{
Use: "genmeta",
Short: "Generate and update Chart.yaml metadata",
Long: chartsGenMetaLongHelp,
Use: "genmeta",
Short: "Generate and update Chart.yaml metadata",
Example: "clustertool charts genmeta",
Long: chartsGenMetaLongHelp,
Run: func(cmd *cobra.Command, args []string) {
bump := ""
if len(args) > 0 && slices.Contains([]string{"patch", "minor", "major"}, args[0]) {
Expand Down
2 changes: 1 addition & 1 deletion clustertool/cmd/charts_tagclean.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var tagCleaner = &cobra.Command{
Use: "tagcleaner",
Short: "Creates a clean version tag from a container digest",
Long: chartsTagCleanLongHelp,
Example: "charttool tagcleaner <tag>",
Example: "clustertool charts tagclean <tag>",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
err := image.Clean(args[0])
Expand Down
7 changes: 4 additions & 3 deletions clustertool/cmd/checkcrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ var checkcyptLongHelp = strings.TrimSpace(`
`)

var checkcrypt = &cobra.Command{
Use: "checkcrypt",
Short: "Checks if all files are encrypted correctly in accordance with .sops.yaml",
Long: checkcyptLongHelp,
Use: "checkcrypt",
Short: "Checks if all files are encrypted correctly in accordance with .sops.yaml",
Example: "clustertool checkcrypt",
Long: checkcyptLongHelp,
Run: func(cmd *cobra.Command, args []string) {
if err := sops.CheckFilesAndReportEncryption(false, false); err != nil {
log.Info().Msgf("Error checking files: %v\n", err)
Expand Down
7 changes: 4 additions & 3 deletions clustertool/cmd/decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ var decryptLongHelp = strings.TrimSpace(`
`)

var decrypt = &cobra.Command{
Use: "decrypt",
Short: "Decrypt all high-risk data using sops",
Long: decryptLongHelp,
Use: "decrypt",
Short: "Decrypt all high-risk data using sops",
Example: "clustertool decrypt",
Long: decryptLongHelp,
Run: func(cmd *cobra.Command, args []string) {
if err := sops.DecryptFiles(); err != nil {
log.Info().Msgf("Error decrypting files: %v\n", err)
Expand Down
7 changes: 4 additions & 3 deletions clustertool/cmd/encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ var encryptLongHelp = strings.TrimSpace(`
`)

var encrypt = &cobra.Command{
Use: "encrypt",
Short: "Encrypt all high-risk data using sops",
Long: encryptLongHelp,
Use: "encrypt",
Short: "Encrypt all high-risk data using sops",
Example: "clustertool encrypt",
Long: encryptLongHelp,
Run: func(cmd *cobra.Command, args []string) {
if err := sops.EncryptAllFiles(); err != nil {
log.Info().Msgf("Error encrypting files: %v\n", err)
Expand Down
7 changes: 4 additions & 3 deletions clustertool/cmd/fluxbootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ var fluxBootstrapLongHelp = strings.TrimSpace(`
`)

var fluxbootstrap = &cobra.Command{
Use: "fluxbootstrap",
Short: "Manually bootstrap fluxcd on existing cluster",
Long: fluxBootstrapLongHelp,
Use: "fluxbootstrap",
Short: "Manually bootstrap fluxcd on existing cluster",
Example: "clustertool fluxbootstrap",
Long: fluxBootstrapLongHelp,
Run: func(cmd *cobra.Command, args []string) {
ctx := context.Background()

Expand Down
5 changes: 3 additions & 2 deletions clustertool/cmd/helmrelease.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (
)

var helmreleaseHelp = strings.TrimSpace(`
A toolkit to load helm-release files onto a cluster without flux
A toolkit to load helm-release files onto a cluster without flux.
originally created to make it easier to install/upgrade/edit flux-based clusterresources without flux
`)

var helmrelease = &cobra.Command{
Use: "helmrelease",
Short: "A toolkit to load helm-release files onto a cluster without flux",
Example: "clustertool helmrelease <install/upgrade>",
Long: advLongHelp,
SilenceUsage: true,
SilenceErrors: true,
Expand Down
7 changes: 4 additions & 3 deletions clustertool/cmd/helmrelease_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ var hrInstalLongHelp = strings.TrimSpace(`
`)

var hrinstall = &cobra.Command{
Use: "install",
Short: "install a helm-release file without flux, helm-release file needs to be called helm-release.yaml",
Long: hrInstalLongHelp,
Use: "install",
Short: "install a helm-release file without flux, helm-release file needs to be called helm-release.yaml",
Example: "clustertool helmrelease install",
Long: hrInstalLongHelp,
Run: func(cmd *cobra.Command, args []string) {
initfiles.LoadTalEnv(false)

Expand Down
7 changes: 4 additions & 3 deletions clustertool/cmd/helmrelease_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ var hrUpgradeLongHelp = strings.TrimSpace(`
`)

var hrupgrade = &cobra.Command{
Use: "upgrade",
Short: "run helm-upgrade using a helm-release file without flux",
Long: hrUpgradeLongHelp,
Use: "upgrade",
Short: "run helm-upgrade using a helm-release file without flux",
Example: "clustertool helmrelease upgrade",
Long: hrUpgradeLongHelp,
Run: func(cmd *cobra.Command, args []string) {
initfiles.LoadTalEnv(false)

Expand Down
9 changes: 9 additions & 0 deletions clustertool/cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ import (
)

var infoLongHelp = strings.TrimSpace(`
clustertool is a tool to help you easily deploy and maintain a Talos Kubernetes Cluster.
Workflow:
Create talconfig.yaml file defining your nodes information like so:
Available commands
> clustertool init
> clustertool genconfig
`)

Expand Down
1 change: 0 additions & 1 deletion clustertool/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Afterwards you can edit talconfig.yaml and clusterenv.yaml to reflect your perso
When done, please run clustertool genconfig to generate all configarion based on your personal settings
Powered by TalHelper (https://budimanjojo.github.io/talhelper/)
`)

Expand Down
18 changes: 1 addition & 17 deletions clustertool/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"os"
"path/filepath"
"strings"

"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
Expand All @@ -12,25 +11,10 @@ import (

var thisversion string

var rootLongHelp = strings.TrimSpace(`
clustertool is a tool to help you easily deploy and maintain a Talos Kubernetes Cluster.
Workflow:
Create talconfig.yaml file defining your nodes information like so:
Available commands
> clustertool init
> clustertool genconfig
Powered by TalHelper (https://budimanjojo.github.io/talhelper/)
`)

var RootCmd = &cobra.Command{
Use: "clustertool",
Short: "A tool to help with creating Talos cluster",
Long: rootLongHelp,
Long: infoLongHelp,
SilenceUsage: true,
SilenceErrors: true,
Version: thisversion,
Expand Down
5 changes: 4 additions & 1 deletion clustertool/cmd/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import (
)

var scaleLongHelp = strings.TrimSpace(`
These are all advanced commands that should generally not be needed
These are all commands that are exclusively intended to migrate away from TrueNAS SCALE Kubernetes Apps to a normal kubernets cluster.
They will all, at a later date, be removed.
`)

var scaleCmd = &cobra.Command{
Use: "scale",
Short: "Commands for handling TrueNAS SCALE",
Example: "clustertool scale export",
Long: advLongHelp,
SilenceUsage: true,
SilenceErrors: true,
Expand Down
7 changes: 4 additions & 3 deletions clustertool/cmd/scale_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ var scaleExportLongHelp = strings.TrimSpace(`
`)

var scaleexport = &cobra.Command{
Use: "export",
Short: "Export SCALE Apps to file",
Long: scaleExportLongHelp,
Use: "export",
Short: "Export SCALE Apps to file",
Example: "clustertool scale export",
Long: scaleExportLongHelp,
Run: func(cmd *cobra.Command, args []string) {
scale.ExportApps()
},
Expand Down
7 changes: 4 additions & 3 deletions clustertool/cmd/scale_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ var scaleMigrateLongHelp = strings.TrimSpace(`
`)

var scalemigrate = &cobra.Command{
Use: "migrate",
Short: "Migrate exported SCALE Apps to the Talos Cluster",
Long: scaleMigrateLongHelp,
Use: "migrate",
Short: "Migrate exported SCALE Apps to the Talos Cluster",
Example: "clustertool scale migrate",
Long: scaleMigrateLongHelp,
Run: func(cmd *cobra.Command, args []string) {
err := scale.ProcessJSONFiles("./truenas_exports")
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions clustertool/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ var upgradeLongHelp = strings.TrimSpace(`
`)

var upgrade = &cobra.Command{
Use: "upgrade",
Short: "Upgrade Talos Nodes and Kubernetes",
Long: upgradeLongHelp,
Use: "upgrade",
Short: "Upgrade Talos Nodes and Kubernetes",
Example: "clustertool upgrade <NodeIP>",
Long: upgradeLongHelp,
Run: func(cmd *cobra.Command, args []string) {
var extraArgs []string
node := ""
Expand Down

0 comments on commit 9d93573

Please sign in to comment.