fix(clustertool): ensure clusterenv is imported on adv fluxbootstrap

This commit is contained in:
Kjeld Schouten
2024-10-21 14:56:58 +02:00
parent c2cc6ab3fc
commit 172d4f4d22
2 changed files with 17 additions and 1 deletions
+15
View File
@@ -3,8 +3,13 @@ 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{
@@ -12,6 +17,16 @@ var fluxbootstrap = &cobra.Command{
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()
_, 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)
},
}
+2 -1
View File
@@ -18,9 +18,10 @@ func init() {
// FluxBootstrap initializes the FluxCD bootstrapping process if GITHUB_REPOSITORY is set in TalEnv.
func FluxBootstrap(ctx context.Context) {
if helper.TalEnv["GITHUB_REPOSITORY"] != "" {
log.Info().Msg("GITHUB_Repository for Flux configured.")
if helper.GetYesOrNo("Do you want to bootstrap FluxCD as well? (yes/no) [y/n]: ") {
if helper.GetYesOrNo("Do you want to (re)bootstrap FluxCD as well? (yes/no) [y/n]: ") {
if err := bootstrapFluxCD(ctx); err != nil {
log.Fatal().Err(err).Msg("Error during FluxCD bootstrap")
if helper.GetYesOrNo("Do you want to retry? (yes/no) [y/n]: ") {