Skip to content

Commit

Permalink
cmd: provision then cleanup a persistent allocation
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Duarte Barroso <[email protected]>
  • Loading branch information
maiqueb committed Aug 30, 2023
1 parent 2b3e076 commit 86750e0
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions cmd/example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"flag"
"fmt"
"github.com/maiqueb/persistentips/pkg/crd/persistentip/v1alpha1"

"github.com/golang/glog"

Expand Down Expand Up @@ -31,6 +32,36 @@ func main() {
glog.Fatalf("Error building example clientset: %v", err)
}

// create a persistent IP allocation
pip := &v1alpha1.PersistentIPAMAllocation{
ObjectMeta: metav1.ObjectMeta{
Name: "example",
},
Spec: v1alpha1.PersistentIPAMAllocationSpec{
Network: "tenantblue",
Interface: "iface321",
IPs: []string{"a", "pony", "bit", "my", "bollocks"},
},
}

_, err = exampleClient.CniV1alpha1().PersistentIPAMAllocations("default").Create(
context.Background(),
pip,
metav1.CreateOptions{},
)
if err != nil {
glog.Fatalf("Error creating a dummy persistentIP object: %v", err)
}

defer func() {
// teardown persistent IP
_ = exampleClient.CniV1alpha1().PersistentIPAMAllocations("default").Delete(
context.Background(),
pip.Name,
metav1.DeleteOptions{},
)
}()

allPersistentIPs, err := exampleClient.CniV1alpha1().PersistentIPAMAllocations(metav1.NamespaceAll).List(
context.Background(),
metav1.ListOptions{},
Expand Down

0 comments on commit 86750e0

Please sign in to comment.