kubeproto

package module
v0.0.0-...-4c3e4f5 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2024 License: MIT Imports: 5 Imported by: 0

README

kubeproto

kubeproto is a plugin for Protocol Buffers to define k8s API.

The code generated by these plugins is incompatible with the code generated by code-generator.

Status: Stabilizing API

Synopsis

With Bazel

proto file

syntax = "proto3";
package example.apis.blogv1alpha1;
option go_package = "go.f110.dev/kubeproto/example/pkg/apis/blogv1alpha1";
option (dev.f110.kubeproto.k8s) = {
  domain: "f110.dev",
  sub_group: "blog",
  version: "v1alpha1",
};

import "kube.proto";

message Blog {
  BlogSpec   spec   = 1;
  BlogStatus status = 2;

  option (dev.f110.kubeproto.kind) = {
    scope: SCOPE_CLUSTER
  };
}

BUILD at pkg/apis/GROUP_AND_VERSION for generating deepcopy and register

load("@rules_proto//proto:defs.bzl", "proto_library")
load("//bazel:def.bzl", "kubeproto_go_api")

proto_library(
    name = "blog_proto",
    srcs = ["blog.proto"],
    deps = [
        "//:kubeproto",
    ],
    visibility = ["//visibility:public"],
)

kubeproto_go_api(
    name = "blog_proto_kubeproto",
    srcs = [":blog_proto"],
    importpath = "go.f110.dev/kubeproto/example/pkg/apis/blogv1alpha1",
)

BUILD file for generating the client

load("//bazel:def.bzl", "go_client")

go_client(
    name = "k8s",
    srcs = [
        "//example/pkg/apis/blogv1alpha1:blog_proto",
    ],
    importpath = "go.f110.dev/kubeproto/example/pkg/client",
    visibility = ["//visibility:public"],
)

BUILD file for generating for test

load("//bazel:def.bzl", "go_testing_client")

go_testing_client(
    name = "blog",
    srcs = [
        "//example/pkg/apis/blogv1alpha1:blog_proto",
    ],
    importpath = "go.f110.dev/kubeproto/example/pkg/client/testingclient",
    client = "//example/pkg/client:k8s",
    visibility = ["//visibility:public"],
)

BUILD file for generating CustomResourceDefinition

load("//bazel/crd:def.bzl", "crd_proto_manifest")

crd_proto_manifest(
    name = "crd",
    srcs = [
        "//example/pkg/apis/blogv1alpha1:blog_proto",
    ],
    visibility = ["//visibility:public"],
)

How to use generated client

cfg, err := rest.InClusterConfig()
if err != nil {
    return nil, err
}
apiClient, err := client.NewSet(cfg)
if err != nil {
    return nil, err
}

factory := client.NewInformerFactory(apiClient, client.NewInformerCache(), metav1.NamespaceAll, 30*time.Second)
blogInformers := client.NewBlogV1alpha1Informer(factory.Cache(), apiClient.BlogV1alpha1, metav1.NamespaceAll, 30*time.Second)
blogInformer := blogInformers.BlogInformer()
blogLister := blogInformers.BlogLister()

Why use the extension number for internal?

These plugins are intended to use my projects.

If you want to use these plugins in your project, I would consider registering with Global Extension Registry. Please feel free to file an issue!

Author

Fumihiro Ito

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Scope_name = map[int32]string{
		0: "SCOPE_NAMESPACED",
		1: "SCOPE_CLUSTER",
	}
	Scope_value = map[string]int32{
		"SCOPE_NAMESPACED": 0,
		"SCOPE_CLUSTER":    1,
	}
)

Enum value maps for Scope.

View Source
var (
	// optional dev.f110.kubeproto.Kubernetes k8s = 60010;
	E_K8S = &file_kube_proto_extTypes[2]
	// optional string kubeproto_go_package = 60011;
	E_KubeprotoGoPackage = &file_kube_proto_extTypes[3]
)

Extension fields to descriptorpb.FileOptions.

View Source
var (
	// optional dev.f110.kubeproto.Field field = 60010;
	E_Field = &file_kube_proto_extTypes[1]
)

Extension fields to descriptorpb.FieldOptions.

View Source
var (
	// optional dev.f110.kubeproto.Kind kind = 60010;
	E_Kind = &file_kube_proto_extTypes[0]
)

Extension fields to descriptorpb.MessageOptions.

View Source
var (
	// optional dev.f110.kubeproto.EnumValue value = 60010;
	E_Value = &file_kube_proto_extTypes[4]
)

Extension fields to descriptorpb.EnumValueOptions.

Functions

This section is empty.

Types

type EnumValue

type EnumValue struct {
	Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*EnumValue) Descriptor deprecated

func (*EnumValue) Descriptor() ([]byte, []int)

Deprecated: Use EnumValue.ProtoReflect.Descriptor instead.

func (*EnumValue) GetValue

func (x *EnumValue) GetValue() string

func (*EnumValue) ProtoMessage

func (*EnumValue) ProtoMessage()

func (*EnumValue) ProtoReflect

func (x *EnumValue) ProtoReflect() protoreflect.Message

func (*EnumValue) Reset

func (x *EnumValue) Reset()

func (*EnumValue) String

func (x *EnumValue) String() string

type Field

type Field struct {
	GoName       string `protobuf:"bytes,1,opt,name=go_name,json=goName,proto3" json:"go_name,omitempty"`
	Inline       bool   `protobuf:"varint,2,opt,name=inline,proto3" json:"inline,omitempty"`
	SubResource  bool   `protobuf:"varint,3,opt,name=sub_resource,json=subResource,proto3" json:"sub_resource,omitempty"`
	ApiFieldName string `protobuf:"bytes,4,opt,name=api_field_name,json=apiFieldName,proto3" json:"api_field_name,omitempty"`
	// contains filtered or unexported fields
}

