Initial v1.0.0 commit

This commit is contained in:
Jakub Vavřík
2021-01-28 17:37:47 +01:00
commit 1481d27782
4164 changed files with 1264675 additions and 0 deletions

5
pkg/apis/config/doc.go Normal file
View File

@@ -0,0 +1,5 @@
// +k8s:deepcopy-gen=package
// +groupName="shoot-fleet-agent-service.extensions.config.gardener.cloud"
//go:generate ../../../hack/update-codegen.sh
package config

View File

@@ -0,0 +1,31 @@
package install
import (
"github.com/javamachr/gardener-extension-shoot-fleet-agent/pkg/apis/config"
v1alpha1 "github.com/javamachr/gardener-extension-shoot-fleet-agent/pkg/apis/config/v1alpha1"
v1alpha1fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
)
var (
schemeBuilder = runtime.NewSchemeBuilder(
v1alpha1.AddToScheme,
v1alpha1fleet.AddToScheme,
config.AddToScheme,
setVersionPriority,
)
// AddToScheme adds all APIs to the scheme.
AddToScheme = schemeBuilder.AddToScheme
)
func setVersionPriority(scheme *runtime.Scheme) error {
return scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion)
}
// Install installs all APIs in the scheme.
func Install(scheme *runtime.Scheme) {
utilruntime.Must(AddToScheme(scheme))
}

View File

@@ -0,0 +1,58 @@
package loader
import (
"io/ioutil"
"github.com/javamachr/gardener-extension-shoot-fleet-agent/pkg/apis/config"
"github.com/javamachr/gardener-extension-shoot-fleet-agent/pkg/apis/config/install"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer/json"
"k8s.io/apimachinery/pkg/runtime/serializer/versioning"
)
var (
Codec runtime.Codec
Scheme *runtime.Scheme
)
func init() {
Scheme = runtime.NewScheme()
install.Install(Scheme)
yamlSerializer := json.NewYAMLSerializer(json.DefaultMetaFactory, Scheme, Scheme)
Codec = versioning.NewDefaultingCodecForScheme(
Scheme,
yamlSerializer,
yamlSerializer,
schema.GroupVersion{Version: "v1alpha1"},
runtime.InternalGroupVersioner,
)
}
// LoadFromFile takes a filename and de-serializes the contents into FleetAgentConfig object.
func LoadFromFile(filename string) (*config.FleetAgentConfig, error) {
bytes, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
return Load(bytes)
}
// Load takes a byte slice and de-serializes the contents into FleetAgentConfig object.
// Encapsulates de-serialization without assuming the source is a file.
func Load(data []byte) (*config.FleetAgentConfig, error) {
cfg := &config.FleetAgentConfig{}
if len(data) == 0 {
return cfg, nil
}
decoded, _, err := Codec.Decode(data, &schema.GroupVersionKind{Version: "v1alpha1", Kind: "Config"}, cfg)
if err != nil {
return nil, err
}
return decoded.(*config.FleetAgentConfig), nil
}

View File

@@ -0,0 +1,37 @@
package config
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// GroupName is the group name use in this package
const GroupName = "shoot-fleet-agent-service.extensions.config.gardener.cloud"
// 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 used to register the Shoot resource.
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
// AddToScheme is a pointer to schemeBuilder.AddToScheme.
AddToScheme = schemeBuilder.AddToScheme
)
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&FleetAgentConfig{},
)
return nil
}

26
pkg/apis/config/types.go Normal file
View File

