Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package terragrunt for openSUSE:Factory 
checked in at 2022-06-29 16:01:30
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/terragrunt (Old)
 and      /work/SRC/openSUSE:Factory/.terragrunt.new.1548 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "terragrunt"

Wed Jun 29 16:01:30 2022 rev:6 rq:985617 version:0.38.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/terragrunt/terragrunt.changes    2022-06-23 
12:32:57.556378479 +0200
+++ /work/SRC/openSUSE:Factory/.terragrunt.new.1548/terragrunt.changes  
2022-06-29 16:02:45.352734327 +0200
@@ -1,0 +2,6 @@
+Tue Jun 28 14:22:42 UTC 2022 - ka...@b1-systems.de
+
+- Update to version 0.38.2:
+  * #2045 Fixed pattern matching for error hooks  (#2101)
+
+-------------------------------------------------------------------

Old:
----
  terragrunt-0.38.1.tar.gz

New:
----
  terragrunt-0.38.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ terragrunt.spec ++++++
--- /var/tmp/diff_new_pack.9FMgcc/_old  2022-06-29 16:02:46.440735775 +0200
+++ /var/tmp/diff_new_pack.9FMgcc/_new  2022-06-29 16:02:46.444735780 +0200
@@ -19,7 +19,7 @@
 %define __arch_install_post export NO_BRP_STRIP_DEBUG=true
 
 Name:           terragrunt
-Version:        0.38.1
+Version:        0.38.2
 Release:        0
 Summary:        Thin wrapper for Terraform for working with multiple Terraform 
modules
 License:        MIT

++++++ _service ++++++
--- /var/tmp/diff_new_pack.9FMgcc/_old  2022-06-29 16:02:46.476735823 +0200
+++ /var/tmp/diff_new_pack.9FMgcc/_new  2022-06-29 16:02:46.476735823 +0200
@@ -3,7 +3,7 @@
     <param name="url">https://github.com/gruntwork-io/terragrunt</param>
     <param name="scm">git</param>
     <param name="exclude">.git</param>
-    <param name="revision">v0.38.1</param>
+    <param name="revision">v0.38.2</param>
     <param name="versionformat">@PARENT_TAG@</param>
     <param name="changesgenerate">enable</param>
     <param name="versionrewrite-pattern">v(.*)</param>
@@ -16,7 +16,7 @@
     <param name="compression">gz</param>
   </service>
   <service name="go_modules" mode="disabled">
-    <param name="archive">terragrunt-0.38.1.tar.gz</param>
+    <param name="archive">terragrunt-0.38.2.tar.gz</param>
   </service>
 </services>
 

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.9FMgcc/_old  2022-06-29 16:02:46.500735855 +0200
+++ /var/tmp/diff_new_pack.9FMgcc/_new  2022-06-29 16:02:46.500735855 +0200
@@ -1,6 +1,6 @@
 <servicedata>
 <service name="tar_scm">
                 <param 
name="url">https://github.com/gruntwork-io/terragrunt</param>
-              <param 
name="changesrevision">47f16b7b07359fa0f5d3e511954414932ec646dc</param></service></servicedata>
+              <param 
name="changesrevision">1cb5c30f36ac698e2f989aa552dd105ad0285059</param></service></servicedata>
 (No newline at EOF)
 

++++++ terragrunt-0.38.1.tar.gz -> terragrunt-0.38.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/terragrunt-0.38.1/cli/cli_app.go 
new/terragrunt-0.38.2/cli/cli_app.go
--- old/terragrunt-0.38.1/cli/cli_app.go        2022-06-22 21:37:11.000000000 
+0200
+++ new/terragrunt-0.38.2/cli/cli_app.go        2022-06-28 13:14:28.000000000 
+0200
@@ -615,8 +615,30 @@
 
        terragruntOptions.Logger.Debugf("Detected %d error Hooks", len(hooks))
 
