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

subresource #1

Merged
merged 5 commits into from
Jul 25, 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
2 changes: 1 addition & 1 deletion api-aggregation-lib/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
k8s.io/client-go v0.27.3
k8s.io/component-base v0.27.3
k8s.io/klog/v2 v2.100.1
sigs.k8s.io/structured-merge-diff/v4 v4.2.3
)

require (
Expand Down Expand Up @@ -99,7 +100,6 @@ require (
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

Expand Down
1 change: 1 addition & 0 deletions api-aggregation-lib/pkg/api/hello.zeng.dev/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&Foo{},
&FooList{},
&Config{},
)
return nil
}
18 changes: 18 additions & 0 deletions api-aggregation-lib/pkg/api/hello.zeng.dev/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,21 @@ type FooList struct {

Items []Foo
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// Config is the config subresource of Foo
type Config struct {
metav1.TypeMeta
metav1.ObjectMeta

Spec ConfigSpec
}

type ConfigSpec struct {
// Msg says hello world!
Msg string
// Msg1 provides some verbose information
// +optional
Msg1 string
}

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

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

6 changes: 6 additions & 0 deletions api-aggregation-lib/pkg/api/transformation/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**/

// +k8s:deepcopy-gen=package
// +groupName=transformation.zeng.dev

package transformation
16 changes: 16 additions & 0 deletions api-aggregation-lib/pkg/api/transformation/install/install.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package install

import (
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"

transformation "github.com/phosae/x-kubernetes/api-aggregation-lib/pkg/api/transformation"
transformationv1beta1 "github.com/phosae/x-kubernetes/api-aggregation-lib/pkg/api/transformation/v1beta1"
)

// Install registers the API group and adds types to a scheme
func Install(scheme *runtime.Scheme) {
utilruntime.Must(transformationv1beta1.AddToScheme(scheme))
utilruntime.Must(transformation.AddToScheme(scheme))
utilruntime.Must(scheme.SetVersionPriority(transformationv1beta1.SchemeGroupVersion))
}
36 changes: 36 additions & 0 deletions api-aggregation-lib/pkg/api/transformation/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package transformation

import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// GroupName is the group name use in this package
const GroupName = "transformation.zeng.dev"

// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}

// Kind takes an unqualified kind and returns a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

var (
// SchemeBuilder points to a list of functions added to Scheme.
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
// AddToScheme applies all the stored functions to the scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&Base64{},
)
return nil
}
28 changes: 28 additions & 0 deletions api-aggregation-lib/pkg/api/transformation/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package transformation

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// Base64 generates a base64 encoding for a specified Kubernetes object.
type Base64 struct {
metav1.TypeMeta
metav1.ObjectMeta

Spec Base64Spec
Status Base64Status
}

type Base64Spec struct {
// Path of the field to select in the specified object.
// defaults to . for the entire object
FieldPath string
}

type Base64Status struct {
// Output is the base64-encoded representation of
// the specified Kubernetes object or its subfield, as defined by the fieldPath.
Output string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package v1beta1

func init() {
localSchemeBuilder.Register(RegisterDefaults)
}
9 changes: 9 additions & 0 deletions api-aggregation-lib/pkg/api/transformation/v1beta1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**/

// +k8s:conversion-gen=github.com/phosae/x-kubernetes/api-aggregation-lib/pkg/api/transformation
// +k8s:conversion-gen-external-types=github.com/phosae/x-kubernetes/api/transformation/v1beta1
// +groupName=transformation.zeng.dev
// +k8s:defaulter-gen=TypeMeta
// +k8s:defaulter-gen-input=github.com/phosae/x-kubernetes/api/transformation/v1beta1

package v1beta1
22 changes: 22 additions & 0 deletions api-aggregation-lib/pkg/api/transformation/v1beta1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package v1beta1

import (
transformationv1beta1 "github.com/phosae/x-kubernetes/api/transformation/v1beta1"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// GroupName is the group name use in this package
const GroupName = "transformation.zeng.dev"

// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

var (
localSchemeBuilder = &transformationv1beta1.SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)
Loading