Skip to content

Commit 922941f

Browse files
authored
[K8s Plugin] Remove unnecessary func and if-else (#5998)
* Remove unused func and its test Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev> * Remove unnecessary check for application config file Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev> * Remove unused func and test Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev> --------- Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
1 parent 8d9d755 commit 922941f

7 files changed

Lines changed: 1 addition & 499 deletions

File tree

pkg/app/pipedv1/plugin/kubernetes/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.24.1
55
require (
66
github.com/goccy/go-yaml v1.9.8
77
github.com/google/go-cmp v0.7.0
8-
github.com/pipe-cd/pipecd v0.52.0
98
github.com/pipe-cd/piped-plugin-sdk-go v0.0.0-20250624100230-4dd9b8f9b0b8
109
github.com/stretchr/testify v1.10.0
1110
go.uber.org/zap v1.19.1
@@ -62,6 +61,7 @@ require (
6261
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
6362
github.com/modern-go/reflect2 v1.0.2 // indirect
6463
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
64+
github.com/pipe-cd/pipecd v0.52.0 // indirect
6565
github.com/pkg/errors v0.9.1 // indirect
6666
github.com/pmezard/go-difflib v1.0.0 // indirect
6767
github.com/prometheus/client_golang v1.12.1 // indirect

pkg/app/pipedv1/plugin/kubernetes/provider/liveresources.go

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ package provider
1717
import (
1818
"context"
1919
"fmt"
20-
"time"
21-
22-
"github.com/pipe-cd/pipecd/pkg/model"
2320
)
2421

2522
// GetLiveResources returns all live resources that belong to the given application.
@@ -46,49 +43,3 @@ func GetLiveResources(ctx context.Context, kubectl *Kubectl, kubeconfig string,
4643

4744
return namespacedLiveResources, clusterScopedLiveResources, nil
4845
}
49-
50-
// BuildApplicationLiveState builds the live state of the application from the given manifests.
51-
func BuildApplicationLiveState(deploytarget string, manifests []Manifest, now time.Time) *model.ApplicationLiveState {
52-
if len(manifests) == 0 {
53-
return &model.ApplicationLiveState{
54-
HealthStatus: model.ApplicationLiveState_UNKNOWN,
55-
}
56-
}
57-
58-
states := make([]*model.ResourceState, 0, len(manifests))
59-
for _, m := range manifests {
60-
states = append(states, buildResourceState(m, now))
61-
}
62-
63-
return &model.ApplicationLiveState{
64-
Resources: states,
65-
HealthStatus: model.ApplicationLiveState_UNKNOWN, // TODO: Implement health status calculation
66-
}
67-
}
68-
69-
// buildResourceState builds the resource state from the given manifest.
70-
func buildResourceState(m Manifest, now time.Time) *model.ResourceState {
71-
var parents []string // default as nil
72-
if len(m.body.GetOwnerReferences()) > 0 {
73-
parents = make([]string, 0, len(m.body.GetOwnerReferences()))
74-
for _, o := range m.body.GetOwnerReferences() {
75-
parents = append(parents, string(o.UID))
76-
}
77-
}
78-
79-
return &model.ResourceState{
80-
Id: string(m.body.GetUID()),
81-
Name: m.body.GetName(),
82-
ParentIds: parents,
83-
HealthStatus: model.ResourceState_UNKNOWN, // TODO: Implement health status calculation
84-
HealthDescription: "", // TODO: Implement health status calculation
85-
ResourceType: m.body.GetKind(),
86-
ResourceMetadata: map[string]string{
87-
"Namespace": m.body.GetNamespace(),
88-
"API Version": m.body.GetAPIVersion(),
89-
"Kind": m.body.GetKind(),
90-
},
91-
CreatedAt: m.body.GetCreationTimestamp().Unix(),
92-
UpdatedAt: now.Unix(),
93-
}
94-
}

pkg/app/pipedv1/plugin/kubernetes/provider/liveresources_test.go

Lines changed: 0 additions & 195 deletions
This file was deleted.

pkg/app/pipedv1/plugin/kubernetes/provider/loader.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"sigs.k8s.io/yaml"
3131

3232
"github.com/pipe-cd/pipecd/pkg/app/pipedv1/plugin/kubernetes/config"
33-
"github.com/pipe-cd/pipecd/pkg/model"
3433
)
3534

3635
type TemplatingMethod string
@@ -205,10 +204,6 @@ func LoadPlainYAMLManifests(dir string, names []string, configFilename string) (
205204
if ext := filepath.Ext(d.Name()); ext != ".yaml" && ext != ".yml" && ext != ".json" {
206205
return nil
207206
}
208-
if model.IsApplicationConfigFile(d.Name()) {
209-
// MEMO: can we remove this check because we have configFilename?
210-
return nil
211-
}
212207
if d.Name() == configFilename {
213208
return nil
214209
}

pkg/app/pipedv1/plugin/kubernetes_multicluster/provider/liveresources.go

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ package provider
1717
import (
1818
"context"
1919
"fmt"
20-
"time"
21-
22-
"github.com/pipe-cd/pipecd/pkg/model"
2320
)
2421

2522
// GetLiveResources returns all live resources that belong to the given application.
@@ -43,49 +40,3 @@ func GetLiveResources(ctx context.Context, kubectl *Kubectl, kubeconfig string,
4340

4441
return namespacedLiveResources, clusterScopedLiveResources, nil
4542
}
46-
47-
// BuildApplicationLiveState builds the live state of the application from the given manifests.
48-
func BuildApplicationLiveState(deploytarget string, manifests []Manifest, now time.Time) *model.ApplicationLiveState {
49-
if len(manifests) == 0 {
50-
return &model.ApplicationLiveState{
51-
HealthStatus: model.ApplicationLiveState_UNKNOWN,
52-
}
53-
}
54-
55-
states := make([]*model.ResourceState, 0, len(manifests))
56-
for _, m := range manifests {
57-
states = append(states, buildResourceState(m, now))
58-
}
59-
60-
return &model.ApplicationLiveState{
61-
Resources: states,
62-
HealthStatus: model.ApplicationLiveState_UNKNOWN, // TODO: Implement health status calculation
63-
}
64-
}
65-
66-
// buildResourceState builds the resource state from the given manifest.
67-
func buildResourceState(m Manifest, now time.Time) *model.ResourceState {
68-
var parents []string // default as nil
69-
if len(m.body.GetOwnerReferences()) > 0 {
70-
parents = make([]string, 0, len(m.body.GetOwnerReferences()))
71-
for _, o := range m.body.GetOwnerReferences() {
72-
parents = append(parents, string(o.UID))
73-
}
74-
}
75-
76-
return &model.ResourceState{
77-
Id: string(m.body.GetUID()),
78-
Name: m.body.GetName(),
79-
ParentIds: parents,
80-
HealthStatus: model.ResourceState_UNKNOWN, // TODO: Implement health status calculation
81-
HealthDescription: "", // TODO: Implement health status calculation
82-
ResourceType: m.body.GetKind(),
83-
ResourceMetadata: map[string]string{
84-
"Namespace": m.body.GetNamespace(),
85-
"API Version": m.body.GetAPIVersion(),
86-
"Kind": m.body.GetKind(),
87-
},
88-
CreatedAt: m.body.GetCreationTimestamp().Unix(),
89-
UpdatedAt: now.Unix(),
90-
}
91-
}

0 commit comments

Comments
 (0)