fix(clustertool): ensure clusterenv is imported on adv fluxbootstrap
This commit is contained in:
@@ -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)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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]: ") {
|
||||
|
||||
Reference in New Issue
Block a user