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

align api with resource backend #43

Merged
merged 1 commit into from
Jun 8, 2023
Merged
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
14 changes: 7 additions & 7 deletions config/crd/bases/req.nephio.org_datanetworks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ spec:
description: Pools contains the statuses of individual pools
items:
properties:
ipAllocation:
description: IPAllocation holds the result of the IP allocation
belonging to the pool
ipClaim:
description: IPClaim holds the result of the IP claim belonging
to the pool
properties:
conditions:
description: Conditions of the resource.
Expand Down Expand Up @@ -172,15 +172,15 @@ spec:
type: object
type: array
expiryTime:
description: ExpiryTime defines when the allocation expires
description: ExpiryTime defines when the claim expires
type: string
gateway:
description: Gateway defines the gateway IP for the allocated
description: Gateway defines the gateway IP for the claimed
prefix Gateway is only relevant for prefix kind = network
type: string
prefix:
description: Prefix defines the prefix, allocated by the
IPAM backend
description: Prefix defines the prefix, claimed through
the IPAM backend
type: string
type: object
name:
Expand Down
24 changes: 12 additions & 12 deletions config/crd/bases/req.nephio.org_interfaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ spec:
type: object
status:
properties:
ipAllocationStatus:
ipClaimStatus:
items:
description: IPAllocationStatus defines the observed state of IPAllocation
description: IPClaimStatus defines the observed state of IPClaim
properties:
conditions:
description: Conditions of the resource.
Expand Down Expand Up @@ -169,20 +169,20 @@ spec:
type: object
type: array
expiryTime:
description: ExpiryTime defines when the allocation expires
description: ExpiryTime defines when the claim expires
type: string
gateway:
description: Gateway defines the gateway IP for the allocated
description: Gateway defines the gateway IP for the claimed
prefix Gateway is only relevant for prefix kind = network
type: string
prefix:
description: Prefix defines the prefix, allocated by the IPAM
backend
description: Prefix defines the prefix, claimed through the
IPAM backend
type: string
type: object
type: array
vlanAllocationStatus:
description: VLANAllocationStatus defines the observed state of VLANAllocation
vlanClaimStatus:
description: VLANClaimStatus defines the observed state of VLANClaim
properties:
conditions:
description: Conditions of the resource.
Expand Down Expand Up @@ -247,15 +247,15 @@ spec:
type: object
type: array
expiryTime:
description: ExpiryTime indicated when the allocation expires
description: ExpiryTime indicated when the claim expires
type: string
vlanID:
description: VLANID defines the vlan ID, allocated by the VLAN
description: VLANID defines the vlan ID, claimed through the VLAN
backend
type: integer
vlanRange:
description: VLANRange defines the vlan range, allocated by the
VLAN backend
description: VLANRange defines the vlan range, claimed through
the VLAN backend
type: string
type: object
type: object
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/google/go-cmp v0.5.9
github.com/nokia/k8s-ipam v0.0.4-0.20230531091740-a5fc07f8c2e2
github.com/nokia/k8s-ipam v0.0.4-0.20230608184434-0c910788bac7
github.com/stretchr/testify v1.8.1
k8s.io/api v0.27.2
k8s.io/apimachinery v0.27.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
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.20230531091740-a5fc07f8c2e2 h1:Uzk1fEHWq8+rp9KuJqfumUoeS947uSLUjxFk6t2mz5w=
github.com/nokia/k8s-ipam v0.0.4-0.20230531091740-a5fc07f8c2e2/go.mod h1:puHYNVuWM77mFqVgwJkq2NePTVScWDlZZPB45sCN21g=
github.com/nokia/k8s-ipam v0.0.4-0.20230608184434-0c910788bac7 h1:ZoUMFeP4Hhh35LMvSO4+0+y+lNw0G4fhus15WpOCF8I=
github.com/nokia/k8s-ipam v0.0.4-0.20230608184434-0c910788bac7/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/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
Expand Down
2 changes: 1 addition & 1 deletion infra/v1alpha1/network_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"reflect"