@@ -0,0 +1,26 @@
package config
import (
healthcheckconfig "github.com/gardener/gardener/extensions/pkg/controller/healthcheck/config"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
componentbaseconfig "k8s.io/component-base/config"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// FleetAgentConfig configuration resource
type FleetAgentConfig struct {
metav1.TypeMeta
// ClientConnection specifies the kubeconfig file and client connection
// settings for the proxy server to use when communicating with the apiserver.
ClientConnection *componentbaseconfig.ClientConnectionConfiguration
// labels to use in Fleet Cluster registration
Labels map[string]string
//namespace to store clusters registrations in Fleet managers cluster
Namespace string
HealthCheckConfig *healthcheckconfig.HealthCheckConfig
}

View File

@@ -0,0 +1,9 @@
package v1alpha1
import (
"k8s.io/apimachinery/pkg/runtime"
)
func addDefaultingFuncs(scheme *runtime.Scheme) error {
return RegisterDefaults(scheme)
}

View File

@@ -0,0 +1,10 @@
// +k8s:deepcopy-gen=package
// +k8s:conversion-gen=github.com/javamachr/gardener-extension-shoot-fleet-agent/pkg/apis/config
// +k8s:openapi-gen=true
// +k8s:defaulter-gen=TypeMeta
//go:generate gen-crd-api-reference-docs -api-dir . -config ../../../../hack/api-reference/config.json -template-dir ../../../../vendor/github.com/gardener/gardener/hack/api-reference/template -out-file ../../../../hack/api-reference/config.md
// Package v1alpha1 contains the Azure provider configuration API resources.
// +groupName=shoot-fleet-agent-service.extensions.config.gardener.cloud
package v1alpha1

View File

@@ -0,0 +1,40 @@
package v1alpha1
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// GroupName is the group name use in this package
const GroupName = "shoot-fleet-agent-service.extensions.config.gardener.cloud"
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
// SchemeBuilder used to register the Shoot resource.
SchemeBuilder runtime.SchemeBuilder
localSchemeBuilder = &SchemeBuilder
// AddToScheme is a pointer to SchemeBuilder.AddToScheme.
AddToScheme = localSchemeBuilder.AddToScheme
)
func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addDefaultingFuncs, addKnownTypes)
}
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&FleetAgentConfig{},
)
return nil
}

View File

@@ -0,0 +1,28 @@
package v1alpha1
import (
healthcheckconfig "github.com/gardener/gardener/extensions/pkg/controller/healthcheck/config"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
componentbaseconfigv1alpha1 "k8s.io/component-base/config/v1alpha1"
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// FleetAgentConfig configuration resource
type FleetAgentConfig struct {
metav1.TypeMeta `json:",inline"`
// ClientConnection specifies the kubeconfig file and client connection
// settings for the proxy server to use when communicating with the apiserver.
// +optional
ClientConnection *componentbaseconfigv1alpha1.ClientConnectionConfiguration `json:"clientConnection,omitempty"`
// labels to use in Fleet Cluster registration
Labels map[string]string `json:"labels,omitempty"`
//namespace to store clusters registrations in Fleet managers cluster
Namespace string `json:"namespace,omitempty"`
HealthCheckConfig *healthcheckconfig.HealthCheckConfig `json:"healthCheckConfig,omitempty"`
}

View File

@@ -0,0 +1,78 @@
// +build !ignore_autogenerated
/*
Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
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.
*/
// Code generated by conversion-gen. DO NOT EDIT.
package v1alpha1
import (
unsafe "unsafe"
healthcheckconfig "github.com/gardener/gardener/extensions/pkg/controller/healthcheck/config"
config "github.com/javamachr/gardener-extension-shoot-fleet-agent/pkg/apis/config"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
componentbaseconfig "k8s.io/component-base/config"
configv1alpha1 "k8s.io/component-base/config/v1alpha1"
)
func init() {
localSchemeBuilder.Register(RegisterConversions)
}
// RegisterConversions adds conversion functions to the given scheme.
// Public to allow building arbitrary schemes.
func RegisterConversions(s *runtime.Scheme) error {
if err := s.AddGeneratedConversionFunc((*FleetAgentConfig)(nil), (*config.FleetAgentConfig)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha1_FleetAgentConfig_To_config_FleetAgentConfig(a.(*FleetAgentConfig), b.(*config.FleetAgentConfig), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*config.FleetAgentConfig)(nil), (*FleetAgentConfig)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_config_FleetAgentConfig_To_v1alpha1_FleetAgentConfig(a.(*config.FleetAgentConfig), b.(*FleetAgentConfig), scope)
}); err != nil {
return err
}
return nil
}
func autoConvert_v1alpha1_FleetAgentConfig_To_config_FleetAgentConfig(in *FleetAgentConfig, out *config.FleetAgentConfig, s conversion.Scope) error {
out.ClientConnection = (*componentbaseconfig.ClientConnectionConfiguration)(unsafe.Pointer(in.ClientConnection))
out.Labels = *(*map[string]string)(unsafe.Pointer(&in.Labels))
out.Namespace = in.Namespace
out.HealthCheckConfig = (*healthcheckconfig.HealthCheckConfig)(unsafe.Pointer(in.HealthCheckConfig))
return nil
}
// Convert_v1alpha1_FleetAgentConfig_To_config_FleetAgentConfig is an autogenerated conversion function.
func Convert_v1alpha1_FleetAgentConfig_To_config_FleetAgentConfig(in *FleetAgentConfig, out *config.FleetAgentConfig, s conversion.Scope) error {
return autoConvert_v1alpha1_FleetAgentConfig_To_config_FleetAgentConfig(in, out, s)
}
func autoConvert_config_FleetAgentConfig_To_v1alpha1_FleetAgentConfig(in *config.FleetAgentConfig, out *FleetAgentConfig, s conversion.Scope) error {
out.ClientConnection = (*configv1alpha1.ClientConnectionConfiguration)(unsafe.Pointer(in.ClientConnection))
out.Labels = *(*map[string]string)(unsafe.Pointer(&in.Labels))
out.Namespace = in.Namespace
out.HealthCheckConfig = (*healthcheckconfig.HealthCheckConfig)(unsafe.Pointer(in.HealthCheckConfig))
return nil
}
// Convert_config_FleetAgentConfig_To_v1alpha1_FleetAgentConfig is an autogenerated conversion function.
func Convert_config_FleetAgentConfig_To_v1alpha1_FleetAgentConfig(in *config.FleetAgentConfig, out *FleetAgentConfig, s conversion.Scope) error {
return autoConvert_config_FleetAgentConfig_To_v1alpha1_FleetAgentConfig(in, out, s)
}

