Skip to content

Commit 9239996

Browse files
bpradiptclaude
andcommitted
Fix lint issue: rename ManifestSet to Set
The type name ManifestSet stutters with the package name manifest. Following Go naming conventions, renamed to manifest.Set. Co-Authored-By: Claude <[email protected]> Signed-off-by: Pradipta Banerjee <[email protected]>
1 parent fcfaba0 commit 9239996

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

integration_test/manifest_multidoc_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/confidential-devhub/cococtl/pkg/manifest"
88
)
99

10-
func TestManifestSet_LoadMultiDocument_PodWithService(t *testing.T) {
10+
func TestSet_LoadMultiDocument_PodWithService(t *testing.T) {
1111
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/pod-with-service.yaml")
1212
if err != nil {
1313
t.Fatalf("LoadMultiDocument() failed: %v", err)
@@ -43,7 +43,7 @@ func TestManifestSet_LoadMultiDocument_PodWithService(t *testing.T) {
4343
}
4444
}
4545

46-
func TestManifestSet_LoadMultiDocument_DeploymentWithService(t *testing.T) {
46+
func TestSet_LoadMultiDocument_DeploymentWithService(t *testing.T) {
4747
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/deployment-with-service.yaml")
4848
if err != nil {
4949
t.Fatalf("LoadMultiDocument() failed: %v", err)
@@ -67,7 +67,7 @@ func TestManifestSet_LoadMultiDocument_DeploymentWithService(t *testing.T) {
6767
}
6868
}
6969

70-
func TestManifestSet_LoadMultiDocument_SingleDocument(t *testing.T) {
70+
func TestSet_LoadMultiDocument_SingleDocument(t *testing.T) {
7171
// Load a single-document YAML
7272
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/simple-pod.yaml")
7373
if err != nil {
@@ -88,7 +88,7 @@ func TestManifestSet_LoadMultiDocument_SingleDocument(t *testing.T) {
8888
}
8989
}
9090

91-
func TestManifestSet_GetServiceTargetPort_NumericPort(t *testing.T) {
91+
func TestSet_GetServiceTargetPort_NumericPort(t *testing.T) {
9292
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/pod-with-service.yaml")
9393
if err != nil {
9494
t.Fatalf("LoadMultiDocument() failed: %v", err)
@@ -105,7 +105,7 @@ func TestManifestSet_GetServiceTargetPort_NumericPort(t *testing.T) {
105105
}
106106
}
107107

108-
func TestManifestSet_GetServiceTargetPort_DeploymentWithService(t *testing.T) {
108+
func TestSet_GetServiceTargetPort_DeploymentWithService(t *testing.T) {
109109
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/deployment-with-service.yaml")
110110
if err != nil {
111111
t.Fatalf("LoadMultiDocument() failed: %v", err)
@@ -122,7 +122,7 @@ func TestManifestSet_GetServiceTargetPort_DeploymentWithService(t *testing.T) {
122122
}
123123
}
124124

125-
func TestManifestSet_GetServiceTargetPort_NamedPort(t *testing.T) {
125+
func TestSet_GetServiceTargetPort_NamedPort(t *testing.T) {
126126
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/service-with-named-port.yaml")
127127
if err != nil {
128128
t.Fatalf("LoadMultiDocument() failed: %v", err)
@@ -140,7 +140,7 @@ func TestManifestSet_GetServiceTargetPort_NamedPort(t *testing.T) {
140140
}
141141
}
142142

143-
func TestManifestSet_GetServiceTargetPort_NoTargetPort(t *testing.T) {
143+
func TestSet_GetServiceTargetPort_NoTargetPort(t *testing.T) {
144144
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/service-no-targetport.yaml")
145145
if err != nil {
146146
t.Fatalf("LoadMultiDocument() failed: %v", err)
@@ -158,7 +158,7 @@ func TestManifestSet_GetServiceTargetPort_NoTargetPort(t *testing.T) {
158158
}
159159
}
160160

161-
func TestManifestSet_GetServiceTargetPort_NoService(t *testing.T) {
161+
func TestSet_GetServiceTargetPort_NoService(t *testing.T) {
162162
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/simple-pod.yaml")
163163
if err != nil {
164164
t.Fatalf("LoadMultiDocument() failed: %v", err)
@@ -175,7 +175,7 @@ func TestManifestSet_GetServiceTargetPort_NoService(t *testing.T) {
175175
}
176176
}
177177

178-
func TestManifestSet_GetServiceTargetPort_ConflictPort(t *testing.T) {
178+
func TestSet_GetServiceTargetPort_ConflictPort(t *testing.T) {
179179
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/service-with-conflict-port.yaml")
180180
if err != nil {
181181
t.Fatalf("LoadMultiDocument() failed: %v", err)
@@ -194,7 +194,7 @@ func TestManifestSet_GetServiceTargetPort_ConflictPort(t *testing.T) {
194194
}
195195
}
196196

197-
func TestManifestSet_GetPrimaryManifest_NoWorkload(t *testing.T) {
197+
func TestSet_GetPrimaryManifest_NoWorkload(t *testing.T) {
198198
// Create a temporary file with only a Service (no workload)
199199
tmpDir := t.TempDir()
200200
tmpFile := tmpDir + "/service-only.yaml"
@@ -224,14 +224,14 @@ spec:
224224
}
225225
}
226226

227-
func TestManifestSet_LoadMultiDocument_InvalidPath(t *testing.T) {
227+
func TestSet_LoadMultiDocument_InvalidPath(t *testing.T) {
228228
_, err := manifest.LoadMultiDocument("nonexistent-file.yaml")
229229
if err == nil {
230230
t.Error("Expected error for nonexistent file, got nil")
231231
}
232232
}
233233

234-
func TestManifestSet_LoadMultiDocument_EmptyFile(t *testing.T) {
234+
func TestSet_LoadMultiDocument_EmptyFile(t *testing.T) {
235235
// Create a temporary empty file
236236
tmpDir := t.TempDir()
237237
emptyFile := tmpDir + "/empty.yaml"
@@ -246,7 +246,7 @@ func TestManifestSet_LoadMultiDocument_EmptyFile(t *testing.T) {
246246
}
247247
}
248248

249-
func TestManifestSet_GetServiceTargetPort_NamedPortInDeployment(t *testing.T) {
249+
func TestSet_GetServiceTargetPort_NamedPortInDeployment(t *testing.T) {
250250
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/deployment-with-named-port.yaml")
251251
if err != nil {
252252
t.Fatalf("LoadMultiDocument() failed: %v", err)
@@ -264,7 +264,7 @@ func TestManifestSet_GetServiceTargetPort_NamedPortInDeployment(t *testing.T) {
264264
}
265265
}
266266

267-
func TestManifestSet_GetServiceTargetPort_InvalidNamedPort(t *testing.T) {
267+
func TestSet_GetServiceTargetPort_InvalidNamedPort(t *testing.T) {
268268
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/service-with-invalid-named-port.yaml")
269269
if err != nil {
270270
t.Fatalf("LoadMultiDocument() failed: %v", err)
@@ -280,7 +280,7 @@ func TestManifestSet_GetServiceTargetPort_InvalidNamedPort(t *testing.T) {
280280
}
281281
}
282282

283-
func TestManifestSet_vLLM_ServiceBeforeDeployment(t *testing.T) {
283+
func TestSet_vLLM_ServiceBeforeDeployment(t *testing.T) {
284284
// Test with vLLM manifest where Service is defined BEFORE Deployment
285285
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/deployment-with-service-vllm.yaml")
286286
if err != nil {
@@ -317,7 +317,7 @@ func TestManifestSet_vLLM_ServiceBeforeDeployment(t *testing.T) {
317317
}
318318
}
319319

320-
func TestManifestSet_vLLM_NamedPortResolution(t *testing.T) {
320+
func TestSet_vLLM_NamedPortResolution(t *testing.T) {
321321
// Test named port resolution with vLLM manifest
322322
// Service has targetPort: http
323323
// Deployment has container with port name: http, containerPort: 8000
@@ -337,7 +337,7 @@ func TestManifestSet_vLLM_NamedPortResolution(t *testing.T) {
337337
}
338338
}
339339

340-
func TestManifestSet_vLLM_HeadlessService(t *testing.T) {
340+
func TestSet_vLLM_HeadlessService(t *testing.T) {
341341
// Test that headless service (clusterIP: None) still works for port detection
342342
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/deployment-with-service-vllm.yaml")
343343
if err != nil {
@@ -373,7 +373,7 @@ func TestManifestSet_vLLM_HeadlessService(t *testing.T) {
373373
}
374374
}
375375

376-
func TestManifestSet_vLLM_ComplexDeployment(t *testing.T) {
376+
func TestSet_vLLM_ComplexDeployment(t *testing.T) {
377377
// Test with a complex deployment that has probes, volumes, resource limits
378378
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/deployment-with-service-vllm.yaml")
379379
if err != nil {
@@ -428,7 +428,7 @@ func TestManifestSet_vLLM_ComplexDeployment(t *testing.T) {
428428
}
429429
}
430430

431-
func TestManifestSet_vLLM_ExistingRuntimeClass(t *testing.T) {
431+
func TestSet_vLLM_ExistingRuntimeClass(t *testing.T) {
432432
// Test that existing runtimeClassName is preserved
433433
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/deployment-with-service-vllm.yaml")
434434
if err != nil {
@@ -447,7 +447,7 @@ func TestManifestSet_vLLM_ExistingRuntimeClass(t *testing.T) {
447447
}
448448
}
449449

450-
func TestManifestSet_vLLM_ExistingAnnotations(t *testing.T) {
450+
func TestSet_vLLM_ExistingAnnotations(t *testing.T) {
451451
// Test that existing annotations are preserved
452452
manifestSet, err := manifest.LoadMultiDocument("testdata/manifests/deployment-with-service-vllm.yaml")
453453
if err != nil {

pkg/manifest/manifest.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ type Manifest struct {
1616
path string
1717
}
1818

19-
// ManifestSet represents a collection of Kubernetes manifests from a multi-document YAML file.
20-
type ManifestSet struct {
19+
// Set represents a collection of Kubernetes manifests from a multi-document YAML file.
20+
type Set struct {
2121
manifests []*Manifest
2222
path string
2323
}
@@ -70,9 +70,9 @@ func Load(path string) (*Manifest, error) {
7070

7171
// LoadMultiDocument reads and parses a multi-document Kubernetes manifest file.
7272
// It handles YAML files with multiple documents separated by '---'.
73-
// Returns a ManifestSet containing all documents. If only one document is found,
74-
// it still returns a ManifestSet with a single Manifest for consistency.
75-
func LoadMultiDocument(path string) (*ManifestSet, error) {
73+
// Returns a Set containing all documents. If only one document is found,
74+
// it still returns a Set with a single Manifest for consistency.
75+
func LoadMultiDocument(path string) (*Set, error) {
7676
// Validate and sanitize the path to prevent directory traversal
7777
// Source - https://stackoverflow.com/a/57534618
7878
// Posted by Kenny Grant, modified by community. See post 'Timeline' for change history
@@ -140,20 +140,20 @@ func LoadMultiDocument(path string) (*ManifestSet, error) {
140140
return nil, fmt.Errorf("no valid documents found in manifest file")
141141
}
142142

143-
return &ManifestSet{
143+
return &Set{
144144
manifests: manifests,
145145
path: cleanPath,
146146
}, nil
147147
}
148148

149149
// GetManifests returns all manifests in the set.
150-
func (ms *ManifestSet) GetManifests() []*Manifest {
150+
func (ms *Set) GetManifests() []*Manifest {
151151
return ms.manifests
152152
}
153153

154154
// GetPrimaryManifest returns the first workload manifest (Pod, Deployment, etc.).
155155
// Returns nil if no workload manifest is found.
156-
func (ms *ManifestSet) GetPrimaryManifest() *Manifest {
156+
func (ms *Set) GetPrimaryManifest() *Manifest {
157157
workloadKinds := map[string]bool{
158158
"Pod": true, "Deployment": true, "StatefulSet": true,
159159
"DaemonSet": true, "ReplicaSet": true, "Job": true,
@@ -169,7 +169,7 @@ func (ms *ManifestSet) GetPrimaryManifest() *Manifest {
169169

170170
// GetServiceManifest returns the first Service manifest.
171171
// Returns nil if no Service is found.
172-
func (ms *ManifestSet) GetServiceManifest() *Manifest {
172+
func (ms *Set) GetServiceManifest() *Manifest {
173173
for _, m := range ms.manifests {
174174
if m.GetKind() == "Service" {
175175
return m
@@ -183,7 +183,7 @@ func (ms *ManifestSet) GetServiceManifest() *Manifest {
183183
// If targetPort is a named port, it resolves it by looking at the primary workload's container ports.
184184
// Returns 0 if no port is found.
185185
// Returns error if the manifest is not a Service or has invalid structure.
186-
func (ms *ManifestSet) GetServiceTargetPort() (int, error) {
186+
func (ms *Set) GetServiceTargetPort() (int, error) {
187187
svc := ms.GetServiceManifest()
188188
if svc == nil {
189189
return 0, nil // No service found, not an error

0 commit comments

Comments
 (0)