chore(clustertool): prep for more longer description texts

This commit is contained in:
Kjeld Schouten
2024-10-25 18:14:20 +02:00
parent 203b451127
commit e09a48e770
23 changed files with 175 additions and 40 deletions
+7
View File
@@ -1,13 +1,20 @@
package cmd
import (
"strings"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/gencmd"
)
var advBootstrapLongHelp = strings.TrimSpace(`
`)
var bootstrap = &cobra.Command{
Use: "bootstrap",
Short: "bootstrap first Talos Node",
Long: advBootstrapLongHelp,
Run: bootstrapfunc,
}
-36
View File
@@ -1,36 +0,0 @@
package cmd
import (
"context"
talhelperCfg "github.com/budimanjojo/talhelper/v3/pkg/config"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/fluxhandler"
"github.com/truecharts/public/clustertool/pkg/helper"
"github.com/truecharts/public/clustertool/pkg/initfiles"
"github.com/truecharts/public/clustertool/pkg/sops"
)
var fluxbootstrap = &cobra.Command{
Use: "fluxbootstrap",
Short: "Manually bootstrap fluxcd on existing cluster",
Run: func(cmd *cobra.Command, args []string) {
ctx := context.Background()
if err := sops.DecryptFiles(); err != nil {
log.Info().Msgf("Error decrypting files: %v\n", err)
}
initfiles.LoadTalEnv(false)
_, err := talhelperCfg.LoadAndValidateFromFile(helper.TalConfigFile, []string{helper.ClusterEnvFile}, false)
if err != nil {
log.Fatal().Err(err).Msg("failed to parse talconfig or talenv file: %s")
}
fluxhandler.FluxBootstrap(ctx)
},
}
func init() {
adv.AddCommand(fluxbootstrap)
}
+7
View File
@@ -1,6 +1,8 @@
package cmd
import (
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/gencmd"
@@ -8,9 +10,14 @@ import (
"github.com/truecharts/public/clustertool/pkg/sops"
)
var advHealthLongHelp = strings.TrimSpace(`
`)
var health = &cobra.Command{
Use: "health",
Short: "Check Talos Cluster 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)
+6
View File
@@ -2,15 +2,21 @@ package cmd
import (
"os"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/sops"
)
var advPrecommitLongHelp = strings.TrimSpace(`
`)
var precommit = &cobra.Command{
Use: "precommit",
Short: "Runs the PreCommit encryption check",
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)
+7
View File
@@ -1,15 +1,22 @@
package cmd
import (
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/gencmd"
"github.com/truecharts/public/clustertool/pkg/sops"
)
var advResetLongHelp = strings.TrimSpace(`
`)
var reset = &cobra.Command{
Use: "reset",
Short: "Reset Talos Nodes and Kubernetes",
Long: advResetLongHelp,
Run: func(cmd *cobra.Command, args []string) {
var extraArgs []string
node := ""
+7
View File
@@ -1,15 +1,22 @@
package cmd
import (
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/gencmd"
"github.com/truecharts/public/clustertool/pkg/initfiles"
)
var advTestCmdlongHelp = strings.TrimSpace(`
`)
var testcmd = &cobra.Command{
Use: "test",
Short: "test run",
Long: advTestCmdlongHelp,
Run: func(cmd *cobra.Command, args []string) {
initfiles.LoadTalEnv(false)
// err := fluxhandler.ProcessJSONFiles("./testdata/truenas_exports")
+7
View File
@@ -1,6 +1,8 @@
package cmd
import (
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/gencmd"
@@ -9,9 +11,14 @@ import (
"github.com/truecharts/public/clustertool/pkg/sops"
)
var applyLongHelp = strings.TrimSpace(`
`)
var apply = &cobra.Command{
Use: "apply",
Short: "apply TalosConfig",
Long: applyLongHelp,
Run: func(cmd *cobra.Command, args []string) {
var extraArgs []string
node := ""
+7
View File
@@ -1,14 +1,21 @@
package cmd
import (
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/charts/version"
)
var chartsBumpLongHelp = strings.TrimSpace(`
`)
var bumper = &cobra.Command{
Use: "bump",
Short: "generate a bumped image version",
Long: chartsBumpLongHelp,
Example: "charttool bump <version> <kind>",
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
+7
View File
@@ -1,15 +1,22 @@
package cmd
import (
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/charts/deps"
"github.com/truecharts/public/clustertool/pkg/helper"
)
var chartsDepsLongHelp = strings.TrimSpace(`
`)
var depsCmd = &cobra.Command{
Use: "deps",
Short: "Download, Update and Verify Helm dependencies",
Long: chartsDepsLongHelp,
Example: "charttool deps <chart> <chart> <chart>",
Run: func(cmd *cobra.Command, args []string) {
if err := deps.LoadGPGKey(); err != nil {
+7
View File
@@ -1,15 +1,22 @@
package cmd
import (
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/charts/changelog"
)
var chartsGenChangelogLongHelp = strings.TrimSpace(`
`)
var genChangelogCmd = &cobra.Command{
Use: "genchangelog",
Short: "Generate changelog for charts",
Long: chartsGenChangelogLongHelp,
Example: "charttool genchangelog <repo path> <template path> <charts dir>",
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 3 {
+7
View File
@@ -1,6 +1,8 @@
package cmd
import (
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
@@ -8,9 +10,14 @@ import (
"github.com/truecharts/public/clustertool/pkg/helper"
)
var chartsGenChartsListLongHelp = strings.TrimSpace(`
`)
var genChartListCmd = &cobra.Command{
Use: "genchartlist",
Short: "Generate chart list json file",
Long: chartsGenChartsListLongHelp,
Example: "charttool genchartlist <path to charts folder>",
Run: func(cmd *cobra.Command, args []string) {
opts := &website.ChartListOptions{
+7
View File
@@ -1,6 +1,8 @@
package cmd
import (
"strings"
"github.com/rs/zerolog/log"
"slices"
@@ -10,9 +12,14 @@ import (
"github.com/truecharts/public/clustertool/pkg/helper"
)
var chartsGenMetaLongHelp = strings.TrimSpace(`
`)
var genMetaCmd = &cobra.Command{
Use: "genmeta",
Short: "Generate and update Chart.yaml metadata",
Long: chartsGenMetaLongHelp,
Run: func(cmd *cobra.Command, args []string) {
bump := ""
if len(args) > 0 && slices.Contains([]string{"patch", "minor", "major"}, args[0]) {
+7
View File
@@ -1,15 +1,22 @@
package cmd
import (
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/charts/image"
)
var chartsTagCleanLongHelp = strings.TrimSpace(`
`)
var tagCleaner = &cobra.Command{
Use: "tagcleaner",
Short: "Creates a clean version tag from a container digest",
Long: chartsTagCleanLongHelp,
Example: "charttool tagcleaner <tag>",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
+6
View File
@@ -2,15 +2,21 @@ package cmd
import (
"os"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/sops"
)
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,
Run: func(cmd *cobra.Command, args []string) {
if err := sops.CheckFilesAndReportEncryption(false, false); err != nil {
log.Info().Msgf("Error checking files: %v\n", err)
+7
View File
@@ -1,14 +1,21 @@
package cmd
import (
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/sops"
)
var decryptLongHelp = strings.TrimSpace(`
`)
var decrypt = &cobra.Command{
Use: "decrypt",
Short: "Decrypt all high-risk data using sops",
Long: decryptLongHelp,
Run: func(cmd *cobra.Command, args []string) {
if err := sops.DecryptFiles(); err != nil {
log.Info().Msgf("Error decrypting files: %v\n", err)
+7
View File
@@ -1,14 +1,21 @@
package cmd
import (
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/sops"
)
var encryptLongHelp = strings.TrimSpace(`
`)
var encrypt = &cobra.Command{
Use: "encrypt",
Short: "Encrypt all high-risk data using sops",
Long: encryptLongHelp,
Run: func(cmd *cobra.Command, args []string) {
if err := sops.EncryptAllFiles(); err != nil {
log.Info().Msgf("Error encrypting files: %v\n", err)
+32 -4
View File
@@ -1,14 +1,42 @@
package cmd
import (
"context"
"strings"
talhelperCfg "github.com/budimanjojo/talhelper/v3/pkg/config"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/fluxhandler"
"github.com/truecharts/public/clustertool/pkg/helper"
"github.com/truecharts/public/clustertool/pkg/initfiles"
"github.com/truecharts/public/clustertool/pkg/sops"
)
var fluxBootstrap = &cobra.Command{
Use: "fluxBootstrap",
Short: "bootstrapFluxCD",
var fluxBootstrapLongHelp = strings.TrimSpace(`
`)
var fluxbootstrap = &cobra.Command{
Use: "fluxbootstrap",
Short: "Manually bootstrap fluxcd on existing cluster",
Long: fluxBootstrapLongHelp,
Run: func(cmd *cobra.Command, args []string) {
ctx := context.Background()
if err := sops.DecryptFiles(); err != nil {
log.Info().Msgf("Error decrypting files: %v\n", err)
}
initfiles.LoadTalEnv(false)
_, err := talhelperCfg.LoadAndValidateFromFile(helper.TalConfigFile, []string{helper.ClusterEnvFile}, false)
if err != nil {
log.Fatal().Err(err).Msg("failed to parse talconfig or talenv file: %s")
}
fluxhandler.FluxBootstrap(ctx)
},
}
func init() {
RootCmd.AddCommand(fluxBootstrap)
RootCmd.AddCommand(fluxbootstrap)
}
+6
View File
@@ -2,15 +2,21 @@ package cmd
import (
"path/filepath"
"strings"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/fluxhandler"
"github.com/truecharts/public/clustertool/pkg/initfiles"
)
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,
Run: func(cmd *cobra.Command, args []string) {
initfiles.LoadTalEnv(false)
+6
View File
@@ -2,15 +2,21 @@ package cmd
import (
"path/filepath"
"strings"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/fluxhandler"
"github.com/truecharts/public/clustertool/pkg/initfiles"
)
var hrUpgradeLongHelp = strings.TrimSpace(`
`)
var hrupgrade = &cobra.Command{
Use: "upgrade",
Short: "run helm-upgrade using a helm-release file without flux",
Long: hrUpgradeLongHelp,
Run: func(cmd *cobra.Command, args []string) {
initfiles.LoadTalEnv(false)
+7
View File
@@ -1,13 +1,20 @@
package cmd
import (
"strings"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/info"
)
var infoLongHelp = strings.TrimSpace(`
`)
var infoCmd = &cobra.Command{
Use: "info",
Short: "Prints information about the clustertool binary",
Long: infoLongHelp,
Example: "clustertool info",
Run: func(cmd *cobra.Command, args []string) {
info.NewInfo().Print()
+7
View File
@@ -1,13 +1,20 @@
package cmd
import (
"strings"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/scale"
)
var scaleExportLongHelp = strings.TrimSpace(`
`)
var scaleexport = &cobra.Command{
Use: "export",
Short: "Export SCALE Apps to file",
Long: scaleExportLongHelp,
Run: func(cmd *cobra.Command, args []string) {
scale.ExportApps()
},
+7
View File
@@ -1,14 +1,21 @@
package cmd
import (
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/scale"
)
var scaleMigrateLongHelp = strings.TrimSpace(`
`)
var scalemigrate = &cobra.Command{
Use: "migrate",
Short: "Migrate exported SCALE Apps to the Talos Cluster",
Long: scaleMigrateLongHelp,
Run: func(cmd *cobra.Command, args []string) {
err := scale.ProcessJSONFiles("./truenas_exports")
if err != nil {
+7
View File
@@ -1,6 +1,8 @@
package cmd
import (
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/gencmd"
@@ -8,9 +10,14 @@ import (
"github.com/truecharts/public/clustertool/pkg/sops"
)
var upgradeLongHelp = strings.TrimSpace(`
`)
var upgrade = &cobra.Command{
Use: "upgrade",
Short: "Upgrade Talos Nodes and Kubernetes",
Long: upgradeLongHelp,
Run: func(cmd *cobra.Command, args []string) {
var extraArgs []string
node := ""