Skip to content

Commit

Permalink
Add unit test coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Parraga <[email protected]>
  • Loading branch information
Sovietaced committed Feb 22, 2025
1 parent 20543d4 commit 45811c3
Show file tree
Hide file tree
Showing 2 changed files with 269 additions and 108 deletions.
6 changes: 3 additions & 3 deletions flyteplugins/go/tasks/pluginmachinery/flytek8s/pod_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ func MergeWithBasePodTemplate(ctx context.Context, tCtx pluginsCore.TaskExecutio
// magic values this method will merge containers that have matching names.
func MergeBasePodSpecOntoTemplate(templatePodSpec *v1.PodSpec, basePodSpec *v1.PodSpec, primaryContainerName string, primaryInitContainerName string) (*v1.PodSpec, error) {
if templatePodSpec == nil || basePodSpec == nil {
return nil, errors.New("templatePodSpec and basePodSpec must not be nil")
return nil, errors.New("neither the templatePodSpec or the basePodSpec can be nil")
}

// extract primaryContainerTemplate. The base should always contain the primary container.
Expand All @@ -713,7 +713,7 @@ func MergeBasePodSpecOntoTemplate(templatePodSpec *v1.PodSpec, basePodSpec *v1.P
for i := 0; i < len(templatePodSpec.InitContainers); i++ {
if templatePodSpec.InitContainers[i].Name == defaultInitContainerTemplateName {
defaultInitContainerTemplate = &templatePodSpec.InitContainers[i]
} else if primaryInitContainerName != primaryInitContainerTemplateName && templatePodSpec.InitContainers[i].Name == primaryInitContainerTemplateName {
} else if templatePodSpec.InitContainers[i].Name == primaryInitContainerTemplateName {
primaryInitContainerTemplate = &templatePodSpec.InitContainers[i]
}
}
Expand Down Expand Up @@ -764,7 +764,7 @@ func MergeBasePodSpecOntoTemplate(templatePodSpec *v1.PodSpec, basePodSpec *v1.P
// Merge in the base container
if mergedContainer == nil {
mergedContainer = container.DeepCopy()
} else if container.Name != primaryContainerTemplateName {
} else {
err := mergo.Merge(mergedContainer, container, mergo.WithOverride, mergo.WithAppendSlice)
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 45811c3

Please sign in to comment.