Skip to content

Commit bf76809

Browse files
ybettank8s-ci-robot
authored andcommitted
Splitting the pod package to different files.
We have 2 more interfaces to come in this package and the files is starting to be big and complicated to follow. Splitting the package into different files to make it easier to import new interfaces into the package. Signed-off-by: Yoni Bettan <[email protected]>
1 parent 0742fdc commit bf76809

File tree

4 files changed

+29
-19
lines changed

4 files changed

+29
-19
lines changed

internal/pod/common.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package pod
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
v1 "k8s.io/api/core/v1"
8+
ctrl "sigs.k8s.io/controller-runtime"
9+
"sigs.k8s.io/controller-runtime/pkg/client"
10+
)
11+
12+
func deletePod(clnt client.Client, ctx context.Context, pod *v1.Pod) error {
13+
14+
logger := ctrl.LoggerFrom(ctx)
15+
16+
if pod.DeletionTimestamp != nil {
17+
logger.Info("DeletionTimestamp set, pod is already in deletion", "pod", pod.Name)
18+
return nil
19+
}
20+
21+
if err := clnt.Delete(ctx, pod); client.IgnoreNotFound(err) != nil {
22+
return fmt.Errorf("failed to delete pull pod %s/%s: %v", pod.Namespace, pod.Name, err)
23+
}
24+
25+
return nil
26+
}
Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"sigs.k8s.io/controller-runtime/pkg/client"
1313
)
1414

15-
//go:generate mockgen -source=pod.go -package=pod -destination=mock_pod.go
15+
//go:generate mockgen -source=imagepuller.go -package=pod -destination=mock_imagepuller.go
1616

1717
type ImagePuller interface {
1818
CreatePullPod(ctx context.Context, imageSpec *kmmv1beta1.ModuleImageSpec, micObj *kmmv1beta1.ModuleImagesConfig) error
@@ -117,19 +117,3 @@ func (ipi *imagePullerImpl) GetPullPodForImage(pods []v1.Pod, image string) *v1.
117117
func (ipi *imagePullerImpl) GetPullPodImage(pod v1.Pod) string {
118118
return pod.Labels[imageLabelKey]
119119
}
120-
121-
func deletePod(clnt client.Client, ctx context.Context, pod *v1.Pod) error {
122-
123-
logger := ctrl.LoggerFrom(ctx)
124-
125-
if pod.DeletionTimestamp != nil {
126-
logger.Info("DeletionTimestamp set, pod is already in deletion", "pod", pod.Name)
127-
return nil
128-
}
129-
130-
if err := clnt.Delete(ctx, pod); client.IgnoreNotFound(err) != nil {
131-
return fmt.Errorf("failed to delete pull pod %s/%s: %v", pod.Namespace, pod.Name, err)
132-
}
133-
134-
return nil
135-
}
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)