From ed2c5d77c790be9bf69acdd748955b6672fd5e67 Mon Sep 17 00:00:00 2001 From: Cosmin Tupangiu Date: Wed, 1 Apr 2026 10:12:28 +0200 Subject: [PATCH] NO-JIRA | fix: source InfraImage cannot be updated This commit fixes the bug when source InfraImage cannot be updated once it has been set. Signed-off-by: Cosmin Tupangiu --- internal/service/mappers/inbound.go | 12 +++++++++++- internal/service/source.go | 4 ++-- internal/store/image.go | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/internal/service/mappers/inbound.go b/internal/service/mappers/inbound.go index 7732ad9cd..d424ead6f 100644 --- a/internal/service/mappers/inbound.go +++ b/internal/service/mappers/inbound.go @@ -119,22 +119,30 @@ func (f *SourceUpdateForm) ToSource(source *model.Source) { } } -func (f *SourceUpdateForm) ToImageInfra(imageInfra *model.ImageInfra) { +func (f *SourceUpdateForm) ToImageInfra(sourceID uuid.UUID) model.ImageInfra { + imageInfra := model.ImageInfra{ + SourceID: sourceID, + } + if f.SshPublicKey != nil { imageInfra.SshPublicKey = *f.SshPublicKey } if f.CertificateChain != nil { imageInfra.CertificateChain = *f.CertificateChain } + if f.HttpUrl != nil { imageInfra.HttpProxyUrl = *f.HttpUrl } + if f.HttpsUrl != nil { imageInfra.HttpsProxyUrl = *f.HttpsUrl } + if f.NoProxy != nil { imageInfra.NoProxyDomains = *f.NoProxy } + if f.IpAddress != nil { imageInfra.IpAddress = *f.IpAddress } @@ -147,6 +155,8 @@ func (f *SourceUpdateForm) ToImageInfra(imageInfra *model.ImageInfra) { if f.Dns != nil { imageInfra.Dns = *f.Dns } + + return imageInfra } func (f *SourceUpdateForm) ToLabels() []model.Label { diff --git a/internal/service/source.go b/internal/service/source.go index d35862775..ac7b2ba64 100644 --- a/internal/service/source.go +++ b/internal/service/source.go @@ -148,8 +148,8 @@ func (s *SourceService) UpdateSource(ctx context.Context, id uuid.UUID, form map } // Update ImageInfra - form.ToImageInfra(&source.ImageInfra) - if _, err := s.store.ImageInfra().Update(ctx, source.ImageInfra); err != nil { + imageInfra := form.ToImageInfra(source.ID) + if _, err := s.store.ImageInfra().Update(ctx, imageInfra); err != nil { return nil, err } diff --git a/internal/store/image.go b/internal/store/image.go index 63c4b55fd..2b7fab6c2 100644 --- a/internal/store/image.go +++ b/internal/store/image.go @@ -3,8 +3,9 @@ package store import ( "context" - "github.com/kubev2v/migration-planner/internal/store/model" "gorm.io/gorm" + + "github.com/kubev2v/migration-planner/internal/store/model" ) type ImageInfra interface {