View File

@@ -0,0 +1,69 @@
// +build !ignore_autogenerated
/*
Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
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.
*/
// Code generated by deepcopy-gen. DO NOT EDIT.
package v1alpha1
import (
config "github.com/gardener/gardener/extensions/pkg/controller/healthcheck/config"
runtime "k8s.io/apimachinery/pkg/runtime"
configv1alpha1 "k8s.io/component-base/config/v1alpha1"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FleetAgentConfig) DeepCopyInto(out *FleetAgentConfig) {
*out = *in
out.TypeMeta = in.TypeMeta
if in.ClientConnection != nil {
in, out := &in.ClientConnection, &out.ClientConnection
*out = new(configv1alpha1.ClientConnectionConfiguration)
**out = **in
}
if in.Labels != nil {
in, out := &in.Labels, &out.Labels
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
if in.HealthCheckConfig != nil {
in, out := &in.HealthCheckConfig, &out.HealthCheckConfig
*out = new(config.HealthCheckConfig)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAgentConfig.
func (in *FleetAgentConfig) DeepCopy() *FleetAgentConfig {
if in == nil {
return nil
}
out := new(FleetAgentConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *FleetAgentConfig) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}

View File

@@ -0,0 +1,32 @@
// +build !ignore_autogenerated
/*
Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
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.
*/
// Code generated by defaulter-gen. DO NOT EDIT.
package v1alpha1
import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// RegisterDefaults adds defaulters functions to the given scheme.
// Public to allow building arbitrary schemes.
// All generated defaulters are covering - they call all nested defaulters.
func RegisterDefaults(scheme *runtime.Scheme) error {
return nil
}

View File

@@ -0,0 +1,69 @@
// +build !ignore_autogenerated
/*
Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
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.
*/
// Code generated by deepcopy-gen. DO NOT EDIT.
package config
import (
healthcheckconfig "github.com/gardener/gardener/extensions/pkg/controller/healthcheck/config"
runtime "k8s.io/apimachinery/pkg/runtime"
componentbaseconfig "k8s.io/component-base/config"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FleetAgentConfig) DeepCopyInto(out *FleetAgentConfig) {
*out = *in
out.TypeMeta = in.TypeMeta
if in.ClientConnection != nil {
in, out := &in.ClientConnection, &out.ClientConnection
*out = new(componentbaseconfig.ClientConnectionConfiguration)
**out = **in
}
if in.Labels != nil {
in, out := &in.Labels, &out.Labels
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
if in.HealthCheckConfig != nil {
in, out := &in.HealthCheckConfig, &out.HealthCheckConfig
*out = new(healthcheckconfig.HealthCheckConfig)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAgentConfig.
func (in *FleetAgentConfig) DeepCopy() *FleetAgentConfig {
if in == nil {
return nil
}
out := new(FleetAgentConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *FleetAgentConfig) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}