func (*Field) Descriptor deprecated

func (*Field) Descriptor() ([]byte, []int)

Deprecated: Use Field.ProtoReflect.Descriptor instead.

func (*Field) GetApiFieldName

func (x *Field) GetApiFieldName() string

func (*Field) GetGoName

func (x *Field) GetGoName() string

func (*Field) GetInline

func (x *Field) GetInline() bool

func (*Field) GetSubResource

func (x *Field) GetSubResource() bool

func (*Field) ProtoMessage

func (*Field) ProtoMessage()

func (*Field) ProtoReflect

func (x *Field) ProtoReflect() protoreflect.Message

func (*Field) Reset

func (x *Field) Reset()

func (*Field) String

func (x *Field) String() string

type Kind

type Kind struct {
	AdditionalPrinterColumns []*PrinterColumn `` /* 135-byte string literal not displayed */
	Scope                    Scope            `protobuf:"varint,2,opt,name=scope,proto3,enum=dev.f110.kubeproto.Scope" json:"scope,omitempty"`
	// contains filtered or unexported fields
}

func (*Kind) Descriptor deprecated

func (*Kind) Descriptor() ([]byte, []int)

Deprecated: Use Kind.ProtoReflect.Descriptor instead.

func (*Kind) GetAdditionalPrinterColumns

func (x *Kind) GetAdditionalPrinterColumns() []*PrinterColumn

func (*Kind) GetScope

func (x *Kind) GetScope() Scope

func (*Kind) ProtoMessage

func (*Kind) ProtoMessage()

func (*Kind) ProtoReflect

func (x *Kind) ProtoReflect() protoreflect.Message

func (*Kind) Reset

func (x *Kind) Reset()

func (*Kind) String

func (x *Kind) String() string

type Kubernetes

type Kubernetes struct {
	Domain   string `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain,omitempty"`
	SubGroup string `protobuf:"bytes,2,opt,name=sub_group,json=subGroup,proto3" json:"sub_group,omitempty"`
	Version  string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"`
	Served   bool   `protobuf:"varint,4,opt,name=served,proto3" json:"served,omitempty"`
	Storage  bool   `protobuf:"varint,5,opt,name=storage,proto3" json:"storage,omitempty"`
	// contains filtered or unexported fields
}

func (*Kubernetes) Descriptor deprecated

func (*Kubernetes) Descriptor() ([]byte, []int)

Deprecated: Use Kubernetes.ProtoReflect.Descriptor instead.

func (*Kubernetes) GetDomain

func (x *Kubernetes) GetDomain() string

func (*Kubernetes) GetServed

func (x *Kubernetes) GetServed() bool

func (*Kubernetes) GetStorage

func (x *Kubernetes) GetStorage() bool

func (*Kubernetes) GetSubGroup

func (x *Kubernetes) GetSubGroup() string

func (*Kubernetes) GetVersion

func (x *Kubernetes) GetVersion() string

func (*Kubernetes) ProtoMessage

func (*Kubernetes) ProtoMessage()

func (*Kubernetes) ProtoReflect

func (x *Kubernetes) ProtoReflect() protoreflect.Message

func (*Kubernetes) Reset

func (x *Kubernetes) Reset()

func (*Kubernetes) String

func (x *Kubernetes) String() string

type PrinterColumn

type PrinterColumn struct {
	Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"`
	Name        string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	JsonPath    string `protobuf:"bytes,3,opt,name=json_path,json=jsonPath,proto3" json:"json_path,omitempty"`
	Priority    int32  `protobuf:"varint,4,opt,name=priority,proto3" json:"priority,omitempty"`
	Type        string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"`
	Format      string `protobuf:"bytes,6,opt,name=format,proto3" json:"format,omitempty"`
	// contains filtered or unexported fields
}

func (*PrinterColumn) Descriptor deprecated

func (*PrinterColumn) Descriptor() ([]byte, []int)

Deprecated: Use PrinterColumn.ProtoReflect.Descriptor instead.

func (*PrinterColumn) GetDescription

func (x *PrinterColumn) GetDescription() string

func (*PrinterColumn) GetFormat

func (x *PrinterColumn) GetFormat() string

func (*PrinterColumn) GetJsonPath

func (x *PrinterColumn) GetJsonPath() string

func (*PrinterColumn) GetName

func (x *PrinterColumn) GetName() string

func (*PrinterColumn) GetPriority

func (x *PrinterColumn) GetPriority() int32

func (*PrinterColumn) GetType

func (x *PrinterColumn) GetType() string

func (*PrinterColumn) ProtoMessage

func (*PrinterColumn) ProtoMessage()

func (*PrinterColumn) ProtoReflect

func (x *PrinterColumn) ProtoReflect() protoreflect.Message

func (*PrinterColumn) Reset

func (x *PrinterColumn) Reset()

func (*PrinterColumn) String

func (x *PrinterColumn) String() string

type Scope

type Scope int32
const (
	Scope_SCOPE_NAMESPACED Scope = 0
	Scope_SCOPE_CLUSTER    Scope = 1
)

func (Scope) Descriptor

func (Scope) Descriptor() protoreflect.EnumDescriptor

func (Scope) Enum

func (x Scope) Enum() *Scope

func (Scope) EnumDescriptor deprecated

func (Scope) EnumDescriptor() ([]byte, []int)

Deprecated: Use Scope.Descriptor instead.

func (Scope) Number

func (x Scope) Number() protoreflect.EnumNumber

func (Scope) String

func (x Scope) String() string

func (Scope) Type

func (Scope) Type() protoreflect.EnumType

Jump to

Keyboard shortcuts

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