Skip to content
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -503,4 +503,4 @@ $(GO_JUNIT_REPORT): $(TOOLS_DIR)/go.mod

go-junit-report: $(GO_JUNIT_REPORT) ## Build go-junit-report

tools: gocov gocov-xml go-junit-report ## Build bins for built tools
tools: gocov gocov-xml go-junit-report ## Build bins for build tools
19 changes: 19 additions & 0 deletions nodenetworkconfig/api/v1alpha/nodenetworkconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ import (
// +kubebuilder:resource:scope=Namespaced
// +kubebuilder:resource:shortName=nnc
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status`
// +kubebuilder:printcolumn:name="Requested IPs",type=string,JSONPath=`.spec.requestedIPCount`
// +kubebuilder:printcolumn:name="Assigned IPs",type=string,JSONPath=`.status.assignedIPCount`
// +kubebuilder:printcolumn:name="Subnet",type=string,JSONPath=`.status.networkContainers[*].subnetName`
// +kubebuilder:printcolumn:name="Subnet CIDR",type=string,JSONPath=`.status.networkContainers[*].subnetAddressSpace`
// +kubebuilder:printcolumn:name="NC ID",type=string,JSONPath=`.status.networkContainers[*].id`
// +kubebuilder:printcolumn:name="NC Version",type=string,JSONPath=`.status.networkContainers[*].version`
type NodeNetworkConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -53,7 +60,9 @@ type NodeNetworkConfigSpec struct {

// NodeNetworkConfigStatus defines the observed state of NetworkConfig
type NodeNetworkConfigStatus struct {
AssignedIPCount int `json:"assignedIPCount,omitempty"`
Scaler Scaler `json:"scaler,omitempty"`
Status Status `json:"status,omitempty"`
NetworkContainers []NetworkContainer `json:"networkContainers,omitempty"`
}

Expand All @@ -65,6 +74,16 @@ type Scaler struct {
MaxIPCount int64 `json:"maxIPCount,omitempty"`
}

// Status indicates the NNC reconcile status
// +kubebuilder:validation:Enum=Updating;Update;Error
type Status string

const (
Updating Status = "Updating"
Updated Status = "Updated"
Error Status = "Error"
)

// NetworkContainer defines the structure of a Network Container as found in NetworkConfigStatus
type NetworkContainer struct {
ID string `json:"id,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ metadata:
creationTimestamp: null
name: nodenetworkconfigs.acn.azure.com
spec:
additionalPrinterColumns:
- JSONPath: .status.status
name: Status
type: string
- JSONPath: .spec.requestedIPCount
name: Requested IPs
type: string
- JSONPath: .status.assignedIPCount
name: Assigned IPs
type: string
- JSONPath: .status.networkContainers[*].subnetName
name: Subnet
type: string
- JSONPath: .status.networkContainers[*].subnetAddressSpace
name: Subnet CIDR
type: string
- JSONPath: .status.networkContainers[*].id
name: NC ID
type: string
- JSONPath: .status.networkContainers[*].version
name: NC Version
type: string
group: acn.azure.com
names:
kind: NodeNetworkConfig
Expand Down Expand Up @@ -49,6 +71,8 @@ spec:
status:
description: NodeNetworkConfigStatus defines the observed state of NetworkConfig
properties:
assignedIPCount:
type: integer
networkContainers:
items:
description: NetworkContainer defines the structure of a Network Container
Expand Down Expand Up @@ -96,6 +120,13 @@ spec:
format: int64
type: integer
type: object
status:
description: Status indicates the NNC reconcile status
enum:
- Updating
- Update
- Error
type: string
type: object
type: object
version: v1alpha
Expand Down
31 changes: 31 additions & 0 deletions nodenetworkconfig/manifests/embed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package manifests

import (
_ "embed"

v1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
"sigs.k8s.io/yaml"
)

// NodeNetworkConfigsYAML embeds the CRD YAML for downstream consumers.
//go:embed acn.azure.com_nodenetworkconfigs.yaml
var NodeNetworkConfigsYAML []byte

// GetNodeNetworkConfigsDefinition parses the raw []byte NodeNetworkConfigs in
// to a CustomResourceDefinition and returns it or an unmarshalling error.
func GetNodeNetworkConfigs() (*v1beta1.CustomResourceDefinition, error) {
nodeNetworkConfigs := &v1beta1.CustomResourceDefinition{}
return nodeNetworkConfigs, yaml.Unmarshal(NodeNetworkConfigsYAML, &nodeNetworkConfigs)
}
32 changes: 32 additions & 0 deletions nodenetworkconfig/manifests/embed_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package manifests

import (
"os"
"reflect"
"testing"
)

const filename = "acn.azure.com_nodenetworkconfigs.yaml"

func TestEmbed(t *testing.T) {
b, err := os.ReadFile(filename)
if err != nil {
t.Error(err)
}

if !reflect.DeepEqual(NodeNetworkConfigsYAML, b) {
t.Errorf("embedded file did not match file on disk")
}
}