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-07-06 15:41:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/terragrunt (Old)
 and      /work/SRC/openSUSE:Factory/.terragrunt.new.1548 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "terragrunt"

Wed Jul  6 15:41:58 2022 rev:8 rq:986894 version:0.38.4

Changes:
--------
--- /work/SRC/openSUSE:Factory/terragrunt/terragrunt.changes    2022-07-02 
15:34:11.930986851 +0200
+++ /work/SRC/openSUSE:Factory/.terragrunt.new.1548/terragrunt.changes  
2022-07-06 15:42:09.938531911 +0200
@@ -1,0 +2,6 @@
+Tue Jul 05 14:19:25 UTC 2022 - ka...@b1-systems.de
+
+- Update to version 0.38.4:
+  * Use faster hashing approach when handling local module sources (#2168)
+
+-------------------------------------------------------------------

Old:
----
  terragrunt-0.38.3.tar.gz

New:
----
  terragrunt-0.38.4.tar.gz

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

Other differences:
------------------
++++++ terragrunt.spec ++++++
--- /var/tmp/diff_new_pack.qwZc1o/_old  2022-07-06 15:42:10.706533042 +0200
+++ /var/tmp/diff_new_pack.qwZc1o/_new  2022-07-06 15:42:10.714533054 +0200
@@ -19,7 +19,7 @@
 %define __arch_install_post export NO_BRP_STRIP_DEBUG=true
 
 Name:           terragrunt
-Version:        0.38.3
+Version:        0.38.4
 Release:        0
 Summary:        Thin wrapper for Terraform for working with multiple Terraform 
modules
 License:        MIT

++++++ _service ++++++
--- /var/tmp/diff_new_pack.qwZc1o/_old  2022-07-06 15:42:10.742533094 +0200
+++ /var/tmp/diff_new_pack.qwZc1o/_new  2022-07-06 15:42:10.746533101 +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.3</param>
+    <param name="revision">v0.38.4</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.3.tar.gz</param>
+    <param name="archive">terragrunt-0.38.4.tar.gz</param>
   </service>
 </services>
 

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.qwZc1o/_old  2022-07-06 15:42:10.762533124 +0200
+++ /var/tmp/diff_new_pack.qwZc1o/_new  2022-07-06 15:42:10.766533130 +0200
@@ -1,6 +1,6 @@
 <servicedata>
 <service name="tar_scm">
                 <param 
name="url">https://github.com/gruntwork-io/terragrunt</param>
-              <param 
name="changesrevision">7d143740c05ef9a5cc87414c5b22107bf3cb1425</param></service></servicedata>
+              <param 
name="changesrevision">48ff9d35066df8a7a49e6b854af95921618758ec</param></service></servicedata>
 (No newline at EOF)
 

++++++ terragrunt-0.38.3.tar.gz -> terragrunt-0.38.4.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/terragrunt-0.38.3/cli/download_source.go 
new/terragrunt-0.38.4/cli/download_source.go
--- old/terragrunt-0.38.3/cli/download_source.go        2022-06-30 
14:03:23.000000000 +0200
+++ new/terragrunt-0.38.4/cli/download_source.go        2022-07-05 
13:37:08.000000000 +0200
@@ -109,10 +109,10 @@
                return err
        }
 
-       currentVersion := terraformSource.EncodeSourceVersion()
-       // if source versions are different, create file to run init
+       currentVersion, err := terraformSource.EncodeSourceVersion()
+       // if source versions are different or calculating version failed, 
create file to run init
        // https://github.com/gruntwork-io/terragrunt/issues/1921
