-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: inducing overridden DockerRegistryId in case docker registry is overridden #4178
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,18 +44,20 @@ type DockerRegistryIpsConfigServiceImpl struct { | |
clusterService cluster.ClusterService | ||
ciPipelineRepository pipelineConfig.CiPipelineRepository | ||
dockerArtifactStoreRepository repository.DockerArtifactStoreRepository | ||
ciTemplateOverrideRepository pipelineConfig.CiTemplateOverrideRepository | ||
} | ||
|
||
func NewDockerRegistryIpsConfigServiceImpl(logger *zap.SugaredLogger, dockerRegistryIpsConfigRepository repository.DockerRegistryIpsConfigRepository, | ||
k8sUtil *k8s.K8sUtil, clusterService cluster.ClusterService, ciPipelineRepository pipelineConfig.CiPipelineRepository, | ||
dockerArtifactStoreRepository repository.DockerArtifactStoreRepository) *DockerRegistryIpsConfigServiceImpl { | ||
dockerArtifactStoreRepository repository.DockerArtifactStoreRepository, ciTemplateOverrideRepository pipelineConfig.CiTemplateOverrideRepository) *DockerRegistryIpsConfigServiceImpl { | ||
return &DockerRegistryIpsConfigServiceImpl{ | ||
logger: logger, | ||
dockerRegistryIpsConfigRepository: dockerRegistryIpsConfigRepository, | ||
k8sUtil: k8sUtil, | ||
clusterService: clusterService, | ||
ciPipelineRepository: ciPipelineRepository, | ||
dockerArtifactStoreRepository: dockerArtifactStoreRepository, | ||
ciTemplateOverrideRepository: ciTemplateOverrideRepository, | ||
} | ||
} | ||
|
||
|
@@ -83,29 +85,11 @@ func (impl DockerRegistryIpsConfigServiceImpl) HandleImagePullSecretOnApplicatio | |
return valuesFileContent, nil | ||
} | ||
|
||
ciPipeline, err := impl.ciPipelineRepository.FindById(ciPipelineId) | ||
dockerRegistryId, err := impl.getDockerRegistryIdForCiPipeline(ciPipelineId) | ||
if err != nil { | ||
impl.logger.Errorw("error in fetching ciPipeline", "ciPipelineId", ciPipelineId, "error", err) | ||
if err == pg.ErrNoRows { | ||
return valuesFileContent, nil | ||
} else { | ||
return nil, err | ||
} | ||
} | ||
|
||
if ciPipeline.IsExternal && ciPipeline.ParentCiPipeline == 0 { | ||
impl.logger.Warn("Ignoring for external ci") | ||
return valuesFileContent, nil | ||
} | ||
|
||
if ciPipeline.CiTemplate == nil { | ||
impl.logger.Warn("returning as ciPipeline.CiTemplate is found nil") | ||
return valuesFileContent, nil | ||
} | ||
|
||
dockerRegistryId := ciPipeline.CiTemplate.DockerRegistryId | ||
if len(*dockerRegistryId) == 0 { | ||
impl.logger.Warn("returning as dockerRegistryId is found empty") | ||
impl.logger.Errorw("error in getting docker registry", "dockerRegistryId", dockerRegistryId, "error", err) | ||
return valuesFileContent, err | ||
} else if dockerRegistryId == nil { | ||
return valuesFileContent, nil | ||
} | ||
|
||
|
@@ -154,6 +138,40 @@ func (impl DockerRegistryIpsConfigServiceImpl) HandleImagePullSecretOnApplicatio | |
return updatedValuesFileContent, nil | ||
} | ||
|
||
func (impl DockerRegistryIpsConfigServiceImpl) getDockerRegistryIdForCiPipeline(ciPipelineId int) (*string, error) { | ||
ciPipeline, err := impl.ciPipelineRepository.FindById(ciPipelineId) | ||
if err != nil { | ||
impl.logger.Errorw("error in fetching ciPipeline", "ciPipelineId", ciPipelineId, "error", err) | ||
return nil, err | ||
} | ||
|
||
if ciPipeline.IsExternal && ciPipeline.ParentCiPipeline == 0 { | ||
impl.logger.Warn("Ignoring for external ci") | ||
return nil, nil | ||
} | ||
|
||
if ciPipeline.CiTemplate == nil { | ||
impl.logger.Warn("returning as ciPipeline.CiTemplate is found nil") | ||
return nil, nil | ||
} | ||
|
||
dockerRegistryId := ciPipeline.CiTemplate.DockerRegistryId | ||
if len(*dockerRegistryId) == 0 { | ||
impl.logger.Warn("returning as dockerRegistryId is found empty") | ||
return nil, nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. throw custom error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This custom error was not being thrown earlier also, so don't know it may impact other flows also outside this function which will increase the scope of this maybe |
||
} | ||
|
||
if ciPipeline.IsDockerConfigOverridden { | ||
//set dockerRegistryId value with the DockerRegistryId of the overridden dockerRegistry | ||
ciTemplateOverride, err := impl.ciTemplateOverrideRepository.FindByCiPipelineId(ciPipelineId) | ||
if err != nil { | ||
impl.logger.Errorw("error in getting ciTemplateOverride by ciPipelineId", "ciPipelineId", ciPipelineId, "error", err) | ||
return nil, err | ||
} | ||
dockerRegistryId = &ciTemplateOverride.DockerRegistryId | ||
} | ||
return dockerRegistryId, nil | ||
} | ||
func (impl DockerRegistryIpsConfigServiceImpl) createOrUpdateDockerRegistryImagePullSecret(clusterId int, namespace string, ipsName string, dockerRegistryBean *repository.DockerArtifactStore) error { | ||
impl.logger.Infow("creating/updating ips", "ipsName", ipsName, "clusterId", clusterId) | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is response in this case