+       customMultierror := multierror.Error{
+               Errors: previousExecErrors.Errors,
+               ErrorFormat: func(err []error) string {
+                       result := ""
+                       for _, e := range err {
+                               errorMessage := e.Error()
+                               // Check if is process execution error and try 
to extract output
+                               // 
https://github.com/gruntwork-io/terragrunt/issues/2045
+                               originalError := errors.Unwrap(e)
+                               if originalError != nil {
+                                       processError, cast := 
originalError.(shell.ProcessExecutionError)
+                                       if cast {
+                                               errorMessage = 
fmt.Sprintf("%s\n%s", processError.StdOut, processError.Stderr)
+                                       }
+                               }
+                               result = fmt.Sprintf("%s\n%s", result, 
errorMessage)
+                       }
+                       return result
+               },
+       }
+       errorMessage := customMultierror.Error()
+
        for _, curHook := range hooks {
-               if util.MatchesAny(curHook.OnErrors, 
previousExecErrors.GoString()) && util.ListContainsElement(curHook.Commands, 
terragruntOptions.TerraformCommand) {
+               if util.MatchesAny(curHook.OnErrors, errorMessage) && 
util.ListContainsElement(curHook.Commands, terragruntOptions.TerraformCommand) {
                        terragruntOptions.Logger.Infof("Executing hook: %s", 
curHook.Name)
                        workingDir := ""
                        if curHook.WorkingDir != nil {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/terragrunt-0.38.1/shell/run_shell_cmd.go 
new/terragrunt-0.38.2/shell/run_shell_cmd.go
--- old/terragrunt-0.38.1/shell/run_shell_cmd.go        2022-06-22 
21:37:11.000000000 +0200
+++ new/terragrunt-0.38.2/shell/run_shell_cmd.go        2022-06-28 
13:14:28.000000000 +0200
@@ -124,6 +124,14 @@
                Stderr: stderrBuf.String(),
        }
 
+       if err != nil {
+               err = ProcessExecutionError{
+                       Err:    err,
+                       StdOut: stdoutBuf.String(),
+                       Stderr: stderrBuf.String(),
+               }
+       }
+
        return &cmdOutput, errors.WithStackTrace(err)
 }
 
@@ -216,3 +224,18 @@
        }
        return strings.TrimSpace(cmd.Stdout), nil
 }