-       if previousVersion != currentVersion {
+       if previousVersion != currentVersion || err != nil {
                initFile := util.JoinPath(terraformSource.WorkingDir, 
moduleInitRequiredFile)
                f, createErr := os.Create(initFile)
                if createErr != nil {
@@ -144,7 +144,16 @@
                return false, nil
        }
 
-       currentVersion := terraformSource.EncodeSourceVersion()
+       currentVersion, err := terraformSource.EncodeSourceVersion()
+       // If we fail to calculate the source version (e.g. because walking the
+       // directory tree failed) use a random version instead, bypassing the 
cache.
+       if err != nil {
+               currentVersion, err = util.GenerateRandomSha256()
+               if err != nil {
+                       return false, err
+               }
+       }
+
        previousVersion, err := readVersionFile(terraformSource)
 
        if err != nil {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/terragrunt-0.38.3/cli/download_source_test.go 
new/terragrunt-0.38.4/cli/download_source_test.go
--- old/terragrunt-0.38.3/cli/download_source_test.go   2022-06-30 
14:03:23.000000000 +0200
+++ new/terragrunt-0.38.4/cli/download_source_test.go   2022-07-05 
13:37:08.000000000 +0200
@@ -11,6 +11,7 @@
        "testing"
 
        "github.com/gruntwork-io/terragrunt/errors"
+       "github.com/sirupsen/logrus"
 
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
@@ -21,7 +22,7 @@
        "github.com/gruntwork-io/terragrunt/util"
 )
 
-func TestAlreadyHaveLatestCodeLocalFilePathWithHashNoChanges(t *testing.T) {
+func TestAlreadyHaveLatestCodeLocalFilePathWithNoModifiedFiles(t *testing.T) {
        t.Parallel()
 
        canonicalUrl := fmt.Sprintf("file://%s", absPath(t, 
"../test/fixture-download-source/hello-world-local-hash"))
@@ -29,9 +30,49 @@
        defer os.Remove(downloadDir)
 
        copyFolder(t, 
"../test/fixture-download-source/download-dir-version-file-local-hash", 
downloadDir)
+       testAlreadyHaveLatestCode(t, canonicalUrl, downloadDir, false)
+
+       // Write out a version file so we can test a cache hit
+       terraformSource, _, _, err := createConfig(t, canonicalUrl, 
downloadDir, false)
+       if err != nil {
+               t.Fatal(err)
+       }
+       err = terraformSource.WriteVersionFile()
+       if err != nil {
+               t.Fatal(err)
+       }
+
        testAlreadyHaveLatestCode(t, canonicalUrl, downloadDir, true)
 }
 
+func TestAlreadyHaveLatestCodeLocalFilePathHashingFailure(t *testing.T) {
+       t.Parallel()
+
+       fixturePath := absPath(t, 
"../test/fixture-download-source/hello-world-local-hash-failed")
+       canonicalUrl := fmt.Sprintf("file://%s", fixturePath)
+       downloadDir := tmpDir(t)
+       defer os.Remove(downloadDir)
+
+       copyFolder(t, 
"../test/fixture-download-source/hello-world-local-hash-failed", downloadDir)
+
+       fileInfo, err := os.Stat(fixturePath)
+       if err != nil {
+               t.Fatal(err)
+       }
+
+       err = os.Chmod(fixturePath, 0000)
+       if err != nil {
+               t.Fatal(err)
+       }
+
+       testAlreadyHaveLatestCode(t, canonicalUrl, downloadDir, false)
+
+       err = os.Chmod(fixturePath, fileInfo.Mode())
+       if err != nil {
+               t.Fatal(err)
+       }
+}
+
 func TestAlreadyHaveLatestCodeLocalFilePathWithHashChanged(t *testing.T) {
        t.Parallel()
 
@@ -317,11 +358,14 @@
 }
 
 func createConfig(t *testing.T, canonicalUrl string, downloadDir string, 
sourceUpdate bool) (*tfsource.TerraformSource, *options.TerragruntOptions, 
*config.TerragruntConfig, error) {
+       logger := logrus.New()
+       logger.Out = ioutil.Discard
        terraformSource := &tfsource.TerraformSource{
                CanonicalSourceURL: parseUrl(t, canonicalUrl),
                DownloadDir:        downloadDir,
                WorkingDir:         downloadDir,
                VersionFile:        util.JoinPath(downloadDir, 
"version-file.txt"),
+               Logger:             logger,
        }
 
        terragruntOptions, err := 
options.NewTerragruntOptionsForTest("./should-not-be-used")
@@ -343,11 +387,14 @@
 }
 
 func testAlreadyHaveLatestCode(t *testing.T, canonicalUrl string, downloadDir 
string, expected bool) {
+       logger := logrus.New()
+       logger.Out = ioutil.Discard
        terraformSource := &tfsource.TerraformSource{
                CanonicalSourceURL: parseUrl(t, canonicalUrl),
                DownloadDir:        downloadDir,
                WorkingDir:         downloadDir,
                VersionFile:        util.JoinPath(downloadDir, 
"version-file.txt"),
+               Logger:             logger,
        }
 
        opts, err := options.NewTerragruntOptionsForTest("./should-not-be-used")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/terragrunt-0.38.3/cli/tfsource/types.go 
new/terragrunt-0.38.4/cli/tfsource/types.go
--- old/terragrunt-0.38.3/cli/tfsource/types.go 2022-06-30 14:03:23.000000000 
+0200
+++ new/terragrunt-0.38.4/cli/tfsource/types.go 2022-07-05 13:37:08.000000000 
+0200
@@ -1,9 +1,12 @@
 package tfsource
 
 import (
+       "crypto/sha256"
        "fmt"
        "io/ioutil"
        "net/url"
+       "os"
+       "path/filepath"
        "regexp"
        "strings"
 
@@ -13,8 +16,6 @@
 
        "github.com/gruntwork-io/terragrunt/errors"
        "github.com/gruntwork-io/terragrunt/util"
-
-       "golang.org/x/mod/sumdb/dirhash"
 )
 
 var forcedRegexp = regexp.MustCompile(`^([A-Za-z0-9]+)::(.+)$`)
@@ -32,6 +33,8 @@
 
        // The path to a file in DownloadDir that stores the version number of 
the code
        VersionFile string
+
+       Logger logrus.FieldLogger
 }
 
 func (src *TerraformSource) String() string {
@@ -45,21 +48,58 @@
 // so the same file path (/foo/bar) is always considered the same version. To 
detect changes the file path will be hashed
 // and returned as version. In case of hash error the default encoded source 
version will be returned.
 // See also the encodeSourceName and ProcessTerraformSource methods.
-func (terraformSource TerraformSource) EncodeSourceVersion() string {
+func (terraformSource TerraformSource) EncodeSourceVersion() (string, error) {
        if IsLocalSource(terraformSource.CanonicalSourceURL) {
-               hash, err := 
dirhash.HashDir(terraformSource.CanonicalSourceURL.Path, "prefix", 
dirhash.DefaultHash)
+               sourceHash := sha256.New()
+               sourceDir := 
filepath.Clean(terraformSource.CanonicalSourceURL.Path)
+
+               err := filepath.Walk(sourceDir, func(path string, info 
os.FileInfo, err error) error {
+                       if err != nil {
+                               // If we've encountered an error while walking 
the tree, give up
+                               return err
+                       }
+
+                       if info.IsDir() {
+                               // We don't use any info from directories to 
calculate our hash
+                               return nil
+                       }
+
+                       fileModified := info.ModTime().UnixMicro()
+                       hashContents := fmt.Sprintf("%s:%d", path, fileModified)
+
+                       sourceHash.Write([]byte(hashContents))
+
+                       return nil
+               })
+
                if err == nil {
-                       return hash
+                       hash := fmt.Sprintf("%x", sourceHash.Sum(nil))
+
+                       return hash, nil
                }
-               // In case of error return default source version strategy
+
+               terraformSource.Logger.WithError(err).Warningf("Could not 
encode version for local source")
+               return "", err
        }
-       return 
util.EncodeBase64Sha1(terraformSource.CanonicalSourceURL.Query().Encode())
+
+       return 
util.EncodeBase64Sha1(terraformSource.CanonicalSourceURL.Query().Encode()), nil
 }
 
 // Write a file into the DownloadDir that contains the version number of this 
source code. The version number is
 // calculated using the EncodeSourceVersion method.
 func (terraformSource TerraformSource) WriteVersionFile() error {
-       version := terraformSource.EncodeSourceVersion()
+       version, err := terraformSource.EncodeSourceVersion()
+       if err != nil {
+               // If we failed to calculate a SHA of the downloaded source, 
write a SHA of
+               // some random data into the version file.
+               //
+               // This ensures we attempt to redownload the source next time.
+               version, err = util.GenerateRandomSha256()
+               if err != nil {
+                       return errors.WithStackTrace(err)
+               }
+       }
+
        return 
errors.WithStackTrace(ioutil.WriteFile(terraformSource.VersionFile, 
[]byte(version), 0640))
 }
 
@@ -133,6 +173,7 @@
                DownloadDir:        updatedDownloadDir,
                WorkingDir:         updatedWorkingDir,
                VersionFile:        versionFile,
+               Logger:             logger,
        }, nil
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/terragrunt-0.38.3/go.mod new/terragrunt-0.38.4/go.mod
--- old/terragrunt-0.38.3/go.mod        2022-06-30 14:03:23.000000000 +0200
+++ new/terragrunt-0.38.4/go.mod        2022-07-05 13:37:08.000000000 +0200
@@ -54,7 +54,6 @@
        github.com/zclconf/go-cty v1.8.3
        go.mozilla.org/sops/v3 v3.7.2
        golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
-       golang.org/x/mod v0.5.1
        golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect
        golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f
        golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/terragrunt-0.38.3/go.sum new/terragrunt-0.38.4/go.sum
--- old/terragrunt-0.38.3/go.sum        2022-06-30 14:03:23.000000000 +0200
+++ new/terragrunt-0.38.4/go.sum        2022-07-05 13:37:08.000000000 +0200
@@ -979,8 +979,6 @@
 golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
-golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
-golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
 golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod 
h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod 
h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod 
h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/terragrunt-0.38.3/test/fixture-download-source/hello-world-local-hash-failed/main.tf
 
new/terragrunt-0.38.4/test/fixture-download-source/hello-world-local-hash-failed/main.tf
--- 
old/terragrunt-0.38.3/test/fixture-download-source/hello-world-local-hash-failed/main.tf
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/terragrunt-0.38.4/test/fixture-download-source/hello-world-local-hash-failed/main.tf
    2022-07-05 13:37:08.000000000 +0200
@@ -0,0 +1 @@
+# Local file hash test
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/terragrunt-0.38.3/util/hash.go 
new/terragrunt-0.38.4/util/hash.go
--- old/terragrunt-0.38.3/util/hash.go  2022-06-30 14:03:23.000000000 +0200
+++ new/terragrunt-0.38.4/util/hash.go  2022-07-05 13:37:08.000000000 +0200
@@ -2,7 +2,10 @@
 
 import (
        "crypto/sha1"
+       "crypto/sha256"
        "encoding/base64"
+       "fmt"
+       "math/rand"
 )
 
 // Returns the base 64 encoded sha1 hash of the given string
@@ -10,3 +13,13 @@
        hash := sha1.Sum([]byte(str))
        return base64.RawURLEncoding.EncodeToString(hash[:])
 }
+
+func GenerateRandomSha256() (string, error) {
+       randomBytes := make([]byte, 32)
+       _, err := rand.Read(randomBytes)
+       if err != nil {
+               return "", err
+       }
+
+       return fmt.Sprintf("%x", sha256.Sum256(randomBytes)), nil
+}

++++++ 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