diff --git a/clustertool/cmd/adv_fluxbootstrap.go b/clustertool/cmd/adv_fluxbootstrap.go index aa58568661b..34930b7a089 100644 --- a/clustertool/cmd/adv_fluxbootstrap.go +++ b/clustertool/cmd/adv_fluxbootstrap.go @@ -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) }, } diff --git a/clustertool/pkg/fluxhandler/bootstrap.go b/clustertool/pkg/fluxhandler/bootstrap.go index 327a2ad50e0..835c88e0ffc 100644 --- a/clustertool/pkg/fluxhandler/bootstrap.go +++ b/clustertool/pkg/fluxhandler/bootstrap.go @@ -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]: ") {