-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Aleksandr Zimin <[email protected]>
- Loading branch information
1 parent
d330ae4
commit b0be3c5
Showing
6 changed files
with
336 additions
and
4 deletions.
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
images/sds-health-watcher-controller/src/api/module_config.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
Copyright 2023 Flant JSC | ||
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. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
var ( | ||
// ModuleConfigGVR GroupVersionResource | ||
ModuleConfigGVR = schema.GroupVersionResource{ | ||
Group: SchemeGroupVersion.Group, | ||
Version: SchemeGroupVersion.Version, | ||
Resource: "moduleconfigs", | ||
} | ||
ModuleConfigGVK = schema.GroupVersionKind{ | ||
Group: SchemeGroupVersion.Group, | ||
Version: SchemeGroupVersion.Version, | ||
Kind: "ModuleConfig", | ||
} | ||
) | ||
|
||
var _ runtime.Object = (*ModuleConfig)(nil) | ||
|
||
// +genclient | ||
// +genclient:nonNamespaced | ||
// +k8s:deepcopy-gen=true | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// ModuleConfig is a configuration for module or for global config values. | ||
type ModuleConfig struct { | ||
metav1.TypeMeta `json:",inline"` | ||
// Standard object's metadata. | ||
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata | ||
// +optional | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec ModuleConfigSpec `json:"spec"` | ||
|
||
Status ModuleConfigStatus `json:"status,omitempty"` | ||
} | ||
|
||
// SettingsValues empty interface in needed to handle DeepCopy generation. DeepCopy does not work with unnamed empty interfaces | ||
type SettingsValues map[string]interface{} | ||
|
||
func (v *SettingsValues) DeepCopy() *SettingsValues { | ||
nmap := make(map[string]interface{}, len(*v)) | ||
|
||
for key, value := range *v { | ||
nmap[key] = value | ||
} | ||
|
||
vv := SettingsValues(nmap) | ||
|
||
return &vv | ||
} | ||
|
||
func (v SettingsValues) DeepCopyInto(out *SettingsValues) { | ||
{ | ||
v := &v | ||
clone := v.DeepCopy() | ||
*out = *clone | ||
return | ||
} | ||
} | ||
|
||
type ModuleConfigSpec struct { | ||
Version int `json:"version,omitempty"` | ||
Settings SettingsValues `json:"settings,omitempty"` | ||
Enabled *bool `json:"enabled,omitempty"` | ||
} | ||
|
||
type ModuleConfigStatus struct { | ||
Version string `json:"version"` | ||
Message string `json:"message"` | ||
} | ||
|
||
// +k8s:deepcopy-gen=true | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// ModuleConfigList is a list of ModuleConfig resources | ||
type ModuleConfigList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata"` | ||
|
||
Items []ModuleConfig `json:"items"` | ||
} | ||
|
||
type moduleConfigKind struct{} | ||
|
||
func (in *ModuleConfigStatus) GetObjectKind() schema.ObjectKind { | ||
return &moduleConfigKind{} | ||
} | ||
|
||
func (f *moduleConfigKind) SetGroupVersionKind(_ schema.GroupVersionKind) {} | ||
func (f *moduleConfigKind) GroupVersionKind() schema.GroupVersionKind { | ||
return ModuleConfigGVK | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2021 Flant JSC | ||
// | ||
// 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. | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
// SchemeGroupVersion is group version used to register these objects | ||
var SchemeGroupVersion = schema.GroupVersion{Group: "deckhouse.io", 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 ( | ||
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. | ||
SchemeBuilder runtime.SchemeBuilder | ||
localSchemeBuilder = &SchemeBuilder | ||
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(addKnownTypes) | ||
} | ||
|
||
// Adds the list of known types to api.Scheme. | ||
func addKnownTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypes(SchemeGroupVersion, | ||
&ModuleConfig{}, | ||
&ModuleConfigList{}, | ||
) | ||
|
||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion) | ||
return nil | ||
} |
125 changes: 125 additions & 0 deletions
125
images/sds-health-watcher-controller/src/api/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
images/sds-health-watcher-controller/src/api/zz_generated.defaults.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters