Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package terragrunt for openSUSE:Factory 
checked in at 2023-06-01 17:19:41
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/terragrunt (Old)
 and      /work/SRC/openSUSE:Factory/.terragrunt.new.2531 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "terragrunt"

Thu Jun  1 17:19:41 2023 rev:50 rq:1090121 version:0.45.18

Changes:
--------
--- /work/SRC/openSUSE:Factory/terragrunt/terragrunt.changes    2023-05-31 
21:54:33.289025742 +0200
+++ /work/SRC/openSUSE:Factory/.terragrunt.new.2531/terragrunt.changes  
2023-06-01 17:19:51.582281062 +0200
@@ -1,0 +2,6 @@
+Wed May 31 13:07:18 UTC 2023 - ka...@b1-systems.de
+
+- Update to version 0.45.18:
+  * feat: implement hclfmt diff output (#2570)
+
+-------------------------------------------------------------------

Old:
----
  terragrunt-0.45.17.obscpio

New:
----
  terragrunt-0.45.18.obscpio

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

Other differences:
------------------
++++++ terragrunt.spec ++++++
--- /var/tmp/diff_new_pack.icz84a/_old  2023-06-01 17:19:52.586287014 +0200
+++ /var/tmp/diff_new_pack.icz84a/_new  2023-06-01 17:19:52.590287038 +0200
@@ -19,7 +19,7 @@
 %define __arch_install_post export NO_BRP_STRIP_DEBUG=true
 
 Name:           terragrunt
-Version:        0.45.17
+Version:        0.45.18
 Release:        0
 Summary:        Thin wrapper for Terraform for working with multiple Terraform 
modules
 License:        MIT

++++++ _service ++++++
--- /var/tmp/diff_new_pack.icz84a/_old  2023-06-01 17:19:52.622287227 +0200
+++ /var/tmp/diff_new_pack.icz84a/_new  2023-06-01 17:19:52.626287251 +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.45.17</param>
+    <param name="revision">v0.45.18</param>
     <param name="versionformat">@PARENT_TAG@</param>
     <param name="changesgenerate">enable</param>
     <param name="versionrewrite-pattern">v(.*)</param>

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.icz84a/_old  2023-06-01 17:19:52.646287370 +0200
+++ /var/tmp/diff_new_pack.icz84a/_new  2023-06-01 17:19:52.650287394 +0200
@@ -1,6 +1,6 @@
 <servicedata>
 <service name="tar_scm">
                 <param 
name="url">https://github.com/gruntwork-io/terragrunt</param>
-              <param 
name="changesrevision">9154ad0ff23e876c9e2bfe0ad7948e179c2bbdae</param></service></servicedata>
+              <param 
name="changesrevision">1494e777b1f2ce18797ce1c9e46859bdef7f33ed</param></service></servicedata>
 (No newline at EOF)
 

++++++ terragrunt-0.45.17.obscpio -> terragrunt-0.45.18.obscpio ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/terragrunt-0.45.17/cli/args.go 
new/terragrunt-0.45.18/cli/args.go
--- old/terragrunt-0.45.17/cli/args.go  2023-05-30 13:50:03.000000000 +0200
+++ new/terragrunt-0.45.18/cli/args.go  2023-05-31 13:37:00.000000000 +0200
@@ -232,6 +232,7 @@
        opts.ModulesThatInclude = modulesThatInclude
        opts.StrictInclude = strictInclude
        opts.Check = parseBooleanArg(args, optTerragruntCheck, 
os.Getenv("TERRAGRUNT_CHECK") == "true")
+       opts.Diff = parseBooleanArg(args, optTerragruntDiff, 
os.Getenv("TERRAGRUNT_DIFF") == "true")
        opts.HclFile = filepath.ToSlash(terragruntHclFilePath)
        opts.AwsProviderPatchOverrides = awsProviderPatchOverrides
        opts.FetchDependencyOutputFromState = parseBooleanArg(args, 
optTerragruntFetchDependencyOutputFromState, 
os.Getenv("TERRAGRUNT_FETCH_DEPENDENCY_OUTPUT_FROM_STATE") == "true")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/terragrunt-0.45.17/cli/cli_app.go 
new/terragrunt-0.45.18/cli/cli_app.go
--- old/terragrunt-0.45.17/cli/cli_app.go       2023-05-30 13:50:03.000000000 
+0200
+++ new/terragrunt-0.45.18/cli/cli_app.go       2023-05-31 13:37:00.000000000 
+0200
@@ -53,6 +53,7 @@
        optTerragruntStrictInclude                  = 
"terragrunt-strict-include"
        optTerragruntParallelism                    = "terragrunt-parallelism"
        optTerragruntCheck                          = "terragrunt-check"
+       optTerragruntDiff                           = "terragrunt-diff"
        optTerragruntHCLFmt                         = "terragrunt-hclfmt-file"
        optTerragruntDebug                          = "terragrunt-debug"
        optTerragruntOverrideAttr                   = "terragrunt-override-attr"
@@ -77,6 +78,7 @@
        optTerragruntNoAutoRetry,
        optTerragruntNoAutoApprove,
        optTerragruntCheck,
+       optTerragruntDiff,
        optTerragruntStrictInclude,
        optTerragruntDebug,
        optTerragruntFetchDependencyOutputFromState,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/terragrunt-0.45.17/cli/hclfmt.go 
new/terragrunt-0.45.18/cli/hclfmt.go
--- old/terragrunt-0.45.17/cli/hclfmt.go        2023-05-30 13:50:03.000000000 
+0200
+++ new/terragrunt-0.45.18/cli/hclfmt.go        2023-05-31 13:37:00.000000000 
+0200
@@ -5,6 +5,7 @@
        "fmt"
        "io/ioutil"
        "os"
+       "os/exec"
        "path/filepath"
        "strings"
 
@@ -93,6 +94,19 @@
 
        fileUpdated := !bytes.Equal(newContents, contents)
 
+       if terragruntOptions.Diff && fileUpdated {
+               diff, err := bytesDiff(contents, newContents, tgHclFile)
+               if err != nil {
+                       terragruntOptions.Logger.Errorf("Failed to generate 
diff for %s", tgHclFile)
+                       return err
+               }
+               _, err = fmt.Fprintf(terragruntOptions.Writer, "%s\n", diff)
+               if err != nil {
+                       terragruntOptions.Logger.Errorf("Failed to print diff 
for %s", tgHclFile)
+                       return err
+               }
+       }
+
        if terragruntOptions.Check && fileUpdated {
                return fmt.Errorf("Invalid file format %s", tgHclFile)
        }
@@ -116,3 +130,37 @@
        }
        return nil
 }
+
+// bytesDiff uses GNU diff to display the differences between the contents of 
HCL file before and after formatting
+func bytesDiff(b1, b2 []byte, path string) ([]byte, error) {
+       f1, err := ioutil.TempFile("", "")
+       if err != nil {
+               return nil, err
+       }
+       defer func() {
+               f1.Close()
+               os.Remove(f1.Name())
+       }()
+
+       f2, err := ioutil.TempFile("", "")
+       if err != nil {
+               return nil, err
+       }
+       defer func() {
+               f2.Close()
+               os.Remove(f2.Name())
+       }()
+       if _, err := f1.Write(b1); err != nil {
+               return nil, err
+       }
+       if _, err := f2.Write(b2); err != nil {
+               return nil, err
+       }
+       data, err := exec.Command("diff", "--label="+filepath.Join("old", 
path), "--label="+filepath.Join("new/", path), "-u", f1.Name(), 
f2.Name()).CombinedOutput()
+       if len(data) > 0 {
+               // diff exits with a non-zero status when the files don't match.
+               // Ignore that failure as long as we get output.
+               err = nil
+       }
+       return data, err
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/terragrunt-0.45.17/docs/_docs/01_getting-started/configuration.md 
new/terragrunt-0.45.18/docs/_docs/01_getting-started/configuration.md
--- old/terragrunt-0.45.17/docs/_docs/01_getting-started/configuration.md       
2023-05-30 13:50:03.000000000 +0200
+++ new/terragrunt-0.45.18/docs/_docs/01_getting-started/configuration.md       
2023-05-31 13:37:00.000000000 +0200
@@ -118,4 +118,6 @@
 
   - `root/qa/services/service01/terragrunt.hcl`
 
+You can set `--terragrunt-diff` option. `terragrunt hclfmt --terragrunt-check` 
will output diff in unified format which can be redirected to your favourite 
diff tool. `diff` utility must be presented in PATH.
+
 Additionally, there’s a flag `--terragrunt-check`. `terragrunt hclfmt 
--terragrunt-check` will only verify if the files are correctly formatted 
**without rewriting** them. The command will return exit status 1 if any 
matching files are improperly formatted, or 0 if all matching .hcl files are 
correctly formatted.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/terragrunt-0.45.17/docs/_docs/04_reference/cli-options.md 
new/terragrunt-0.45.18/docs/_docs/04_reference/cli-options.md
--- old/terragrunt-0.45.17/docs/_docs/04_reference/cli-options.md       
2023-05-30 13:50:03.000000000 +0200
+++ new/terragrunt-0.45.18/docs/_docs/04_reference/cli-options.md       
2023-05-31 13:37:00.000000000 +0200
@@ -800,6 +800,16 @@
 command to exit with exit code 1 if there are any files that are not formatted.
 
 
+### terragrunt-diff
+
+**CLI Arg**: `--terragrunt-diff`<br/>
+**Environment Variable**: `TERRAGRUNT_DIFF` (set to `true`)
+**Commands**:
+- [hclfmt](#hclfmt)
+
+When passed in, running `hclfmt` will print diff between original and modified 
file versions.
+
+
 ### terragrunt-hclfmt-file
 
 **CLI Arg**: `--terragrunt-hclfmt-file`
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/terragrunt-0.45.17/options/options.go 
new/terragrunt-0.45.18/options/options.go
--- old/terragrunt-0.45.17/options/options.go   2023-05-30 13:50:03.000000000 
+0200
+++ new/terragrunt-0.45.18/options/options.go   2023-05-31 13:37:00.000000000 
+0200
@@ -162,6 +162,9 @@
        // Enable check mode, by default it's disabled.
        Check bool
 
+       // Show diff, by default it's disabled.
+       Diff bool
+
        // The file which hclfmt should be specifically run on
        HclFile string
 
@@ -281,6 +284,7 @@
                StrictInclude:                  false,
                Parallelism:                    DEFAULT_PARALLELISM,
                Check:                          false,
+               Diff:                           false,
                FetchDependencyOutputFromState: false,
                UsePartialParseConfigCache:     false,
                OutputPrefix:                   "",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/terragrunt-0.45.17/test/fixture-hclfmt-diff/expected.diff 
new/terragrunt-0.45.18/test/fixture-hclfmt-diff/expected.diff
--- old/terragrunt-0.45.17/test/fixture-hclfmt-diff/expected.diff       
1970-01-01 01:00:00.000000000 +0100
+++ new/terragrunt-0.45.18/test/fixture-hclfmt-diff/expected.diff       
2023-05-31 13:37:00.000000000 +0200
@@ -0,0 +1,19 @@
+@@ -1,11 +1,11 @@
+ inputs = {
+-# comments
+-  foo =                               "bar"
+-  bar="baz"
+-  inputs = "disjoint"
++  # comments
++  foo      = "bar"
++  bar      = "baz"
++  inputs   = "disjoint"
+   disjoint = true
+   listInput = [
+-"foo",
+-"bar",
+-]
++    "foo",
++    "bar",
++  ]
+ }
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/terragrunt-0.45.17/test/fixture-hclfmt-diff/terragrunt.hcl 
new/terragrunt-0.45.18/test/fixture-hclfmt-diff/terragrunt.hcl
--- old/terragrunt-0.45.17/test/fixture-hclfmt-diff/terragrunt.hcl      
1970-01-01 01:00:00.000000000 +0100
+++ new/terragrunt-0.45.18/test/fixture-hclfmt-diff/terragrunt.hcl      
2023-05-31 13:37:00.000000000 +0200
@@ -0,0 +1,11 @@
+inputs = {
+# comments
+  foo =                               "bar"
+  bar="baz"
+  inputs = "disjoint"
+  disjoint = true
+  listInput = [
+"foo",
+"bar",
+]
+}
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/terragrunt-0.45.17/test/integration_test.go 
new/terragrunt-0.45.18/test/integration_test.go
--- old/terragrunt-0.45.17/test/integration_test.go     2023-05-30 
13:50:03.000000000 +0200
+++ new/terragrunt-0.45.18/test/integration_test.go     2023-05-31 
13:37:00.000000000 +0200
@@ -146,6 +146,7 @@
        TEST_FIXTURE_PARALLEL_RUN                               = 
"fixture-parallel-run"
        TEST_FIXTURE_INIT_ERROR                                 = 
"fixture-init-error"
        TEST_FIXTURE_MODULE_PATH_ERROR                          = 
"fixture-module-path-in-error"
+       TEST_FIXTURE_HCLFMT_DIFF                                = 
"fixture-hclfmt-diff"
        TERRAFORM_BINARY                                        = "terraform"
        TERRAFORM_FOLDER                                        = ".terraform"
        TERRAFORM_STATE                                         = 
"terraform.tfstate"
@@ -5468,6 +5469,30 @@
        assert.Contains(t, err.Error(), fmt.Sprintf("[%s] exit status 1", 
util.JoinPath(tmpEnvPath, TEST_FIXTURE_MODULE_PATH_ERROR, "d1")))
 }
 
+func TestHclFmtDiff(t *testing.T) {
+       t.Parallel()
+
+       cleanupTerraformFolder(t, TEST_FIXTURE_HCLFMT_DIFF)
+       tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_HCLFMT_DIFF)
+       rootPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_HCLFMT_DIFF)
+
+       stdout := bytes.Buffer{}
+       stderr := bytes.Buffer{}
+
+       require.NoError(
+               t,
+               runTerragruntCommand(t, fmt.Sprintf("terragrunt hclfmt 
--terragrunt-diff --terragrunt-working-dir %s", rootPath), &stdout, &stderr),
+       )
+
+       output := stdout.String()
+
+       expectedDiff, err := ioutil.ReadFile(util.JoinPath(rootPath, 
"expected.diff"))
+       assert.NoError(t, err)
+
+       logBufferContentsLineByLine(t, stdout, "output")
+       assert.Contains(t, output, string(expectedDiff))
+}
+
 func validateOutput(t *testing.T, outputs map[string]TerraformOutput, key 
string, value interface{}) {
        t.Helper()
        output, hasPlatform := outputs[key]

++++++ terragrunt.obsinfo ++++++
--- /var/tmp/diff_new_pack.icz84a/_old  2023-06-01 17:19:53.358291590 +0200
+++ /var/tmp/diff_new_pack.icz84a/_new  2023-06-01 17:19:53.362291614 +0200
@@ -1,5 +1,5 @@
 name: terragrunt
-version: 0.45.17
-mtime: 1685447403
-commit: 9154ad0ff23e876c9e2bfe0ad7948e179c2bbdae
+version: 0.45.18
+mtime: 1685533020
+commit: 1494e777b1f2ce18797ce1c9e46859bdef7f33ed
 

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

Reply via email to