Skip to content

Commit

Permalink
Revert "De duplication logic to NF Deploy Fn Param Ref" (nephio-proje…
Browse files Browse the repository at this point in the history
  • Loading branch information
radoslawc authored and PrimalPimmy committed Aug 2, 2024
1 parent 287a1c3 commit 8832520
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 309 deletions.
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.

0 comments on commit 8832520

Please sign in to comment.