rgclient

package module
v0.28.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

routegroup-client

client-go implementation of routegroup.

There is example code in ./cli/rg-client-test to show how to use it. If you want to build the example you can run make, which will do code generation and build this example client application, that you can run from build/ directory with ./build/rg-example. You can use kubectl proxy to run the example against the local API endpoint.

Unified Client does composition to have one client for all Kubernetes API access. In case you want to do composition yourself you can use the Zalando Client.

Unified Client

A unified client has all the functions from kubernetes.Interface and the ZalandoV1() available in one client-go client.

Sample code:

import (
	"context"
	"log"

	rgclient "github.com/szuecs/routegroup-client"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func main() {
	cli, err := rgclient.CreateUnified()
	if err != nil {
		log.Fatalf("Failed to create unified RouteGroup client: %v", err)
	}

	// example kubernetes.Interface access with unified client
	ings, err := cli.ExtensionsV1beta1().Ingresses("").List(context.TODO(), metav1.ListOptions{})
	for _, ing := range ings.Items {
		log.Printf("ing Namespace/Name: %s/%s", ing.Namespace, ing.Name)
	}

	// example RouteGroups access with unified client
	l, err := cli.ZalandoV1().RouteGroups("").List(context.TODO(), metav1.ListOptions{})
	if err != nil {
		log.Fatalf("Failed to get RouteGroup list: %v", err)
	}

	for _, rg := range l.Items {
		log.Printf("rg Namespace/Name: %s/%s", rg.Namespace, rg.Name)
	}

Zalando Client

Zalando client has access to ZalandoV1(), but does not have access to kubernetes.Interface, such that you can't list Ingress for example with it.

Sample code:

import (
	"context"
	"log"

	rgclient "github.com/szuecs/routegroup-client"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func main() {
	zcli, err := rgclient.Create()
	if err != nil {
		log.Fatalf("Failed to create RouteGroup client: %v", err)
	}

	ls, err := zcli.ZalandoV1().RouteGroups("").List(context.TODO(), metav1.ListOptions{})
	if err != nil {
		log.Fatalf("Failed to list routegroups: %v", err)
	}

	for _, rg := range l.Items {
		log.Printf("rg Namespace/Name: %s/%s", rg.Namespace, rg.Name)
	}

Documentation

Overview

Package rgclient implements client-go style API client to access RouteGroups and Kubernetes resources.

Index

Constants

View Source
const (
	LocalAPIServer = "http://127.0.0.1:8001"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Clientset

type Clientset struct {
	*kubernetes.Clientset
	// contains filtered or unexported fields
}

Clientset is the unified client implementation

func NewClientset

func NewClientset(config *rest.Config) (*Clientset, error)

NewClientset returns the unified client, but users should in general prefer rgclient.CreateUnified().

func (*Clientset) ZalandoV1

func (cs *Clientset) ZalandoV1() zalandov1.ZalandoV1Interface

ZalandoV1 implements ZalandoInterface

type Interface

type Interface interface {
	kubernetes.Interface
	ZalandoInterface
}

Interface is the unified interface for Kubernetes and Zalando RouteGroup access

func CreateUnified

func CreateUnified() (Interface, error)

CreateUnified returns the unified client

type ZalandoInterface

type ZalandoInterface interface {
	ZalandoV1() zalandov1.ZalandoV1Interface
}

ZalandoInterface to access RouteGroups

func Create

func Create() (ZalandoInterface, error)

Create returns the Zalandointerface client

Directories

Path Synopsis
apis
zalando.org/v1
Package v1 contains API Schema definitions for the zalando v1 API group +kubebuilder:object:generate=true +groupName=zalando.org
Package v1 contains API Schema definitions for the zalando v1 API group +kubebuilder:object:generate=true +groupName=zalando.org
cli
client
clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
clientset/versioned/typed/zalando.org/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
clientset/versioned/typed/zalando.org/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL