sigs.k8s.io/kubebuilder/v3@v3.14.0/pkg/config/interface.go (about) 1 /* 2 Copyright 2022 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package config 18 19 import ( 20 "sigs.k8s.io/kubebuilder/v3/pkg/model/resource" 21 ) 22 23 // Config defines the interface that project configuration types must follow. 24 type Config interface { 25 /* Version */ 26 27 // GetVersion returns the current project version. 28 GetVersion() Version 29 30 /* String fields */ 31 32 // GetDomain returns the project domain. 33 GetDomain() string 34 // SetDomain sets the project domain. 35 SetDomain(domain string) error 36 37 // GetRepository returns the project repository. 38 GetRepository() string 39 // SetRepository sets the project repository. 40 SetRepository(repository string) error 41 42 // GetProjectName returns the project name. 43 // This method was introduced in project version 3. 44 GetProjectName() string 45 // SetProjectName sets the project name. 46 // This method was introduced in project version 3. 47 SetProjectName(name string) error 48 49 // GetPluginChain returns the plugin chain. 50 // This method was introduced in project version 3. 51 GetPluginChain() []string 52 // SetPluginChain sets the plugin chain. 53 // This method was introduced in project version 3. 54 SetPluginChain(pluginChain []string) error 55 56 /* Boolean fields */ 57 58 // IsMultiGroup checks if multi-group is enabled. 59 IsMultiGroup() bool 60 // SetMultiGroup enables multi-group. 61 SetMultiGroup() error 62 // ClearMultiGroup disables multi-group. 63 ClearMultiGroup() error 64 65 // IsComponentConfig checks if component config is enabled. 66 // This method was introduced in project version 3. 67 IsComponentConfig() bool 68 // SetComponentConfig enables component config. 69 // This method was introduced in project version 3. 70 SetComponentConfig() error 71 // ClearComponentConfig disables component config. 72 // This method was introduced in project version 3. 73 ClearComponentConfig() error 74 75 /* Resources */ 76 77 // ResourcesLength returns the number of tracked resources. 78 ResourcesLength() int 79 // HasResource checks if the provided GVK is stored in the Config. 80 HasResource(gvk resource.GVK) bool 81 // GetResource returns the stored resource matching the provided GVK. 82 GetResource(gvk resource.GVK) (resource.Resource, error) 83 // GetResources returns all the stored resources. 84 GetResources() ([]resource.Resource, error) 85 // AddResource adds the provided resource if it was not present, no-op if it was already present. 86 AddResource(res resource.Resource) error 87 // UpdateResource adds the provided resource if it was not present, modifies it if it was already present. 88 UpdateResource(res resource.Resource) error 89 90 // HasGroup checks if the provided group is the same as any of the tracked resources. 91 HasGroup(group string) bool 92 // ListCRDVersions returns a list of the CRD versions in use by the tracked resources. 93 ListCRDVersions() []string 94 // ListWebhookVersions returns a list of the webhook versions in use by the tracked resources. 95 ListWebhookVersions() []string 96 97 /* Plugins */ 98 99 // DecodePluginConfig decodes a plugin config stored in Config into configObj, which must be a pointer. 100 // This method is intended to be used for custom configuration objects, which were introduced in project version 3. 101 DecodePluginConfig(key string, configObj interface{}) error 102 // EncodePluginConfig encodes a config object into Config by overwriting the existing object stored under key. 103 // This method is intended to be used for custom configuration objects, which were introduced in project version 3. 104 EncodePluginConfig(key string, configObj interface{}) error 105 106 /* Persistence */ 107 108 // Marshal returns the YAML representation of the Config. 109 MarshalYAML() ([]byte, error) 110 // Unmarshal loads the Config fields from its YAML representation. 111 UnmarshalYAML([]byte) error 112 }