reqv1alpha1 "github.com/nephio-project/api/nf_requirements/v1alpha1"
ipamv1alpha1 "github.com/nokia/k8s-ipam/apis/alloc/ipam/v1alpha1"
ipamv1alpha1 "github.com/nokia/k8s-ipam/apis/resource/ipam/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)
Expand Down
2 changes: 1 addition & 1 deletion infra/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions nf_requirements/v1alpha1/dnn_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import (
"reflect"

ipamv1alpha1 "github.com/nokia/k8s-ipam/apis/alloc/ipam/v1alpha1"
ipamv1alpha1 "github.com/nokia/k8s-ipam/apis/resource/ipam/v1alpha1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -63,8 +63,8 @@ type DataNetworkStatus struct {
type PoolStatus struct {
// Name of the pool
Name string `yaml:"name,omitempty" json:"name,omitempty"`
// IPAllocation holds the result of the IP allocation belonging to the pool
IPAllocation ipamv1alpha1.IPAllocationStatus `yaml:"ipAllocation,omitempty" json:"ipAllocation,omitempty"`
// IPClaim holds the result of the IP claim belonging to the pool
IPClaim ipamv1alpha1.IPClaimStatus `yaml:"ipClaim,omitempty" json:"ipClaim,omitempty"`
}

// DataNetworkName type metadata.
Expand Down
12 changes: 6 additions & 6 deletions nf_requirements/v1alpha1/interface_interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import (
"fmt"

ipamv1alpha1 "github.com/nokia/k8s-ipam/apis/alloc/ipam/v1alpha1"
ipamv1alpha1 "github.com/nokia/k8s-ipam/apis/resource/ipam/v1alpha1"
)

const (
Expand Down Expand Up @@ -142,21 +142,21 @@ func (spec *InterfaceSpec) Validate() error {
return nil
}

func (r *InterfaceStatus) UpsertIPAllocation(newAllocStatus ipamv1alpha1.IPAllocationStatus) {
func (r *InterfaceStatus) UpsertIPAllocation(newAllocStatus ipamv1alpha1.IPClaimStatus) {
if newAllocStatus.Prefix == nil {
return
}
if r.IPAllocationStatus == nil {
r.IPAllocationStatus = []ipamv1alpha1.IPAllocationStatus{}
if r.IPClaimStatus == nil {
r.IPClaimStatus = []ipamv1alpha1.IPClaimStatus{}
}
for _, alloc := range r.IPAllocationStatus {
for _, alloc := range r.IPClaimStatus {

if alloc.Prefix != nil && *alloc.Prefix == *newAllocStatus.Prefix {
alloc = newAllocStatus
return
}
}
r.IPAllocationStatus = append(r.IPAllocationStatus, newAllocStatus)
r.IPClaimStatus = append(r.IPClaimStatus, newAllocStatus)
}

func (r *InterfaceSpec) GetAddressFamilies() []IPFamily {
Expand Down
24 changes: 12 additions & 12 deletions nf_requirements/v1alpha1/interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
ipamv1alpha1 "github.com/nokia/k8s-ipam/apis/alloc/ipam/v1alpha1"
ipamv1alpha1 "github.com/nokia/k8s-ipam/apis/resource/ipam/v1alpha1"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/pointer"
Expand Down Expand Up @@ -258,45 +258,45 @@ func TestIsAddressFamilySupported(t *testing.T) {
func TestUpsertIPAllocation(t *testing.T) {
cases := map[string]struct {
interfaceStatus *InterfaceStatus
allocStatus ipamv1alpha1.IPAllocationStatus
claimStatus ipamv1alpha1.IPClaimStatus
expectedLength int
}{
"Init": {
interfaceStatus: &InterfaceStatus{},
allocStatus: ipamv1alpha1.IPAllocationStatus{Prefix: pointer.String("a")},
claimStatus: ipamv1alpha1.IPClaimStatus{Prefix: pointer.String("a")},
expectedLength: 1,
},
"InitWithNil": {
interfaceStatus: &InterfaceStatus{},
allocStatus: ipamv1alpha1.IPAllocationStatus{},
claimStatus: ipamv1alpha1.IPClaimStatus{},
expectedLength: 0,
},
"Update": {
interfaceStatus: &InterfaceStatus{
IPAllocationStatus: []ipamv1alpha1.IPAllocationStatus{
IPClaimStatus: []ipamv1alpha1.IPClaimStatus{
{Prefix: pointer.String("a")},
},
},
allocStatus: ipamv1alpha1.IPAllocationStatus{Prefix: pointer.String("a")},
claimStatus: ipamv1alpha1.IPClaimStatus{Prefix: pointer.String("a")},
expectedLength: 1,
},
"Add": {
interfaceStatus: &InterfaceStatus{
IPAllocationStatus: []ipamv1alpha1.IPAllocationStatus{
IPClaimStatus: []ipamv1alpha1.IPClaimStatus{
{Prefix: pointer.String("a")},
},
},
allocStatus: ipamv1alpha1.IPAllocationStatus{Prefix: pointer.String("b")},
claimStatus: ipamv1alpha1.IPClaimStatus{Prefix: pointer.String("b")},
expectedLength: 2,
},
}

for name, tc := range cases {
t.Run(name, func(t *testing.T) {
tc.interfaceStatus.UpsertIPAllocation(tc.allocStatus)
tc.interfaceStatus.UpsertIPAllocation(tc.claimStatus)

if len(tc.interfaceStatus.IPAllocationStatus) != tc.expectedLength {
t.Errorf("-want: %d, +got: %d", tc.expectedLength, len(tc.interfaceStatus.IPAllocationStatus))
if len(tc.interfaceStatus.IPClaimStatus) != tc.expectedLength {
t.Errorf("-want: %d, +got: %d", tc.expectedLength, len(tc.interfaceStatus.IPClaimStatus))
}
})
}
Expand Down Expand Up @@ -325,7 +325,7 @@ func TestGetAddressFamilies(t *testing.T) {
},
"none": {
interfaceSpec: &InterfaceSpec{},
afs: []IPFamily{IPFamilyIPv4},
afs: []IPFamily{IPFamilyIPv4},
},
}

Expand Down
8 changes: 4 additions & 4 deletions nf_requirements/v1alpha1/interface_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package v1alpha1
import (
"reflect"

ipamv1alpha1 "github.com/nokia/k8s-ipam/apis/alloc/ipam/v1alpha1"
vlanv1alpha1 "github.com/nokia/k8s-ipam/apis/alloc/vlan/v1alpha1"
ipamv1alpha1 "github.com/nokia/k8s-ipam/apis/resource/ipam/v1alpha1"
vlanv1alpha1 "github.com/nokia/k8s-ipam/apis/resource/vlan/v1alpha1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -52,8 +52,8 @@ type InterfaceSpec struct {
}

type InterfaceStatus struct {
IPAllocationStatus []ipamv1alpha1.IPAllocationStatus `json:"ipAllocationStatus,omitempty" yaml:"ipAllocationStatus,omitempty"`
VLANAllocationStatus *vlanv1alpha1.VLANAllocationStatus `json:"vlanAllocationStatus,omitempty" yaml:"vlanAllocationStatus,omitempty"`
IPClaimStatus []ipamv1alpha1.IPClaimStatus `json:"ipClaimStatus,omitempty" yaml:"ipClaimStatus,omitempty"`
VLANClaimStatus *vlanv1alpha1.VLANClaimStatus `json:"vlanClaimStatus,omitempty" yaml:"vlanClaimStatus,omitempty"`
}

// Interface type metadata.
Expand Down
18 changes: 9 additions & 9 deletions nf_requirements/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.