feat(hydrator): add inline parameter support to Source Hydrator (#24228) (#24277)

Signed-off-by: sangyeong01 <tkddud386@gmail.com>
Signed-off-by: sangyeong01 <sy.park@alpacax.com>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
This commit is contained in:
Sangyeong Park
2025-12-06 02:32:48 +09:00
committed by GitHub
parent 528482c87a
commit 0c6fa288c2
28 changed files with 46325 additions and 782 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1055,6 +1055,18 @@ message DrySource {
// Path is a directory path within the Git repository where the manifests are located
optional string path = 3;
// Helm specifies helm specific options
optional ApplicationSourceHelm helm = 4;
// Kustomize specifies kustomize specific options
optional ApplicationSourceKustomize kustomize = 5;
// Directory specifies path/directory specific options
optional ApplicationSourceDirectory directory = 6;
// Plugin specifies config management plugin specific options
optional ApplicationSourcePlugin plugin = 7;
}
// DuckType defines a generator to match against clusters registered with ArgoCD.

View File

@@ -431,7 +431,7 @@ func (s SourceHydrator) GetDrySource() ApplicationSource {
// DeepEquals returns true if the SourceHydrator is deeply equal to the given SourceHydrator.
func (s SourceHydrator) DeepEquals(hydrator SourceHydrator) bool {
return s.DrySource == hydrator.DrySource && s.SyncSource == hydrator.SyncSource && s.HydrateTo.DeepEquals(hydrator.HydrateTo)
return s.DrySource.Equals(hydrator.DrySource) && s.SyncSource == hydrator.SyncSource && s.HydrateTo.DeepEquals(hydrator.HydrateTo)
}
// DrySource specifies a location for dry "don't repeat yourself" manifest source information.
@@ -442,6 +442,28 @@ type DrySource struct {
TargetRevision string `json:"targetRevision" protobuf:"bytes,2,name=targetRevision"`
// Path is a directory path within the Git repository where the manifests are located
Path string `json:"path" protobuf:"bytes,3,name=path"`
// Helm specifies helm specific options
Helm *ApplicationSourceHelm `json:"helm,omitempty" protobuf:"bytes,4,opt,name=helm"`
// Kustomize specifies kustomize specific options
Kustomize *ApplicationSourceKustomize `json:"kustomize,omitempty" protobuf:"bytes,5,opt,name=kustomize"`
// Directory specifies path/directory specific options
Directory *ApplicationSourceDirectory `json:"directory,omitempty" protobuf:"bytes,6,opt,name=directory"`
// Plugin specifies config management plugin specific options
Plugin *ApplicationSourcePlugin `json:"plugin,omitempty" protobuf:"bytes,7,opt,name=plugin"`
}
func (in DrySource) Equals(other DrySource) bool {
// Equals compares two instances of ApplicationSource and return true if instances are equal.
if !in.Plugin.Equals(other.Plugin) {
return false
}
// reflect.DeepEqual works fine for the other fields. Since the plugin fields are equal, set them to null so they're
// not considered in the DeepEqual comparison.
sourceCopy := in
otherCopy := other
sourceCopy.Plugin = nil
otherCopy.Plugin = nil
return reflect.DeepEqual(sourceCopy, otherCopy)
}
// SyncSource specifies a location from which hydrated manifests may be synced. RepoURL is assumed based on the

View File

@@ -4842,3 +4842,26 @@ func TestSanitized(t *testing.T) {
},
}, cluster.Sanitized())
}
func TestSourceHydrator_Equals(t *testing.T) {
t.Parallel()
tests := []struct {
name string
a SourceHydrator
b SourceHydrator
expected bool
}{
{"different SourceHydrators", SourceHydrator{}, SourceHydrator{DrySource: DrySource{Helm: &ApplicationSourceHelm{Namespace: "test"}}}, false},
{"equal SourceHydrators", SourceHydrator{DrySource: DrySource{Helm: &ApplicationSourceHelm{Namespace: "test"}}}, SourceHydrator{DrySource: DrySource{Helm: &ApplicationSourceHelm{Namespace: "test"}}}, true},
}
for _, testCase := range tests {
testCopy := testCase
t.Run(testCopy.name, func(t *testing.T) {
t.Parallel()
assert.Equal(t, testCopy.expected, testCopy.a.DeepEquals(testCopy.b))
})
}
}

View File

@@ -1967,6 +1967,26 @@ func (in *ConnectionState) DeepCopy() *ConnectionState {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DrySource) DeepCopyInto(out *DrySource) {
*out = *in
if in.Helm != nil {
in, out := &in.Helm, &out.Helm
*out = new(ApplicationSourceHelm)
(*in).DeepCopyInto(*out)
}
if in.Kustomize != nil {
in, out := &in.Kustomize, &out.Kustomize
*out = new(ApplicationSourceKustomize)
(*in).DeepCopyInto(*out)
}
if in.Directory != nil {
in, out := &in.Directory, &out.Directory
*out = new(ApplicationSourceDirectory)
(*in).DeepCopyInto(*out)
}
if in.Plugin != nil {
in, out := &in.Plugin, &out.Plugin
*out = new(ApplicationSourcePlugin)
(*in).DeepCopyInto(*out)
}
return
}
@@ -4389,7 +4409,7 @@ func (in *SignatureKey) DeepCopy() *SignatureKey {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SourceHydrator) DeepCopyInto(out *SourceHydrator) {
*out = *in
out.DrySource = in.DrySource
in.DrySource.DeepCopyInto(&out.DrySource)
out.SyncSource = in.SyncSource
if in.HydrateTo != nil {
in, out := &in.HydrateTo, &out.HydrateTo