chore: fix links

This commit is contained in:
Kjeld Schouten
2025-09-07 14:26:19 +02:00
parent 029b0366ba
commit 1c28a12789
1236 changed files with 26091 additions and 26091 deletions
+22 -22
View File
@@ -1,35 +1,35 @@
package cmd
import (
"log"
"os"
"log"
"os"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
"github.com/truecharts/public/clustertool/pkg/helper"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
"github.com/trueforge-org/truecharts/clustertool/pkg/helper"
)
var gendocsCmd = &cobra.Command{
Use: "gentooldocs",
Short: "Generate documentation for the CLI",
Args: cobra.ExactArgs(1),
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {
outdir := args[0]
tmpdir := helper.DocsCache
Use: "gentooldocs",
Short: "Generate documentation for the CLI",
Args: cobra.ExactArgs(1),
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {
outdir := args[0]
tmpdir := helper.DocsCache
if err := os.MkdirAll(tmpdir, 0o777); err != nil {
log.Fatal(err)
}
if err := os.MkdirAll(tmpdir, 0o777); err != nil {
log.Fatal(err)
}
err := doc.GenMarkdownTree(RootCmd, tmpdir)
if err != nil {
log.Fatal(err)
}
helper.ToolDocs(tmpdir, outdir)
},
err := doc.GenMarkdownTree(RootCmd, tmpdir)
if err != nil {
log.Fatal(err)
}
helper.ToolDocs(tmpdir, outdir)
},
}
func init() {
adv.AddCommand(gendocsCmd)
adv.AddCommand(gendocsCmd)
}
+16 -16
View File
@@ -1,12 +1,12 @@
package cmd
import (
"os"
"strings"
"os"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/sops"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/sops"
)
var advPrecommitLongHelp = strings.TrimSpace(`
@@ -14,18 +14,18 @@ var advPrecommitLongHelp = strings.TrimSpace(`
`)
var precommit = &cobra.Command{
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)
os.Exit(1)
}
},
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)
os.Exit(1)
}
},
}
func init() {
adv.AddCommand(precommit)
adv.AddCommand(precommit)
}
+35 -35
View File
@@ -1,17 +1,17 @@
package cmd
import (
"context"
"os"
"path/filepath"
"strings"
"context"
"os"
"path/filepath"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/helper"
"github.com/truecharts/public/clustertool/pkg/initfiles"
"github.com/truecharts/public/clustertool/pkg/kubectlcmds"
"github.com/truecharts/public/clustertool/pkg/talassist"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/helper"
"github.com/trueforge-org/truecharts/clustertool/pkg/initfiles"
"github.com/trueforge-org/truecharts/clustertool/pkg/kubectlcmds"
"github.com/trueforge-org/truecharts/clustertool/pkg/talassist"
)
var advTestCmdlongHelp = strings.TrimSpace(`
@@ -19,32 +19,32 @@ This command is mostly just for development usage and should NEVER be used by en
`)
var testcmd = &cobra.Command{
Use: "test",
Short: "tests specific code for developer usages",
Long: advTestCmdlongHelp,
Run: func(cmd *cobra.Command, args []string) {
ctx := context.Background()
initfiles.LoadTalEnv(false)
talassist.LoadTalConfig()
// err := fluxhandler.ProcessJSONFiles("./testdata/truenas_exports")
// if err != nil {
// log.Info().Msg("Error:", err)
// }
var manifestPaths = []string{
filepath.Join(helper.KubernetesPath, "flux-system", "flux", "sopssecret.secret.yaml"),
filepath.Join(helper.KubernetesPath, "flux-system", "flux", "deploykey.secret.yaml"),
filepath.Join(helper.KubernetesPath, "flux-system", "flux", "clustersettings.secret.yaml"),
}
for _, filePath := range manifestPaths {
log.Info().Msgf("Bootstrap: Loading Manifest: %v", filePath)
if err := kubectlcmds.KubectlApply(ctx, filePath); err != nil {
log.Info().Msgf("Error applying manifest for %s: %v\n", filepath.Base(filePath), err)
os.Exit(1)
}
}
},
Use: "test",
Short: "tests specific code for developer usages",
Long: advTestCmdlongHelp,
Run: func(cmd *cobra.Command, args []string) {
ctx := context.Background()
initfiles.LoadTalEnv(false)
talassist.LoadTalConfig()
// err := fluxhandler.ProcessJSONFiles("./testdata/truenas_exports")
// if err != nil {
// log.Info().Msg("Error:", err)
// }
var manifestPaths = []string{
filepath.Join(helper.KubernetesPath, "flux-system", "flux", "sopssecret.secret.yaml"),
filepath.Join(helper.KubernetesPath, "flux-system", "flux", "deploykey.secret.yaml"),
filepath.Join(helper.KubernetesPath, "flux-system", "flux", "clustersettings.secret.yaml"),
}
for _, filePath := range manifestPaths {
log.Info().Msgf("Bootstrap: Loading Manifest: %v", filePath)
if err := kubectlcmds.KubectlApply(ctx, filePath); err != nil {
log.Info().Msgf("Error applying manifest for %s: %v\n", filepath.Base(filePath), err)
os.Exit(1)
}
}
},
}
func init() {
adv.AddCommand(testcmd)
adv.AddCommand(testcmd)
}
+15 -15
View File
@@ -1,11 +1,11 @@
package cmd
import (
"strings"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/charts/version"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/charts/version"
)
var chartsBumpLongHelp = strings.TrimSpace(`
@@ -13,18 +13,18 @@ var chartsBumpLongHelp = strings.TrimSpace(`
`)
var bumper = &cobra.Command{
Use: "bump",
Short: "generate a bumped image version",
Long: chartsBumpLongHelp,
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 {
log.Fatal().Err(err).Msg("failed to bump version")
}
},
Use: "bump",
Short: "generate a bumped image version",
Long: chartsBumpLongHelp,
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 {
log.Fatal().Err(err).Msg("failed to bump version")
}
},
}
func init() {
charts.AddCommand(bumper)
charts.AddCommand(bumper)
}
+20 -20
View File
@@ -1,12 +1,12 @@
package cmd
import (
"strings"
"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"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/charts/deps"
"github.com/trueforge-org/truecharts/clustertool/pkg/helper"
)
var chartsDepsLongHelp = strings.TrimSpace(`
@@ -14,23 +14,23 @@ var chartsDepsLongHelp = strings.TrimSpace(`
`)
var depsCmd = &cobra.Command{
Use: "deps",
Short: "Download, Update and Verify Helm dependencies",
Long: chartsDepsLongHelp,
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")
}
Use: "deps",
Short: "Download, Update and Verify Helm dependencies",
Long: chartsDepsLongHelp,
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")
}
// Specify the mode (SyncMode or AsyncMode)
mode := helper.SyncMode // Change to helper.SyncMode for synchronous processing
if err := helper.WalkCharts(args, deps.DownloadDeps, "", mode); err != nil {
log.Fatal().Err(err).Msg("failed to update Chart.yaml")
}
},
// Specify the mode (SyncMode or AsyncMode)
mode := helper.SyncMode // Change to helper.SyncMode for synchronous processing
if err := helper.WalkCharts(args, deps.DownloadDeps, "", mode); err != nil {
log.Fatal().Err(err).Msg("failed to update Chart.yaml")
}
},
}
func init() {
charts.AddCommand(depsCmd)
charts.AddCommand(depsCmd)
}
+30 -30
View File
@@ -1,12 +1,12 @@
package cmd
import (
"strings"
"strings"
"github.com/rs/zerolog/log"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/charts/changelog"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/charts/changelog"
)
var chartsGenChangelogLongHelp = strings.TrimSpace(`
@@ -14,33 +14,33 @@ var chartsGenChangelogLongHelp = strings.TrimSpace(`
`)
var genChangelogCmd = &cobra.Command{
Use: "genchangelog",
Short: "Generate changelog for charts",
Long: chartsGenChangelogLongHelp,
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.")
}
opts := &changelog.ChangelogOptions{
RepoPath: args[0],
TemplatePath: args[1],
ChartsDir: args[2],
ChangelogFileName: "CHANGELOG.md",
JSONOutputPath: "./changelog.json",
PrettyJSON: true,
StatusUpdateInterval: 5,
SkipCommitsWithBadMessage: false,
}
if err := opts.Generate(); err != nil {
log.Fatal().Err(err)
}
if err := opts.Render(); err != nil {
log.Fatal().Err(err)
}
},
Use: "genchangelog",
Short: "Generate changelog for charts",
Long: chartsGenChangelogLongHelp,
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.")
}
opts := &changelog.ChangelogOptions{
RepoPath: args[0],
TemplatePath: args[1],
ChartsDir: args[2],
ChangelogFileName: "CHANGELOG.md",
JSONOutputPath: "./changelog.json",
PrettyJSON: true,
StatusUpdateInterval: 5,
SkipCommitsWithBadMessage: false,
}
if err := opts.Generate(); err != nil {
log.Fatal().Err(err)
}
if err := opts.Render(); err != nil {
log.Fatal().Err(err)
}
},
}
func init() {
charts.AddCommand(genChangelogCmd)
charts.AddCommand(genChangelogCmd)
}
+22 -22
View File
@@ -1,13 +1,13 @@
package cmd
import (
"strings"
"strings"
"github.com/rs/zerolog/log"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/charts/website"
"github.com/truecharts/public/clustertool/pkg/helper"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/charts/website"
"github.com/trueforge-org/truecharts/clustertool/pkg/helper"
)
var chartsGenChartsListLongHelp = strings.TrimSpace(`
@@ -15,27 +15,27 @@ var chartsGenChartsListLongHelp = strings.TrimSpace(`
`)
var genChartListCmd = &cobra.Command{
Use: "genchartlist",
Short: "Generate chart list json file",
Long: chartsGenChartsListLongHelp,
Example: "clustertool charts genchartlist <path to charts folder>",
Run: func(cmd *cobra.Command, args []string) {
opts := &website.ChartListOptions{
OutputPath: "./charts.json",
TrainFilter: []string{}, // We can filter by train later if needed
}
Use: "genchartlist",
Short: "Generate chart list json file",
Long: chartsGenChartsListLongHelp,
Example: "clustertool charts genchartlist <path to charts folder>",
Run: func(cmd *cobra.Command, args []string) {
opts := &website.ChartListOptions{
OutputPath: "./charts.json",
TrainFilter: []string{}, // We can filter by train later if needed
}
if err := helper.WalkCharts2(args, opts.GetChartData, helper.AsyncMode); err != nil {
log.Fatal().Err(err).Msg("failed to generate chart list json file:")
}
if err := helper.WalkCharts2(args, opts.GetChartData, helper.AsyncMode); err != nil {
log.Fatal().Err(err).Msg("failed to generate chart list json file:")
}
if err := opts.WriteChartList(); err != nil {
log.Fatal().Err(err).Msg("failed to write chart list json file:")
}
if err := opts.WriteChartList(); err != nil {
log.Fatal().Err(err).Msg("failed to write chart list json file:")
}
},
},
}
func init() {
charts.AddCommand(genChartListCmd)
charts.AddCommand(genChartListCmd)
}
+25 -25
View File
@@ -1,15 +1,15 @@
package cmd
import (
"strings"
"strings"
"github.com/rs/zerolog/log"
"github.com/rs/zerolog/log"
"slices"
"slices"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/charts/chartFile"
"github.com/truecharts/public/clustertool/pkg/helper"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/charts/chartFile"
"github.com/trueforge-org/truecharts/clustertool/pkg/helper"
)
var chartsGenMetaLongHelp = strings.TrimSpace(`
@@ -17,28 +17,28 @@ var chartsGenMetaLongHelp = strings.TrimSpace(`
`)
var genMetaCmd = &cobra.Command{
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]) {
bump = args[0]
args = args[1:]
}
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]) {
bump = args[0]
args = args[1:]
}
// Specify the mode (SyncMode or AsyncMode)
// Async Mode showed concurrency issues (Stavros)
mode := helper.SyncMode
// Specify the mode (SyncMode or AsyncMode)
// Async Mode showed concurrency issues (Stavros)
mode := helper.SyncMode
err := helper.WalkCharts(args, chartFile.UpdateChartFile, bump, mode)
if err != nil {
log.Fatal().Err(err).Msg("failed to update Chart.yaml:")
}
},
err := helper.WalkCharts(args, chartFile.UpdateChartFile, bump, mode)
if err != nil {
log.Fatal().Err(err).Msg("failed to update Chart.yaml:")
}
},
}
func init() {
charts.AddCommand(genMetaCmd)
charts.AddCommand(genMetaCmd)
}
+16 -16
View File
@@ -1,12 +1,12 @@
package cmd
import (
"strings"
"strings"
"github.com/rs/zerolog/log"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/charts/image"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/charts/image"
)
var chartsTagCleanLongHelp = strings.TrimSpace(`
@@ -14,19 +14,19 @@ var chartsTagCleanLongHelp = strings.TrimSpace(`
`)
var tagCleaner = &cobra.Command{
Use: "tagcleaner",
Short: "Creates a clean version tag from a container digest",
Long: chartsTagCleanLongHelp,
Example: "clustertool charts tagclean <tag>",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
err := image.Clean(args[0])
if err != nil {
log.Fatal().Err(err).Msg("failed to clean tag")
}
},
Use: "tagcleaner",
Short: "Creates a clean version tag from a container digest",
Long: chartsTagCleanLongHelp,
Example: "clustertool charts tagclean <tag>",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
err := image.Clean(args[0])
if err != nil {
log.Fatal().Err(err).Msg("failed to clean tag")
}
},
}
func init() {
charts.AddCommand(tagCleaner)
charts.AddCommand(tagCleaner)
}
+17 -17
View File
@@ -1,12 +1,12 @@
package cmd
import (
"os"
"strings"
"os"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/sops"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/sops"
)
var checkcyptLongHelp = strings.TrimSpace(`
@@ -17,19 +17,19 @@ This tool can, for example, be used as a pre-commit check and will fail with a n
`)
var checkcrypt = &cobra.Command{
Use: "checkcrypt",
Short: "Checks if all files are encrypted correctly in accordance with .sops.yaml",
Aliases: []string{"checkencrypt"},
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)
os.Exit(1)
}
},
Use: "checkcrypt",
Short: "Checks if all files are encrypted correctly in accordance with .sops.yaml",
Aliases: []string{"checkencrypt"},
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)
os.Exit(1)
}
},
}
func init() {
RootCmd.AddCommand(checkcrypt)
RootCmd.AddCommand(checkcrypt)
}
+14 -14
View File
@@ -1,11 +1,11 @@
package cmd
import (
"strings"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/sops"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/sops"
)
var decryptLongHelp = strings.TrimSpace(`
@@ -15,17 +15,17 @@ If so, they are decrypted using your "age.agekey" file as specified in ".sops.ya
`)
var decrypt = &cobra.Command{
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)
}
},
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)
}
},
}
func init() {
RootCmd.AddCommand(decrypt)
RootCmd.AddCommand(decrypt)
}
+14 -14
View File
@@ -1,11 +1,11 @@
package cmd
import (
"strings"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/sops"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/sops"
)
var encryptLongHelp = strings.TrimSpace(`
@@ -15,17 +15,17 @@ Afterwards, they are encrypted using your "age.agekey" file as specified in ".so
`)
var encrypt = &cobra.Command{
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)
}
},
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)
}
},
}
func init() {
RootCmd.AddCommand(encrypt)
RootCmd.AddCommand(encrypt)
}
+20 -20
View File
@@ -1,14 +1,14 @@
package cmd
import (
"context"
"strings"
"context"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/fluxhandler"
"github.com/truecharts/public/clustertool/pkg/initfiles"
"github.com/truecharts/public/clustertool/pkg/sops"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/fluxhandler"
"github.com/trueforge-org/truecharts/clustertool/pkg/initfiles"
"github.com/trueforge-org/truecharts/clustertool/pkg/sops"
)
var fluxBootstrapLongHelp = strings.TrimSpace(`
@@ -16,21 +16,21 @@ var fluxBootstrapLongHelp = strings.TrimSpace(`
`)
var fluxbootstrap = &cobra.Command{
Use: "bootstrap",
Short: "Manually bootstrap fluxcd on existing cluster",
Example: "clustertool flux bootstrap",
Long: fluxBootstrapLongHelp,
Run: func(cmd *cobra.Command, args []string) {
ctx := context.Background()
Use: "bootstrap",
Short: "Manually bootstrap fluxcd on existing cluster",
Example: "clustertool flux bootstrap",
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)
fluxhandler.FluxBootstrap(ctx)
},
if err := sops.DecryptFiles(); err != nil {
log.Info().Msgf("Error decrypting files: %v\n", err)
}
initfiles.LoadTalEnv(false)
fluxhandler.FluxBootstrap(ctx)
},
}
func init() {
fluxCmd.AddCommand(fluxbootstrap)
fluxCmd.AddCommand(fluxbootstrap)
}
+11 -11
View File
@@ -1,10 +1,10 @@
package cmd
import (
"strings"
"strings"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/gencmd"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/gencmd"
)
var genConfigLongHelp = strings.TrimSpace(`
@@ -17,16 +17,16 @@ It also ensures the same configmap is always added by updating the patches.
`)
var genConfig = &cobra.Command{
Use: "genconfig",
Short: "generate Configuration files",
Long: genConfigLongHelp,
Example: "clustertool genconfig",
Run: func(cmd *cobra.Command, args []string) {
Use: "genconfig",
Short: "generate Configuration files",
Long: genConfigLongHelp,
Example: "clustertool genconfig",
Run: func(cmd *cobra.Command, args []string) {
gencmd.GenConfig(args)
},
gencmd.GenConfig(args)
},
}
func init() {
RootCmd.AddCommand(genConfig)
RootCmd.AddCommand(genConfig)
}
+26 -26
View File
@@ -1,12 +1,12 @@
package cmd
import (
"path/filepath"
"strings"
"path/filepath"
"strings"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/fluxhandler"
"github.com/truecharts/public/clustertool/pkg/initfiles"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/fluxhandler"
"github.com/trueforge-org/truecharts/clustertool/pkg/initfiles"
)
var hrInstalLongHelp = strings.TrimSpace(`
@@ -14,31 +14,31 @@ 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",
Example: "clustertool helmrelease install",
Long: hrInstalLongHelp,
Run: func(cmd *cobra.Command, args []string) {
initfiles.LoadTalEnv(false)
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)
var dir string
var dir string
// Check if args[0] includes a filename
if filename := filepath.Base(args[0]); filename != "" && filename != "." && filename != "/" {
dir = filepath.Dir(args[0])
} else {
dir = args[0] // Assuming args[0] is just a directory path without a filename
}
helmRepoPath := filepath.Join("./repositories", "helm")
helmRepos, _ := fluxhandler.LoadAllHelmRepos(helmRepoPath)
intermediateCharts := []fluxhandler.HelmChart{
{dir, false, true},
}
// Check if args[0] includes a filename
if filename := filepath.Base(args[0]); filename != "" && filename != "." && filename != "/" {
dir = filepath.Dir(args[0])
} else {
dir = args[0] // Assuming args[0] is just a directory path without a filename
}
helmRepoPath := filepath.Join("./repositories", "helm")
helmRepos, _ := fluxhandler.LoadAllHelmRepos(helmRepoPath)
intermediateCharts := []fluxhandler.HelmChart{
{dir, false, true},
}
fluxhandler.InstallCharts(intermediateCharts, helmRepos, false)
},
fluxhandler.InstallCharts(intermediateCharts, helmRepos, false)
},
}
func init() {
helmrelease.AddCommand(hrinstall)
helmrelease.AddCommand(hrinstall)
}
+27 -27
View File
@@ -1,12 +1,12 @@
package cmd
import (
"path/filepath"
"strings"
"path/filepath"
"strings"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/fluxhandler"
"github.com/truecharts/public/clustertool/pkg/initfiles"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/fluxhandler"
"github.com/trueforge-org/truecharts/clustertool/pkg/initfiles"
)
var hrUpgradeLongHelp = strings.TrimSpace(`
@@ -14,32 +14,32 @@ var hrUpgradeLongHelp = strings.TrimSpace(`
`)
var hrupgrade = &cobra.Command{
Use: "upgrade",
Short: "run helm-upgrade using a helm-release file without flux",
Aliases: []string{"update", "edit"},
Example: "clustertool helmrelease upgrade",
Long: hrUpgradeLongHelp,
Run: func(cmd *cobra.Command, args []string) {
initfiles.LoadTalEnv(false)
Use: "upgrade",
Short: "run helm-upgrade using a helm-release file without flux",
Aliases: []string{"update", "edit"},
Example: "clustertool helmrelease upgrade",
Long: hrUpgradeLongHelp,
Run: func(cmd *cobra.Command, args []string) {
initfiles.LoadTalEnv(false)
var dir string
var dir string
// Check if args[0] includes a filename
if filename := filepath.Base(args[0]); filename != "" && filename != "." && filename != "/" {
dir = filepath.Dir(args[0])
} else {
dir = args[0] // Assuming args[0] is just a directory path without a filename
}
helmRepoPath := filepath.Join("./repositories", "helm")
helmRepos, _ := fluxhandler.LoadAllHelmRepos(helmRepoPath)
intermediateCharts := []fluxhandler.HelmChart{
{dir, false, true},
}
// Check if args[0] includes a filename
if filename := filepath.Base(args[0]); filename != "" && filename != "." && filename != "/" {
dir = filepath.Dir(args[0])
} else {
dir = args[0] // Assuming args[0] is just a directory path without a filename
}
helmRepoPath := filepath.Join("./repositories", "helm")
helmRepos, _ := fluxhandler.LoadAllHelmRepos(helmRepoPath)
intermediateCharts := []fluxhandler.HelmChart{
{dir, false, true},
}
fluxhandler.UpgradeCharts(intermediateCharts, helmRepos, false)
},
fluxhandler.UpgradeCharts(intermediateCharts, helmRepos, false)
},
}
func init() {
helmrelease.AddCommand(hrupgrade)
helmrelease.AddCommand(hrupgrade)
}
+11 -11
View File
@@ -1,10 +1,10 @@
package cmd
import (
"strings"
"strings"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/info"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/info"
)
var infoLongHelp = strings.TrimSpace(`
@@ -21,15 +21,15 @@ Workflow:
`)
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()
},
Use: "info",
Short: "Prints information about the clustertool binary",
Long: infoLongHelp,
Example: "clustertool info",
Run: func(cmd *cobra.Command, args []string) {
info.NewInfo().Print()
},
}
func init() {
RootCmd.AddCommand(infoCmd)
RootCmd.AddCommand(infoCmd)
}
+13 -13
View File
@@ -1,11 +1,11 @@
package cmd
import (
"strings"
"strings"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/initfiles"
"github.com/truecharts/public/clustertool/pkg/sops"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/initfiles"
"github.com/trueforge-org/truecharts/clustertool/pkg/sops"
)
var initLongHelp = strings.TrimSpace(`
@@ -18,18 +18,18 @@ When done, please run clustertool genconfig to generate all configurations based
`)
var initFiles = &cobra.Command{
Use: "init",
Short: "generate Basic ClusterTool file-and-folder structure in current folder",
Long: initLongHelp,
Example: "clustertool init",
Run: func(cmd *cobra.Command, args []string) {
Use: "init",
Short: "generate Basic ClusterTool file-and-folder structure in current folder",
Long: initLongHelp,
Example: "clustertool init",
Run: func(cmd *cobra.Command, args []string) {
sops.DecryptFiles()
sops.DecryptFiles()
initfiles.InitFiles()
},
initfiles.InitFiles()
},
}
func init() {
RootCmd.AddCommand(initFiles)
RootCmd.AddCommand(initFiles)
}
+29 -29
View File
@@ -1,47 +1,47 @@
package cmd
import (
"os"
"path/filepath"
"os"
"path/filepath"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/helper"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/helper"
)
var thisversion string
var RootCmd = &cobra.Command{
Use: "clustertool",
Short: "A tool to help with creating Talos cluster",
Long: infoLongHelp,
SilenceUsage: true,
SilenceErrors: true,
Version: thisversion,
Use: "clustertool",
Short: "A tool to help with creating Talos cluster",
Long: infoLongHelp,
SilenceUsage: true,
SilenceErrors: true,
Version: thisversion,
}
func init() {
// Define the --cluster flag
RootCmd.PersistentFlags().StringVar(&helper.ClusterName, "cluster", "main", "Cluster name")
// Define the --cluster flag
RootCmd.PersistentFlags().StringVar(&helper.ClusterName, "cluster", "main", "Cluster name")
}
func Execute() error {
// Parse only the persistent flags (like --cluster) before executing any command
RootCmd.PersistentFlags().Parse(os.Args[1:])
// Parse only the persistent flags (like --cluster) before executing any command
RootCmd.PersistentFlags().Parse(os.Args[1:])
// You can now access the helper.ClusterName variable
if helper.ClusterName != "" {
log.Info().Msgf("Cluster name: %s\n", helper.ClusterName)
helper.ClusterPath = filepath.Join("./clusters", helper.ClusterName)
helper.ClusterEnvFile = filepath.Join(helper.ClusterPath, "/clusterenv.yaml")
helper.TalConfigFile = filepath.Join(helper.ClusterPath, "/talos", "talconfig.yaml")
helper.TalosPath = filepath.Join(helper.ClusterPath, "/talos")
helper.KubernetesPath = filepath.Join(helper.ClusterPath, "/kubernetes")
helper.TalosGenerated = filepath.Join(helper.TalosPath, "/generated")
helper.TalosConfigFile = filepath.Join(helper.TalosGenerated, "talosconfig")
helper.TalSecretFile = filepath.Join(helper.TalosGenerated, "talsecret.yaml")
}
// You can now access the helper.ClusterName variable
if helper.ClusterName != "" {
log.Info().Msgf("Cluster name: %s\n", helper.ClusterName)
helper.ClusterPath = filepath.Join("./clusters", helper.ClusterName)
helper.ClusterEnvFile = filepath.Join(helper.ClusterPath, "/clusterenv.yaml")
helper.TalConfigFile = filepath.Join(helper.ClusterPath, "/talos", "talconfig.yaml")
helper.TalosPath = filepath.Join(helper.ClusterPath, "/talos")
helper.KubernetesPath = filepath.Join(helper.ClusterPath, "/kubernetes")
helper.TalosGenerated = filepath.Join(helper.TalosPath, "/generated")
helper.TalosConfigFile = filepath.Join(helper.TalosGenerated, "talosconfig")
helper.TalSecretFile = filepath.Join(helper.TalosGenerated, "talsecret.yaml")
}
// Execute the root command and all subcommands
return RootCmd.Execute()
// Execute the root command and all subcommands
return RootCmd.Execute()
}
+68 -68
View File
@@ -1,16 +1,16 @@
package cmd
import (
"strings"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/gencmd"
"github.com/truecharts/public/clustertool/pkg/helper"
"github.com/truecharts/public/clustertool/pkg/initfiles"
"github.com/truecharts/public/clustertool/pkg/nodestatus"
"github.com/truecharts/public/clustertool/pkg/sops"
"github.com/truecharts/public/clustertool/pkg/talassist"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/gencmd"
"github.com/trueforge-org/truecharts/clustertool/pkg/helper"
"github.com/trueforge-org/truecharts/clustertool/pkg/initfiles"
"github.com/trueforge-org/truecharts/clustertool/pkg/nodestatus"
"github.com/trueforge-org/truecharts/clustertool/pkg/sops"
"github.com/trueforge-org/truecharts/clustertool/pkg/talassist"
)
var applyLongHelp = strings.TrimSpace(`
@@ -45,79 +45,79 @@ Not any contained helm-charts
`)
var apply = &cobra.Command{
Use: "apply",
Short: "apply",
Aliases: []string{"apply-config"},
Example: "clustertool apply <NodeIP>",
Long: applyLongHelp,
Run: func(cmd *cobra.Command, args []string) {
var extraArgs []string
node := ""
Use: "apply",
Short: "apply",
Aliases: []string{"apply-config"},
Example: "clustertool apply <NodeIP>",
Long: applyLongHelp,
Run: func(cmd *cobra.Command, args []string) {
var extraArgs []string
node := ""
if len(args) > 1 {
extraArgs = args[1:]
}
if len(args) >= 1 {
node = args[0]
if args[0] == "all" {
node = ""
}
}
if len(args) > 1 {
extraArgs = args[1:]
}
if len(args) >= 1 {
node = args[0]
if args[0] == "all" {
node = ""
}
}
if err := sops.DecryptFiles(); err != nil {
log.Info().Msgf("Error decrypting files: %v\n", err)
}
if err := sops.DecryptFiles(); err != nil {
log.Info().Msgf("Error decrypting files: %v\n", err)
}
initfiles.LoadTalEnv(false)
talassist.LoadTalConfig()
bootstrapNode := talassist.TalConfig.Nodes[0].IPAddress
initfiles.LoadTalEnv(false)
talassist.LoadTalConfig()
bootstrapNode := talassist.TalConfig.Nodes[0].IPAddress
log.Info().Msgf("Checking if first node is ready to recieve anything... %s", bootstrapNode)
status, err := nodestatus.WaitForHealth(bootstrapNode, []string{"running", "maintenance"})
if err != nil {
log.Info().Msgf("Checking if first node is ready to recieve anything... %s", bootstrapNode)
status, err := nodestatus.WaitForHealth(bootstrapNode, []string{"running", "maintenance"})
if err != nil {
} else if status == "maintenance" {
bootstrapNeeded, err := nodestatus.CheckNeedBootstrap(bootstrapNode)
if err != nil {
} else if status == "maintenance" {
bootstrapNeeded, err := nodestatus.CheckNeedBootstrap(bootstrapNode)
if err != nil {
} else if bootstrapNeeded {
log.Info().Msg("First Node requires to be bootstrapped before it can be used.")
if helper.GetYesOrNo("Do you want to bootstrap now? (yes/no) [y/n]: ") {
gencmd.RunBootstrap(extraArgs)
if helper.GetYesOrNo("Do you want to apply config to all remaining clusternodes as well? (yes/no) [y/n]: ") {
RunApply(false, "", extraArgs)
}
} else {
log.Info().Msg("Exiting bootstrap, as apply is not possible...")
}
} else if bootstrapNeeded {
log.Info().Msg("First Node requires to be bootstrapped before it can be used.")
if helper.GetYesOrNo("Do you want to bootstrap now? (yes/no) [y/n]: ") {
gencmd.RunBootstrap(extraArgs)
if helper.GetYesOrNo("Do you want to apply config to all remaining clusternodes as well? (yes/no) [y/n]: ") {
RunApply(false, "", extraArgs)
}
} else {
log.Info().Msg("Exiting bootstrap, as apply is not possible...")
}
} else {
log.Info().Msg("Detected maintenance mode, but first node does not require to be bootrapped.")
log.Info().Msg("Assuming apply is requested... continuing with Apply...")
RunApply(true, node, extraArgs)
}
} else {
log.Info().Msg("Detected maintenance mode, but first node does not require to be bootrapped.")
log.Info().Msg("Assuming apply is requested... continuing with Apply...")
RunApply(true, node, extraArgs)
}
} else if status == "running" {
log.Info().Msg("Apply: running first controlnode detected, continuing...")
RunApply(true, node, extraArgs)
}
},
} else if status == "running" {
log.Info().Msg("Apply: running first controlnode detected, continuing...")
RunApply(true, node, extraArgs)
}
},
}
func RunApply(kubeconfig bool, node string, extraArgs []string) {
taloscmds := gencmd.GenApply(node, extraArgs)
gencmd.ExecCmds(taloscmds, true)
taloscmds := gencmd.GenApply(node, extraArgs)
gencmd.ExecCmds(taloscmds, true)
if kubeconfig {
kubeconfigcmds := gencmd.GenPlain("kubeconfig", helper.TalEnv["VIP_IP"], []string{"-f"})
gencmd.ExecCmd(kubeconfigcmds[0])
}
if kubeconfig {
kubeconfigcmds := gencmd.GenPlain("kubeconfig", helper.TalEnv["VIP_IP"], []string{"-f"})
gencmd.ExecCmd(kubeconfigcmds[0])
}
//if helper.GetYesOrNo("Do you want to (re)load ssh, Sops and ClusterEnv onto the cluster? (yes/no) [y/n]: ") {
//
//}
//if helper.GetYesOrNo("Do you want to (re)load ssh, Sops and ClusterEnv onto the cluster? (yes/no) [y/n]: ") {
//
//}
}
func init() {
talosCmd.AddCommand(apply)
talosCmd.AddCommand(apply)
}
+20 -20
View File
@@ -1,13 +1,13 @@
package cmd
import (
"strings"
"strings"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/gencmd"
"github.com/truecharts/public/clustertool/pkg/helper"
"github.com/truecharts/public/clustertool/pkg/initfiles"
"github.com/truecharts/public/clustertool/pkg/talassist"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/gencmd"
"github.com/trueforge-org/truecharts/clustertool/pkg/helper"
"github.com/trueforge-org/truecharts/clustertool/pkg/initfiles"
"github.com/trueforge-org/truecharts/clustertool/pkg/talassist"
)
var advBootstrapLongHelp = strings.TrimSpace(`
@@ -15,24 +15,24 @@ var advBootstrapLongHelp = strings.TrimSpace(`
`)
var bootstrap = &cobra.Command{
Use: "bootstrap",
Short: "bootstrap first Talos Node",
Example: "clustertool talos bootstrap",
Long: advBootstrapLongHelp,
Run: bootstrapfunc,
Use: "bootstrap",
Short: "bootstrap first Talos Node",
Example: "clustertool talos bootstrap",
Long: advBootstrapLongHelp,
Run: bootstrapfunc,
}
func bootstrapfunc(cmd *cobra.Command, args []string) {
if helper.GetYesOrNo("Do you want to also run the complete ClusterTool Bootstrap, besides just talos? (yes/no) [y/n]: ") {
initfiles.LoadTalEnv(false)
talassist.LoadTalConfig()
gencmd.RunBootstrap(args)
} else {
bootstrapcmds := gencmd.GenPlain("bootstrap", talassist.TalConfig.Nodes[0].IPAddress, []string{})
gencmd.ExecCmd(bootstrapcmds[0])
}
if helper.GetYesOrNo("Do you want to also run the complete ClusterTool Bootstrap, besides just talos? (yes/no) [y/n]: ") {
initfiles.LoadTalEnv(false)
talassist.LoadTalConfig()
gencmd.RunBootstrap(args)
} else {
bootstrapcmds := gencmd.GenPlain("bootstrap", talassist.TalConfig.Nodes[0].IPAddress, []string{})
gencmd.ExecCmd(bootstrapcmds[0])
}
}
func init() {
talosCmd.AddCommand(bootstrap)
talosCmd.AddCommand(bootstrap)
}
+23 -23
View File
@@ -1,15 +1,15 @@
package cmd
import (
"strings"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/gencmd"
"github.com/truecharts/public/clustertool/pkg/helper"
"github.com/truecharts/public/clustertool/pkg/initfiles"
"github.com/truecharts/public/clustertool/pkg/sops"
"github.com/truecharts/public/clustertool/pkg/talassist"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/gencmd"
"github.com/trueforge-org/truecharts/clustertool/pkg/helper"
"github.com/trueforge-org/truecharts/clustertool/pkg/initfiles"
"github.com/trueforge-org/truecharts/clustertool/pkg/sops"
"github.com/trueforge-org/truecharts/clustertool/pkg/talassist"
)
var advHealthLongHelp = strings.TrimSpace(`
@@ -17,22 +17,22 @@ var advHealthLongHelp = strings.TrimSpace(`
`)
var health = &cobra.Command{
Use: "health",
Short: "Check Talos Cluster Health",
Example: "clustertool talos 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)
}
initfiles.LoadTalEnv(false)
talassist.LoadTalConfig()
log.Info().Msg("Running Cluster HealthCheck")
healthcmd := gencmd.GenPlain("health", helper.TalEnv["VIP_IP"], []string{})
gencmd.ExecCmd(healthcmd[0])
},
Use: "health",
Short: "Check Talos Cluster Health",
Example: "clustertool talos 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)
}
initfiles.LoadTalEnv(false)
talassist.LoadTalConfig()
log.Info().Msg("Running Cluster HealthCheck")
healthcmd := gencmd.GenPlain("health", helper.TalEnv["VIP_IP"], []string{})
gencmd.ExecCmd(healthcmd[0])
},
}
func init() {
talosCmd.AddCommand(health)
talosCmd.AddCommand(health)
}
+33 -33
View File
@@ -1,14 +1,14 @@
package cmd
import (
"strings"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/gencmd"
"github.com/truecharts/public/clustertool/pkg/initfiles"
"github.com/truecharts/public/clustertool/pkg/sops"
"github.com/truecharts/public/clustertool/pkg/talassist"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/gencmd"
"github.com/trueforge-org/truecharts/clustertool/pkg/initfiles"
"github.com/trueforge-org/truecharts/clustertool/pkg/sops"
"github.com/trueforge-org/truecharts/clustertool/pkg/talassist"
)
var advKubeconfigLongHelp = strings.TrimSpace(`
@@ -16,37 +16,37 @@ var advKubeconfigLongHelp = strings.TrimSpace(`
`)
var kubeconfig = &cobra.Command{
Use: "kubeconfig",
Short: "kubeconfig for Talos Cluster",
Example: "clustertool talos kubeconfig <NodeIP>",
Long: advResetLongHelp,
Run: func(cmd *cobra.Command, args []string) {
var extraArgs []string
node := ""
Use: "kubeconfig",
Short: "kubeconfig for Talos Cluster",
Example: "clustertool talos kubeconfig <NodeIP>",
Long: advResetLongHelp,
Run: func(cmd *cobra.Command, args []string) {
var extraArgs []string
node := ""
if len(args) > 1 {
extraArgs = args[1:]
}
if len(args) >= 1 {
node = args[0]
if args[0] == "all" {
node = ""
}
}
if len(args) > 1 {
extraArgs = args[1:]
}
if len(args) >= 1 {
node = args[0]
if args[0] == "all" {
node = ""
}
}
if err := sops.DecryptFiles(); err != nil {
log.Info().Msgf("Error decrypting files: %v\n", err)
}
initfiles.LoadTalEnv(false)
talassist.LoadTalConfig()
log.Info().Msg("Running Cluster kubeconfig")
if err := sops.DecryptFiles(); err != nil {
log.Info().Msgf("Error decrypting files: %v\n", err)
}
initfiles.LoadTalEnv(false)
talassist.LoadTalConfig()
log.Info().Msg("Running Cluster kubeconfig")
taloscmds := gencmd.GenPlain("kubeconfig", node, extraArgs)
gencmd.ExecCmds(taloscmds, true)
taloscmds := gencmd.GenPlain("kubeconfig", node, extraArgs)
gencmd.ExecCmds(taloscmds, true)
},
},
}
func init() {
talosCmd.AddCommand(kubeconfig)
talosCmd.AddCommand(kubeconfig)
}
+33 -33
View File
@@ -1,14 +1,14 @@
package cmd
import (
"strings"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/gencmd"
"github.com/truecharts/public/clustertool/pkg/initfiles"
"github.com/truecharts/public/clustertool/pkg/sops"
"github.com/truecharts/public/clustertool/pkg/talassist"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/gencmd"
"github.com/trueforge-org/truecharts/clustertool/pkg/initfiles"
"github.com/trueforge-org/truecharts/clustertool/pkg/sops"
"github.com/trueforge-org/truecharts/clustertool/pkg/talassist"
)
var advResetLongHelp = strings.TrimSpace(`
@@ -16,38 +16,38 @@ var advResetLongHelp = strings.TrimSpace(`
`)
var reset = &cobra.Command{
Use: "reset",
Short: "Reset Talos Nodes and Kubernetes",
Example: "clustertool talos reset <NodeIP>",
Long: advResetLongHelp,
Run: func(cmd *cobra.Command, args []string) {
var extraArgs []string
node := ""
Use: "reset",
Short: "Reset Talos Nodes and Kubernetes",
Example: "clustertool talos reset <NodeIP>",
Long: advResetLongHelp,
Run: func(cmd *cobra.Command, args []string) {
var extraArgs []string
node := ""
if len(args) > 1 {
extraArgs = args[1:]
}
if len(args) >= 1 {
node = args[0]
if args[0] == "all" {
node = ""
}
}
if len(args) > 1 {
extraArgs = args[1:]
}
if len(args) >= 1 {
node = args[0]
if args[0] == "all" {
node = ""
}
}
if err := sops.DecryptFiles(); err != nil {
log.Info().Msgf("Error decrypting files: %v\n", err)
}
initfiles.LoadTalEnv(false)
talassist.LoadTalConfig()
if err := sops.DecryptFiles(); err != nil {
log.Info().Msgf("Error decrypting files: %v\n", err)
}
initfiles.LoadTalEnv(false)
talassist.LoadTalConfig()
log.Info().Msg("Running Cluster node Reset")
log.Info().Msg("Running Cluster node Reset")
taloscmds := gencmd.GenPlain("reset", node, extraArgs)
gencmd.ExecCmds(taloscmds, true)
taloscmds := gencmd.GenPlain("reset", node, extraArgs)
gencmd.ExecCmds(taloscmds, true)
},
},
}
func init() {
talosCmd.AddCommand(reset)
talosCmd.AddCommand(reset)
}
+40 -40
View File
@@ -1,15 +1,15 @@
package cmd
import (
"strings"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/gencmd"
"github.com/truecharts/public/clustertool/pkg/helper"
"github.com/truecharts/public/clustertool/pkg/initfiles"
"github.com/truecharts/public/clustertool/pkg/sops"
"github.com/truecharts/public/clustertool/pkg/talassist"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/trueforge-org/truecharts/clustertool/pkg/gencmd"
"github.com/trueforge-org/truecharts/clustertool/pkg/helper"
"github.com/trueforge-org/truecharts/clustertool/pkg/initfiles"
"github.com/trueforge-org/truecharts/clustertool/pkg/sops"
"github.com/trueforge-org/truecharts/clustertool/pkg/talassist"
)
var upgradeLongHelp = strings.TrimSpace(`
@@ -21,46 +21,46 @@ On top of this, after upgrading Talos on all nodes, it also executes kubernetes-
`)
var upgrade = &cobra.Command{
Use: "upgrade",
Short: "Upgrade Talos Nodes and Kubernetes",
Example: "clustertool talos upgrade <NodeIP>",
Long: upgradeLongHelp,
Run: func(cmd *cobra.Command, args []string) {
var extraArgs []string
node := ""
Use: "upgrade",
Short: "Upgrade Talos Nodes and Kubernetes",
Example: "clustertool talos upgrade <NodeIP>",
Long: upgradeLongHelp,
Run: func(cmd *cobra.Command, args []string) {
var extraArgs []string
node := ""
if len(args) > 1 {
extraArgs = args[1:]
}
if len(args) >= 1 {
node = args[0]
if args[0] == "all" {
node = ""
}
}
if len(args) > 1 {
extraArgs = args[1:]
}
if len(args) >= 1 {
node = args[0]
if args[0] == "all" {
node = ""
}
}
if err := sops.DecryptFiles(); err != nil {
log.Info().Msgf("Error decrypting files: %v\n", err)
}
initfiles.LoadTalEnv(false)
talassist.LoadTalConfig()
if err := sops.DecryptFiles(); err != nil {
log.Info().Msgf("Error decrypting files: %v\n", err)
}
initfiles.LoadTalEnv(false)
talassist.LoadTalConfig()
log.Info().Msg("Running Cluster Upgrade")
log.Info().Msg("Running Cluster Upgrade")
taloscmds := gencmd.GenUpgrade(node, extraArgs)
gencmd.ExecCmds(taloscmds, true)
taloscmds := gencmd.GenUpgrade(node, extraArgs)
gencmd.ExecCmds(taloscmds, true)
log.Info().Msg("Running Kubernetes Upgrade")
kubeUpgradeCmd := gencmd.GenKubeUpgrade(helper.TalEnv["VIP_IP"])
gencmd.ExecCmd(kubeUpgradeCmd)
log.Info().Msg("Running Kubernetes Upgrade")
kubeUpgradeCmd := gencmd.GenKubeUpgrade(helper.TalEnv["VIP_IP"])
gencmd.ExecCmd(kubeUpgradeCmd)
log.Info().Msg("(re)Loading KubeConfig)")
kubeconfigcmds := gencmd.GenPlain("health", helper.TalEnv["VIP_IP"], []string{"-f"})
gencmd.ExecCmd(kubeconfigcmds[0])
log.Info().Msg("(re)Loading KubeConfig)")
kubeconfigcmds := gencmd.GenPlain("health", helper.TalEnv["VIP_IP"], []string{"-f"})
gencmd.ExecCmd(kubeconfigcmds[0])
},
},
}
func init() {
talosCmd.AddCommand(upgrade)
talosCmd.AddCommand(upgrade)
}