gitrepo: Use internal/util for creating temp dir
Signed-off-by: Sunny <darkowlzz@protonmail.com>
This commit is contained in:
		
							parent
							
								
									8b43f6d7a7
								
							
						
					
					
						commit
						4502d15549
					
				|  | @ -48,6 +48,7 @@ import ( | ||||||
| 	sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" | 	sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" | ||||||
| 	serror "github.com/fluxcd/source-controller/internal/error" | 	serror "github.com/fluxcd/source-controller/internal/error" | ||||||
| 	sreconcile "github.com/fluxcd/source-controller/internal/reconcile" | 	sreconcile "github.com/fluxcd/source-controller/internal/reconcile" | ||||||
|  | 	"github.com/fluxcd/source-controller/internal/util" | ||||||
| 	"github.com/fluxcd/source-controller/pkg/git" | 	"github.com/fluxcd/source-controller/pkg/git" | ||||||
| 	"github.com/fluxcd/source-controller/pkg/git/strategy" | 	"github.com/fluxcd/source-controller/pkg/git/strategy" | ||||||
| ) | ) | ||||||
|  | @ -234,7 +235,7 @@ func (r *GitRepositoryReconciler) reconcile(ctx context.Context, obj *sourcev1.G | ||||||
| 	var includes artifactSet | 	var includes artifactSet | ||||||
| 
 | 
 | ||||||
| 	// Create temp dir for Git clone
 | 	// Create temp dir for Git clone
 | ||||||
| 	tmpDir, err := os.MkdirTemp("", fmt.Sprintf("%s-%s-%s-", obj.Kind, obj.Namespace, obj.Name)) | 	tmpDir, err := util.TempDirForObj("", obj) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return sreconcile.ResultEmpty, &serror.Event{ | 		return sreconcile.ResultEmpty, &serror.Event{ | ||||||
| 			Err:    fmt.Errorf("failed to create temporary directory: %w", err), | 			Err:    fmt.Errorf("failed to create temporary directory: %w", err), | ||||||
|  |  | ||||||
|  | @ -708,7 +708,7 @@ func TestGitRepositoryReconciler_reconcileArtifact(t *testing.T) { | ||||||
| 			}, | 			}, | ||||||
| 			afterFunc: func(t *WithT, obj *sourcev1.GitRepository, artifact sourcev1.Artifact) { | 			afterFunc: func(t *WithT, obj *sourcev1.GitRepository, artifact sourcev1.Artifact) { | ||||||
| 				t.Expect(obj.GetArtifact()).ToNot(BeNil()) | 				t.Expect(obj.GetArtifact()).ToNot(BeNil()) | ||||||
| 				t.Expect(obj.GetArtifact().Checksum).To(Equal("ef9c34eab0584035ac8b8a4070876954ea46f270250d60648672feef3e943426")) | 				t.Expect(obj.GetArtifact().Checksum).To(Equal("60a3bf69f337cb5ec9ebd00abefbb6e7f2a2cf27158ecf438d52b2035b184172")) | ||||||
| 				t.Expect(obj.Status.IncludedArtifacts).ToNot(BeEmpty()) | 				t.Expect(obj.Status.IncludedArtifacts).ToNot(BeEmpty()) | ||||||
| 				t.Expect(obj.Status.URL).ToNot(BeEmpty()) | 				t.Expect(obj.Status.URL).ToNot(BeEmpty()) | ||||||
| 			}, | 			}, | ||||||
|  | @ -744,7 +744,7 @@ func TestGitRepositoryReconciler_reconcileArtifact(t *testing.T) { | ||||||
| 			}, | 			}, | ||||||
| 			afterFunc: func(t *WithT, obj *sourcev1.GitRepository, artifact sourcev1.Artifact) { | 			afterFunc: func(t *WithT, obj *sourcev1.GitRepository, artifact sourcev1.Artifact) { | ||||||
| 				t.Expect(obj.GetArtifact()).ToNot(BeNil()) | 				t.Expect(obj.GetArtifact()).ToNot(BeNil()) | ||||||
| 				t.Expect(obj.GetArtifact().Checksum).To(Equal("dc95ae14c19d335b693bbba58ae2a562242b0cf33893baffd1b7605ba578e0d6")) | 				t.Expect(obj.GetArtifact().Checksum).To(Equal("11f7f007dce5619bd79e6c57688261058d09f5271e802463ac39f2b9ead7cabd")) | ||||||
| 			}, | 			}, | ||||||
| 			want: sreconcile.ResultSuccess, | 			want: sreconcile.ResultSuccess, | ||||||
| 			assertConditions: []metav1.Condition{ | 			assertConditions: []metav1.Condition{ | ||||||
|  | @ -761,7 +761,7 @@ func TestGitRepositoryReconciler_reconcileArtifact(t *testing.T) { | ||||||
| 			}, | 			}, | ||||||
| 			afterFunc: func(t *WithT, obj *sourcev1.GitRepository, artifact sourcev1.Artifact) { | 			afterFunc: func(t *WithT, obj *sourcev1.GitRepository, artifact sourcev1.Artifact) { | ||||||
| 				t.Expect(obj.GetArtifact()).ToNot(BeNil()) | 				t.Expect(obj.GetArtifact()).ToNot(BeNil()) | ||||||
| 				t.Expect(obj.GetArtifact().Checksum).To(Equal("ef9c34eab0584035ac8b8a4070876954ea46f270250d60648672feef3e943426")) | 				t.Expect(obj.GetArtifact().Checksum).To(Equal("60a3bf69f337cb5ec9ebd00abefbb6e7f2a2cf27158ecf438d52b2035b184172")) | ||||||
| 				t.Expect(obj.Status.URL).ToNot(BeEmpty()) | 				t.Expect(obj.Status.URL).ToNot(BeEmpty()) | ||||||
| 			}, | 			}, | ||||||
| 			want: sreconcile.ResultSuccess, | 			want: sreconcile.ResultSuccess, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue