Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "De duplication logic to NF Deploy Fn Param Ref" #496

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions krm-functions/nfdeploy-fn/fn/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,6 @@ func (f *NfDeployFn) UpdateResourceFn(nfDeploymentObj *fn.KubeObject, objs fn.Ku
return nil, err
}

// add all the existing param ref to the struct
// we need to compare for deduplication logic
// slice append is not ideal, it breaks the function idempotency requirement
f.paramRef = nf.Spec.ParametersRefs

capObjs := objs.Where(fn.IsGroupVersionKind(nephioreqv1alpha1.CapacityGroupVersionKind))
for _, o := range capObjs {
if err := f.CapacityUpdate(o); err != nil {
Expand All @@ -276,7 +271,6 @@ func (f *NfDeployFn) UpdateResourceFn(nfDeploymentObj *fn.KubeObject, objs fn.Ku
return nil, err
}
}

itfceObjs := objs.Where(fn.IsGroupVersionKind(nephioreqv1alpha1.InterfaceGroupVersionKind))
for _, o := range itfceObjs {
if err := f.InterfaceUpdate(o); err != nil {
Expand All @@ -293,7 +287,11 @@ func (f *NfDeployFn) UpdateResourceFn(nfDeploymentObj *fn.KubeObject, objs fn.Ku

f.FillCapacityDetails(nf)

nf.Spec.ParametersRefs = f.paramRef
if len(nf.Spec.ParametersRefs) == 0 {
nf.Spec.ParametersRefs = f.paramRef
} else {
nf.Spec.ParametersRefs = append(nf.Spec.ParametersRefs, f.paramRef...)
}

//sort the paramRefs
sort.Slice(nf.Spec.ParametersRefs, func(i, j int) bool {
Expand Down
21 changes: 5 additions & 16 deletions krm-functions/nfdeploy-fn/fn/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,9 @@ func (h *NfDeployFn) FillCapacityDetails(nf *workloadv1alpha1.NFDeployment) {
}

func (h *NfDeployFn) AddDependencyRef(ref corev1.ObjectReference) {
if !h.checkDependencyExist(ref) {
h.paramRef = append(h.paramRef, workloadv1alpha1.ObjectReference{
Name: &ref.Name,
Kind: ref.Kind,
APIVersion: ref.APIVersion,
})
}
}

func (h *NfDeployFn) checkDependencyExist(ref corev1.ObjectReference) bool {
for _, p := range h.paramRef {
if *p.Name == ref.Name && p.Kind == ref.Kind && p.APIVersion == ref.APIVersion {
return true
}
}
return false
h.paramRef = append(h.paramRef, workloadv1alpha1.ObjectReference{
Name: &ref.Name,
Kind: ref.Kind,
APIVersion: ref.APIVersion,
})
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.