Skip to content

Commit

Permalink
ueransim specialised + generalised nad (#324)
Browse files Browse the repository at this point in the history
added ueransim specialiser
generalised nad
  • Loading branch information
henderiw authored Jun 28, 2023
1 parent 8b92b80 commit e5dd3bd
Show file tree
Hide file tree
Showing 153 changed files with 1,473 additions and 490 deletions.
4 changes: 2 additions & 2 deletions controllers/pkg/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ require (
github.com/go-logr/logr v1.2.4
github.com/google/go-cmp v0.5.9
github.com/henderiw-nephio/network v0.0.0-20230626193806-04743403261e
github.com/nephio-project/api v0.0.0-20230622115552-0304af432fd3
github.com/nephio-project/api v0.0.0-20230627152656-a2bf013a68da
github.com/nephio-project/nephio/krm-functions/configinject-fn v0.0.0-00010101000000-000000000000
github.com/nephio-project/nephio/krm-functions/ipam-fn v0.0.0-00010101000000-000000000000
github.com/nephio-project/nephio/krm-functions/lib v0.0.0-20230605213956-a1e470f419a4
github.com/nephio-project/nephio/krm-functions/vlan-fn v0.0.0-00010101000000-000000000000
github.com/nokia/k8s-ipam v0.0.4-0.20230614172255-e361e59e279c
github.com/nokia/k8s-ipam v0.0.4-0.20230628092530-8a292aec80a4
github.com/openconfig/ygot v0.28.3
github.com/pkg/errors v0.9.1
github.com/srl-labs/ygotsrl/v22 v22.11.1
Expand Down
8 changes: 4 additions & 4 deletions controllers/pkg/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/nephio-project/api v0.0.0-20230622115552-0304af432fd3 h1:7e6RZ+nQJLkB5NzbY8pGSxhzB2OkC3It//z8t3OE23g=
github.com/nephio-project/api v0.0.0-20230622115552-0304af432fd3/go.mod h1:9w+JbXeyiT3KZrrXab0pzaWtiUk4upvgLzpqOtSmbpI=
github.com/nokia/k8s-ipam v0.0.4-0.20230614172255-e361e59e279c h1:zNeqCNUXERQOPbFvcDv8zbEGtZSpTWar/fgqwvKKklo=
github.com/nokia/k8s-ipam v0.0.4-0.20230614172255-e361e59e279c/go.mod h1:ZVMmhD6jllAAO3YGIZFXUQbKRtEiIYgZ772bn/1GVz4=
github.com/nephio-project/api v0.0.0-20230627152656-a2bf013a68da h1:GqTpDe8Xbqs+R4TXLJjn4nbO18/XrkXesN7TITXsrwI=
github.com/nephio-project/api v0.0.0-20230627152656-a2bf013a68da/go.mod h1:9w+JbXeyiT3KZrrXab0pzaWtiUk4upvgLzpqOtSmbpI=
github.com/nokia/k8s-ipam v0.0.4-0.20230628092530-8a292aec80a4 h1:4v0n24tsumwuz1BDGKoGWxZMFtqAlYpI87gE/enMUUI=
github.com/nokia/k8s-ipam v0.0.4-0.20230628092530-8a292aec80a4/go.mod h1:ZVMmhD6jllAAO3YGIZFXUQbKRtEiIYgZ772bn/1GVz4=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q=
github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU=
Expand Down
2 changes: 1 addition & 1 deletion krm-functions/configinject-fn/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ FROM golang:1.20-alpine
ENV CGO_ENABLED=0
WORKDIR /go/src/
COPY krm-functions/ krm-functions/
WORKDIR /go/src/krm-functions/ipam-fn
WORKDIR /go/src/krm-functions/configinject-fn
RUN go install
RUN go build -o /usr/local/bin/function ./

Expand Down
2 changes: 1 addition & 1 deletion krm-functions/configinject-fn/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
IMAGE_TAG ?= latest
REGISTRY ?= docker.io/nephio
IMAGE_NAME ?= inject-fn
IMAGE_NAME ?= configinject-fn
IMG ?= $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)

# This includes the following targets:
Expand Down
4 changes: 2 additions & 2 deletions krm-functions/configinject-fn/fn/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (f *FnR) desiredOwnedResourceList(forObj *fn.KubeObject) (fn.KubeObjects, e
}

// updateDependencyResource adds the resources to the status
func (f *FnR) updateDependencyResource(forObj *fn.KubeObject, objs fn.KubeObjects) (*fn.KubeObject, error) {
func (f *FnR) updateDependencyResource(forObj *fn.KubeObject, objs fn.KubeObjects) (fn.KubeObjects, error) {
if forObj == nil {
return nil, fmt.Errorf("expected a for object but got nil")
}
Expand Down Expand Up @@ -294,7 +294,7 @@ func (f *FnR) updateDependencyResource(forObj *fn.KubeObject, objs fn.KubeObject
return nil, err
}

return &depObj.KubeObject, nil
return fn.KubeObjects{&depObj.KubeObject}, nil
}

func GetConfigKubeObject(forObj, o *fn.KubeObject) (*fn.KubeObject, error) {
Expand Down
2 changes: 1 addition & 1 deletion krm-functions/configinject-fn/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/GoogleContainerTools/kpt v1.0.0-beta.29.0.20230327202912-01513604feaa
github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20230427202446-3255accc518d
github.com/GoogleContainerTools/kpt/porch/api v0.0.0-20230608012444-ee7c8cf378e9
github.com/nephio-project/api v0.0.0-20230622115552-0304af432fd3
github.com/nephio-project/api v0.0.0-20230627152656-a2bf013a68da
github.com/nephio-project/nephio/krm-functions/lib v0.0.0-00010101000000-000000000000
k8s.io/api v0.27.3
k8s.io/apimachinery v0.27.3
Expand Down
4 changes: 2 additions & 2 deletions krm-functions/configinject-fn/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/nephio-project/api v0.0.0-20230622115552-0304af432fd3 h1:7e6RZ+nQJLkB5NzbY8pGSxhzB2OkC3It//z8t3OE23g=
github.com/nephio-project/api v0.0.0-20230622115552-0304af432fd3/go.mod h1:9w+JbXeyiT3KZrrXab0pzaWtiUk4upvgLzpqOtSmbpI=
github.com/nephio-project/api v0.0.0-20230627152656-a2bf013a68da h1:GqTpDe8Xbqs+R4TXLJjn4nbO18/XrkXesN7TITXsrwI=
github.com/nephio-project/api v0.0.0-20230627152656-a2bf013a68da/go.mod h1:9w+JbXeyiT3KZrrXab0pzaWtiUk4upvgLzpqOtSmbpI=
github.com/nokia/k8s-ipam v0.0.4-0.20230614172255-e361e59e279c h1:zNeqCNUXERQOPbFvcDv8zbEGtZSpTWar/fgqwvKKklo=
github.com/nokia/k8s-ipam v0.0.4-0.20230614172255-e361e59e279c/go.mod h1:ZVMmhD6jllAAO3YGIZFXUQbKRtEiIYgZ772bn/1GVz4=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
Expand Down
4 changes: 2 additions & 2 deletions krm-functions/dnn-fn/fn/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (f *dnnFn) desiredOwnedResourceList(o *fn.KubeObject) (fn.KubeObjects, erro
}

// updateDnnResource assembles the Status of the DNN "for object" from the status of the owned IPClaims
func (f *dnnFn) updateDnnResource(dnnObj_ *fn.KubeObject, owned fn.KubeObjects) (*fn.KubeObject, error) {
func (f *dnnFn) updateDnnResource(dnnObj_ *fn.KubeObject, owned fn.KubeObjects) (fn.KubeObjects, error) {
dnnObj, err := ko.NewFromKubeObject[nephioreqv1alpha1.DataNetwork](dnnObj_)
if err != nil {
return nil, err
Expand Down Expand Up @@ -186,7 +186,7 @@ func (f *dnnFn) updateDnnResource(dnnObj_ *fn.KubeObject, owned fn.KubeObjects)
}

err = dnnObj.SetStatus(dnn)
return &dnnObj.KubeObject, err
return fn.KubeObjects{&dnnObj.KubeObject}, err
}

func getAnnotations(annotations map[string]string) map[string]string {
Expand Down
4 changes: 2 additions & 2 deletions krm-functions/dnn-fn/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ replace github.com/nephio-project/nephio/krm-functions/lib => ../lib

require (
github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20230427202446-3255accc518d
github.com/nephio-project/api v0.0.0-20230622115552-0304af432fd3
github.com/nephio-project/api v0.0.0-20230627152656-a2bf013a68da
github.com/nephio-project/nephio/krm-functions/lib v0.0.0-20230605213956-a1e470f419a4
github.com/nokia/k8s-ipam v0.0.4-0.20230614172255-e361e59e279c
github.com/nokia/k8s-ipam v0.0.4-0.20230628092530-8a292aec80a4
k8s.io/api v0.27.3
k8s.io/apimachinery v0.27.3
k8s.io/utils v0.0.0-20230505201702-9f6742963106
Expand Down
8 changes: 4 additions & 4 deletions krm-functions/dnn-fn/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/nephio-project/api v0.0.0-20230622115552-0304af432fd3 h1:7e6RZ+nQJLkB5NzbY8pGSxhzB2OkC3It//z8t3OE23g=
github.com/nephio-project/api v0.0.0-20230622115552-0304af432fd3/go.mod h1:9w+JbXeyiT3KZrrXab0pzaWtiUk4upvgLzpqOtSmbpI=
github.com/nokia/k8s-ipam v0.0.4-0.20230614172255-e361e59e279c h1:zNeqCNUXERQOPbFvcDv8zbEGtZSpTWar/fgqwvKKklo=
github.com/nokia/k8s-ipam v0.0.4-0.20230614172255-e361e59e279c/go.mod h1:ZVMmhD6jllAAO3YGIZFXUQbKRtEiIYgZ772bn/1GVz4=
github.com/nephio-project/api v0.0.0-20230627152656-a2bf013a68da h1:GqTpDe8Xbqs+R4TXLJjn4nbO18/XrkXesN7TITXsrwI=
github.com/nephio-project/api v0.0.0-20230627152656-a2bf013a68da/go.mod h1:9w+JbXeyiT3KZrrXab0pzaWtiUk4upvgLzpqOtSmbpI=
github.com/nokia/k8s-ipam v0.0.4-0.20230628092530-8a292aec80a4 h1:4v0n24tsumwuz1BDGKoGWxZMFtqAlYpI87gE/enMUUI=
github.com/nokia/k8s-ipam v0.0.4-0.20230628092530-8a292aec80a4/go.mod h1:ZVMmhD6jllAAO3YGIZFXUQbKRtEiIYgZ772bn/1GVz4=
github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q=
github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
4 changes: 2 additions & 2 deletions krm-functions/interface-fn/fn/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (f *itfceFn) desiredOwnedResourceList(o *fn.KubeObject) (fn.KubeObjects, er
return resources, nil
}

func (f *itfceFn) updateItfceResource(forObj *fn.KubeObject, objs fn.KubeObjects) (*fn.KubeObject, error) {
func (f *itfceFn) updateItfceResource(forObj *fn.KubeObject, objs fn.KubeObjects) (fn.KubeObjects, error) {
if forObj == nil {
return nil, fmt.Errorf("expected a for object but got nil")
}
Expand Down Expand Up @@ -235,7 +235,7 @@ func (f *itfceFn) updateItfceResource(forObj *fn.KubeObject, objs fn.KubeObjects
}
// set the status
err = itfceKOE.SetStatus(itfce)
return &itfceKOE.KubeObject, err
return fn.KubeObjects{&itfceKOE.KubeObject}, err
}

func (f *itfceFn) getVLANClaim(meta metav1.ObjectMeta) (*fn.KubeObject, error) {
Expand Down
4 changes: 2 additions & 2 deletions krm-functions/interface-fn/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ replace github.com/nephio-project/nephio/krm-functions/lib => ../lib
require (
github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20230427202446-3255accc518d
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.4.0
github.com/nephio-project/api v0.0.0-20230622115552-0304af432fd3
github.com/nephio-project/api v0.0.0-20230627152656-a2bf013a68da
github.com/nephio-project/nephio/krm-functions/lib v0.0.0-20230605213956-a1e470f419a4
github.com/nokia/k8s-ipam v0.0.4-0.20230614172255-e361e59e279c
github.com/nokia/k8s-ipam v0.0.4-0.20230628092530-8a292aec80a4
k8s.io/api v0.27.3
k8s.io/apimachinery v0.27.3
sigs.k8s.io/kustomize/kyaml v0.14.2
Expand Down
8 changes: 4 additions & 4 deletions krm-functions/interface-fn/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/nephio-project/api v0.0.0-20230622115552-0304af432fd3 h1:7e6RZ+nQJLkB5NzbY8pGSxhzB2OkC3It//z8t3OE23g=
github.com/nephio-project/api v0.0.0-20230622115552-0304af432fd3/go.mod h1:9w+JbXeyiT3KZrrXab0pzaWtiUk4upvgLzpqOtSmbpI=
github.com/nokia/k8s-ipam v0.0.4-0.20230614172255-e361e59e279c h1:zNeqCNUXERQOPbFvcDv8zbEGtZSpTWar/fgqwvKKklo=
github.com/nokia/k8s-ipam v0.0.4-0.20230614172255-e361e59e279c/go.mod h1:ZVMmhD6jllAAO3YGIZFXUQbKRtEiIYgZ772bn/1GVz4=
github.com/nephio-project/api v0.0.0-20230627152656-a2bf013a68da h1:GqTpDe8Xbqs+R4TXLJjn4nbO18/XrkXesN7TITXsrwI=
github.com/nephio-project/api v0.0.0-20230627152656-a2bf013a68da/go.mod h1:9w+JbXeyiT3KZrrXab0pzaWtiUk4upvgLzpqOtSmbpI=
github.com/nokia/k8s-ipam v0.0.4-0.20230628092530-8a292aec80a4 h1:4v0n24tsumwuz1BDGKoGWxZMFtqAlYpI87gE/enMUUI=
github.com/nokia/k8s-ipam v0.0.4-0.20230628092530-8a292aec80a4/go.mod h1:ZVMmhD6jllAAO3YGIZFXUQbKRtEiIYgZ772bn/1GVz4=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q=
github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU=
Expand Down
30 changes: 17 additions & 13 deletions krm-functions/ipam-fn/fn/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/GoogleContainerTools/kpt-functions-sdk/go/fn"
"github.com/nephio-project/nephio/krm-functions/lib/condkptsdk"
"github.com/nephio-project/nephio/krm-functions/lib/kubeobject"
resourcev1alpha1 "github.com/nokia/k8s-ipam/apis/resource/common/v1alpha1"
ipamv1alpha1 "github.com/nokia/k8s-ipam/apis/resource/ipam/v1alpha1"
"github.com/nokia/k8s-ipam/pkg/proxy/clientproxy"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -66,7 +67,7 @@ func (f *FnR) Run(rl *fn.ResourceList) (bool, error) {

// updateIPClaimResource provides an ip claim for a given KRM resource
// in the package by calling the ipam backend
func (f *FnR) updateIPClaimResource(forObj *fn.KubeObject, objs fn.KubeObjects) (*fn.KubeObject, error) {
func (f *FnR) updateIPClaimResource(forObj *fn.KubeObject, objs fn.KubeObjects) (fn.KubeObjects, error) {
if forObj == nil {
return nil, fmt.Errorf("expected a for object but got nil")
}
Expand All @@ -80,12 +81,22 @@ func (f *FnR) updateIPClaimResource(forObj *fn.KubeObject, objs fn.KubeObjects)
return nil, err
}
newclaim := claim.DeepCopy()
resp, err := f.ClientProxy.Claim(context.Background(), newclaim, nil)
if err != nil {
return nil, err
var resp *ipamv1alpha1.IPClaim
if _, ok := claim.Annotations[resourcev1alpha1.NephioAPIAction]; ok {
// get action
fn.Log("claim action get\n")
resp, err = f.ClientProxy.GetClaim(context.Background(), newclaim, nil)
if err != nil {
return nil, err
}
} else {
fn.Log("claim action claim\n")
resp, err = f.ClientProxy.Claim(context.Background(), newclaim, nil)
if err != nil {
return nil, err
}
}
claim.Status = resp.Status

if claim.Status.Prefix != nil {
fn.Logf("claim resp prefix: %v\n", *resp.Status.Prefix)
}
Expand All @@ -94,12 +105,5 @@ func (f *FnR) updateIPClaimResource(forObj *fn.KubeObject, objs fn.KubeObjects)
}
// set the status
err = claimKOE.SetStatus(resp)
return &claimKOE.KubeObject, err
return fn.KubeObjects{&claimKOE.KubeObject}, err
}

/*
func getNewName(annotations map[string]string, origName string) string {
split := strings.Split(annotations[condkptsdk.SpecializerFor], ".")
return fmt.Sprintf("%s-%s", split[len(split)-1], origName)
}
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: config.kubernetes.io/v1
kind: ResourceList
items:
- apiVersion: ipam.resource.nephio.org/v1alpha1
kind: IPClaim
metadata:
name: upf-cluster01-n3
annotations:
nephio.org/action: get
specializer.nephio.org/owner: req.nephio.org/v1alpha1.Interface.n3
spec:
kind: network
selector:
matchLabels:
nephio.org/cluster-name: cluster01
networkInstance:
name: vpc
status:
prefix: 10.0.0.10/24
gateway: 10.0.0.1
- apiVersion: kpt.dev/v1
kind: Kptfile
# comment A
metadata:
name: pkg-upf
#commentB
annotations:
config.kubernetes.io/local-config: "true"
info:
description: upf package example
pipeline: {}
status:
conditions:
- message: update done
status: "True"
type: ipam.resource.nephio.org/v1alpha1.IPClaim.upf-cluster01-n3
14 changes: 14 additions & 0 deletions krm-functions/ipam-fn/fn/testdata/get_network_prefix/ipclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: ipam.resource.nephio.org/v1alpha1
kind: IPClaim
metadata:
name: upf-cluster01-n3
annotations:
nephio.org/action: get
specializer.nephio.org/owner: req.nephio.org/v1alpha1.Interface.n3
spec:
kind: network
selector:
matchLabels:
nephio.org/cluster-name: cluster01
networkInstance:
name: vpc
2 changes: 1 addition & 1 deletion krm-functions/ipam-fn/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ replace github.com/nephio-project/nephio/krm-functions/lib => ../lib
require (
github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20230427202446-3255accc518d
github.com/nephio-project/nephio/krm-functions/lib v0.0.0-20230605213956-a1e470f419a4
github.com/nokia/k8s-ipam v0.0.4-0.20230614172255-e361e59e279c
github.com/nokia/k8s-ipam v0.0.4-0.20230628092530-8a292aec80a4
k8s.io/api v0.27.3
)

Expand Down
4 changes: 2 additions & 2 deletions krm-functions/ipam-fn/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/nokia/k8s-ipam v0.0.4-0.20230614172255-e361e59e279c h1:zNeqCNUXERQOPbFvcDv8zbEGtZSpTWar/fgqwvKKklo=
github.com/nokia/k8s-ipam v0.0.4-0.20230614172255-e361e59e279c/go.mod h1:ZVMmhD6jllAAO3YGIZFXUQbKRtEiIYgZ772bn/1GVz4=
github.com/nokia/k8s-ipam v0.0.4-0.20230628092530-8a292aec80a4 h1:4v0n24tsumwuz1BDGKoGWxZMFtqAlYpI87gE/enMUUI=
github.com/nokia/k8s-ipam v0.0.4-0.20230628092530-8a292aec80a4/go.mod h1:ZVMmhD6jllAAO3YGIZFXUQbKRtEiIYgZ772bn/1GVz4=
github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q=
github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
19 changes: 8 additions & 11 deletions krm-functions/lib/condkptsdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ type Config struct {
type PopulateOwnResourcesFn func(*fn.KubeObject) (fn.KubeObjects, error)

// the list of objects contains the owns and the specific watches
type UpdateResourceFn func(*fn.KubeObject, fn.KubeObjects) (*fn.KubeObject, error)
type UpdateResourceFn func(*fn.KubeObject, fn.KubeObjects) (fn.KubeObjects, error)

func UpdateResourceFnNop(*fn.KubeObject, fn.KubeObjects) (*fn.KubeObject, error) { return nil, nil }
func UpdateResourceFnNop(*fn.KubeObject, fn.KubeObjects) (fn.KubeObjects, error) { return nil, nil }

type WatchCallbackFn func(*fn.KubeObject) error

Expand All @@ -82,14 +82,11 @@ func New(rl *fn.ResourceList, cfg *Config) (KptCondSDK, error) {
}

type sdk struct {
cfg *Config
inv inventory
rl *fn.ResourceList
//conditions *ko.KptPackageConditions
//kptfile *fn.KubeObject
cfg *Config
inv inventory
rl *fn.ResourceList
kptfile kptfilelibv1.KptFile
//ready bool // tracks the overall ready state
debug bool // set based on for annotation
debug bool // set based on for annotation
}

func (r *sdk) Run() (bool, error) {
Expand Down Expand Up @@ -166,9 +163,9 @@ func (r *sdk) Run() (bool, error) {
// the error and condition update is handled in the fn as we can have multiple forresource
r.updateChildren()

// stage 2 of the sdk pipeline
// stage 2 of the sdk pipeline -> update resources (forObj and adjacent resources)
// the error and condition update is handled in the fn as we can have multiple forresource
r.updateResource()
r.updateResources()

// handle readiness condition -> if all conditions of the for resource are true we can declare readiness
if r.cfg.Root {
Expand Down
Loading

0 comments on commit e5dd3bd

Please sign in to comment.