+
+// ProcessExecutionError - error returned when a command fails, contains 
StdOut and StdErr
+type ProcessExecutionError struct {
+       Err    error
+       StdOut string
+       Stderr string
+}
+
+func (err ProcessExecutionError) Error() string {
+       return err.Err.Error()
+}
+
+func (err ProcessExecutionError) ExitStatus() (int, error) {
+       return GetExitCode(err.Err)
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/terragrunt-0.38.1/test/fixture-hooks/error-hooks/main.tf 
new/terragrunt-0.38.2/test/fixture-hooks/error-hooks/main.tf
--- old/terragrunt-0.38.1/test/fixture-hooks/error-hooks/main.tf        
1970-01-01 01:00:00.000000000 +0100
+++ new/terragrunt-0.38.2/test/fixture-hooks/error-hooks/main.tf        
2022-06-28 13:14:28.000000000 +0200
@@ -0,0 +1,4 @@
+
+data "local_file" "read_not_existing_file" {
+  filename = "${path.module}/not-existing-file.txt"
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/terragrunt-0.38.1/test/fixture-hooks/error-hooks/terragrunt.hcl 
new/terragrunt-0.38.2/test/fixture-hooks/error-hooks/terragrunt.hcl
--- old/terragrunt-0.38.1/test/fixture-hooks/error-hooks/terragrunt.hcl 
1970-01-01 01:00:00.000000000 +0100
+++ new/terragrunt-0.38.2/test/fixture-hooks/error-hooks/terragrunt.hcl 
2022-06-28 13:14:28.000000000 +0200
@@ -0,0 +1,29 @@
+terraform {
+  source = "."
+
+  error_hook "pattern_matching_hook" {
+    commands = ["apply"]
+    execute  = ["echo", "pattern_matching_hook"]
+    on_errors = [
+      "not-existing-file.txt"
+    ]
+  }
+
+  error_hook "catch_all_matching_hook" {
+    commands = ["apply"]
+    execute  = ["echo", "catch_all_matching_hook"]
+    on_errors = [
+      ".*"
+    ]
+  }
+
+  error_hook "not_matching_hook" {
+    commands = ["apply"]
+    execute  = ["echo", "not_matching_hook"]
+    on_errors = [
+      ".*random-not-matching-pattern.*"
+    ]
+  }
+
+}
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/terragrunt-0.38.1/test/fixture-hooks/skip-on-error/terragrunt.hcl 
new/terragrunt-0.38.2/test/fixture-hooks/skip-on-error/terragrunt.hcl
--- old/terragrunt-0.38.1/test/fixture-hooks/skip-on-error/terragrunt.hcl       
2022-06-22 21:37:11.000000000 +0200
+++ new/terragrunt-0.38.2/test/fixture-hooks/skip-on-error/terragrunt.hcl       
2022-06-28 13:14:28.000000000 +0200
@@ -34,4 +34,17 @@
     execute   = ["echo", "ERROR_HOOK_EXECUTED"]
     on_errors = [".*"]
   }
+
+  error_hook "not_matching_error_hook" {
+    commands  = ["apply", "plan"]
+    execute   = ["echo", "NOT_MATCHING_ERROR_HOOK"]
+    on_errors = [".*custom-matcher.*"]
+  }
+
+  # hook to match error "executable file not found in $PATH"
+  error_hook "e" {
+    commands  = ["apply", "plan"]
+    execute   = ["echo", "PATTERN_MATCHING_ERROR_HOOK"]
+    on_errors = [".*executable file not found.*"]
+  }
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/terragrunt-0.38.1/test/integration_test.go 
new/terragrunt-0.38.2/test/integration_test.go
--- old/terragrunt-0.38.1/test/integration_test.go      2022-06-22 
21:37:11.000000000 +0200
+++ new/terragrunt-0.38.2/test/integration_test.go      2022-06-28 
13:14:28.000000000 +0200
@@ -78,6 +78,7 @@
        TEST_FIXTURE_HOOKS_BEFORE_AND_AFTER_PATH                = 
"fixture-hooks/before-and-after"
        TEST_FIXTURE_HOOKS_BEFORE_AFTER_AND_ERROR_MERGE_PATH    = 
"fixture-hooks/before-after-and-error-merge"
        TEST_FIXTURE_HOOKS_SKIP_ON_ERROR_PATH                   = 
"fixture-hooks/skip-on-error"
+       TEST_FIXTURE_ERROR_HOOKS_PATH                           = 
"fixture-hooks/error-hooks"
        TEST_FIXTURE_HOOKS_ONE_ARG_ACTION_PATH                  = 
"fixture-hooks/one-arg-action"
        TEST_FIXTURE_HOOKS_EMPTY_STRING_COMMAND_PATH            = 
"fixture-hooks/bad-arg-action/empty-string-command"
        TEST_FIXTURE_HOOKS_EMPTY_COMMAND_LIST_PATH              = 
"fixture-hooks/bad-arg-action/empty-command-list"
@@ -403,19 +404,43 @@
 
        err := runTerragruntCommand(t, fmt.Sprintf("terragrunt apply 
-auto-approve --terragrunt-non-interactive --terragrunt-working-dir %s", 
rootPath), &stdout, &stderr)
 
+       assert.Error(t, err)
+
        output := stderr.String()
-       if err != nil {
-               assert.Contains(t, output, "BEFORE_SHOULD_DISPLAY")
-               assert.NotContains(t, output, "BEFORE_NODISPLAY")
 
-               assert.Contains(t, output, "AFTER_SHOULD_DISPLAY")
-               assert.NotContains(t, output, "AFTER_NODISPLAY")
+       assert.Contains(t, output, "BEFORE_SHOULD_DISPLAY")
+       assert.NotContains(t, output, "BEFORE_NODISPLAY")
 
-               assert.Contains(t, output, "ERROR_HOOK_EXECUTED")
+       assert.Contains(t, output, "AFTER_SHOULD_DISPLAY")
+       assert.NotContains(t, output, "AFTER_NODISPLAY")
+
+       assert.Contains(t, output, "ERROR_HOOK_EXECUTED")
+       assert.NotContains(t, output, "NOT_MATCHING_ERROR_HOOK")
+       assert.Contains(t, output, "PATTERN_MATCHING_ERROR_HOOK")
+}
+
+func TestTerragruntCatchErrorsInTerraformExecution(t *testing.T) {
+       t.Parallel()
+
+       cleanupTerraformFolder(t, TEST_FIXTURE_ERROR_HOOKS_PATH)
+       tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_ERROR_HOOKS_PATH)
+       rootPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_ERROR_HOOKS_PATH)
+
+       var (
+               stdout bytes.Buffer
+               stderr bytes.Buffer
+       )
+
+       err := runTerragruntCommand(t, fmt.Sprintf("terragrunt apply 
-auto-approve --terragrunt-non-interactive --terragrunt-working-dir %s", 
rootPath), &stdout, &stderr)
+
+       assert.Error(t, err)
+
+       output := stderr.String()
+
+       assert.Contains(t, output, "pattern_matching_hook")
+       assert.Contains(t, output, "catch_all_matching_hook")
+       assert.NotContains(t, output, "not_matching_hook")
 
-       } else {
-               t.Error("Expected NO terragrunt execution due to previous 
errors but it did run.")
-       }
 }
 
 func TestTerragruntBeforeOneArgAction(t *testing.T) {

++++++ vendor.tar.gz ++++++
/work/SRC/openSUSE:Factory/terragrunt/vendor.tar.gz 
/work/SRC/openSUSE:Factory/.terragrunt.new.1548/vendor.tar.gz differ: char 5, 
line 1

Reply via email to