@@ -324,10 +324,8 @@ var initCmd = &cobra.Command{
324324
325325 // If encrypted file exists, decrypt it (don't require key - will generate if needed)
326326 if encryptedTalosconfigFileExists && ! talosconfigFileExists {
327- _ , err := handleTalosconfigEncryption (false )
328- if err != nil {
329- // If decryption fails (e.g., no key), continue to generate
330- }
327+ // If decryption fails (e.g., no key), continue to generate
328+ _ , _ = handleTalosconfigEncryption (false )
331329 talosconfigFileExists = fileExists (talosconfigFile )
332330 }
333331
@@ -347,7 +345,6 @@ var initCmd = &cobra.Command{
347345 if err = writeToDestination (data , talosconfigFile , 0o600 ); err != nil {
348346 return err
349347 }
350- talosconfigFileExists = true
351348 }
352349
353350 // Encrypt talosconfig if needed
@@ -385,7 +382,6 @@ var initCmd = &cobra.Command{
385382 if err != nil {
386383 return fmt .Errorf ("failed to generate key: %w" , err )
387384 }
388- keyFileExists = true // Update flag after creation
389385 keyWasCreated = keyCreated
390386 }
391387
@@ -417,7 +413,7 @@ var initCmd = &cobra.Command{
417413 if chartName == initCmdFlags .preset {
418414 file := filepath .Join (Config .RootDir , filepath .Join (parts [1 :]... ))
419415 if parts [len (parts )- 1 ] == "Chart.yaml" {
420- writeToDestination ([]byte (fmt .Sprintf (content , clusterName , Config .InitOptions .Version )), file , 0o644 )
416+ err = writeToDestination ([]byte (fmt .Sprintf (content , clusterName , Config .InitOptions .Version )), file , 0o644 )
421417 } else {
422418 err = writeToDestination ([]byte (content ), file , 0o644 )
423419 }
@@ -429,7 +425,7 @@ var initCmd = &cobra.Command{
429425 if chartName == "talm" {
430426 file := filepath .Join (Config .RootDir , filepath .Join ("charts" , path ))
431427 if parts [len (parts )- 1 ] == "Chart.yaml" {
432- writeToDestination ([]byte (fmt .Sprintf (content , "talm" , Config .InitOptions .Version )), file , 0o644 )
428+ err = writeToDestination ([]byte (fmt .Sprintf (content , "talm" , Config .InitOptions .Version )), file , 0o644 )
433429 } else {
434430 err = writeToDestination ([]byte (content ), file , 0o644 )
435431 }
@@ -856,7 +852,6 @@ func handleTalosconfigEncryption(requireKeyForDecrypt bool) (bool, error) {
856852 if keyCreated {
857853 fmt .Fprintf (os .Stderr , "Generated new encryption key: talm.key\n " )
858854 }
859- keyFileExists = true
860855 }
861856
862857 // Encrypt talosconfig
0 commit comments