1
0
mirror of synced 2026-06-09 16:20:49 +00:00

refactor(api): migrate MakeDependsOn to shared apis/meta func

Signed-off-by: Vincent Dely <vincent.dely@ik.me>
This commit is contained in:
vecil
2026-05-22 21:14:09 +02:00
parent 8c41d5b56d
commit 22953596c6
6 changed files with 5 additions and 51 deletions
-21
View File
@@ -47,7 +47,6 @@ import (
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
notificationv1 "github.com/fluxcd/notification-controller/api/v1"
notificationv1b3 "github.com/fluxcd/notification-controller/api/v1beta3"
"github.com/fluxcd/pkg/apis/meta"
runclient "github.com/fluxcd/pkg/runtime/client"
"github.com/fluxcd/pkg/version"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
@@ -231,26 +230,6 @@ func ParseObjectKindNameNamespace(input string) (kind, name, namespace string) {
return kind, name, namespace
}
func MakeDependsOn(deps []string) []meta.NamespacedObjectReference {
refs := []meta.NamespacedObjectReference{}
for _, dep := range deps {
parts := strings.Split(dep, "/")
depNamespace := ""
depName := ""
if len(parts) > 1 {
depNamespace = parts[0]
depName = parts[1]
} else {
depName = parts[0]
}
refs = append(refs, meta.NamespacedObjectReference{
Namespace: depNamespace,
Name: depName,
})
}
return refs
}
func ValidateComponents(components []string) error {
defaults := install.MakeDefaultOptions()
bootstrapAllComponents := append(defaults.Components, defaults.ComponentsExtra...)
-25
View File
@@ -21,10 +21,7 @@ package utils
import (
"path/filepath"
"reflect"
"testing"
"github.com/fluxcd/pkg/apis/meta"
)
func TestCompatibleVersion(t *testing.T) {
@@ -79,28 +76,6 @@ func TestParseObjectKindNameNamespace(t *testing.T) {
}
}
func TestMakeDependsOn(t *testing.T) {
input := []string{
"someNSA/someNameA",
"someNSB/someNameB",
"someNameC",
"someNSD/",
"",
}
want := []meta.NamespacedObjectReference{
{Namespace: "someNSA", Name: "someNameA"},
{Namespace: "someNSB", Name: "someNameB"},
{Namespace: "", Name: "someNameC"},
{Namespace: "someNSD", Name: ""},
{Namespace: "", Name: ""},
}
got := MakeDependsOn(input)
if !reflect.DeepEqual(got, want) {
t.Errorf("MakeDependsOn() = %v, want %v", got, want)
}
}
func TestValidateComponents(t *testing.T) {
tests := []struct {
name string