Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SupportedConversionReviewVersions = []string{"v1", "v1beta1"}
Functions ¶
func ExtractAPIVersions ¶
func ExtractAPIVersions(objs []runtime.RawExtension) []string
func VersionsMatched ¶
VersionsMatched when: - ver0 equals to ver1 - ver0 is short and ver1 is full and short ver1 is equals to ver0 - ver0 is full and ver1 is short and short ver0 is equals to ver1 Note that ver0 and ver1 with different groups are not matched (e.g. stable/v1 and unstable/v1)
Types ¶
type Chain ¶
type Chain struct {
// A cache of calculated paths. A key is an arbitrary path and value is a sequence of base paths.
PathsCache map[Rule][]Rule
// An index to search for base paths by given From and To.
BaseFromToIndex map[string]map[string]struct{}
}
func (Chain) HasTargetVersion ¶
HasTargetVersion returns true if there is a base path leading to an input version.
func (Chain) NextRules ¶
NextRules finds all base paths in BaseFromToIndex that starts from an input version.
func (Chain) RulesWithSimilarFromVersion ¶
RulesWithFromVersion returns all rules in PathsCache that has similar FromVersion as the input rule.
func (Chain) SearchPathForRule ¶
SearchPathForRule returns an array of base paths for an arbitrary rule.
type ChainStorage ¶
func NewChainStorage ¶
func NewChainStorage() *ChainStorage
func (ChainStorage) FindConversionChain ¶
func (cs ChainStorage) FindConversionChain(crdName string, rule Rule) []Rule
Calculations FindConversionChain returns an array of ConverionsRules that should be
func (ChainStorage) Get ¶
func (cs ChainStorage) Get(crdName string) *Chain
Access a Chain by CRD full name (e.g. crontab.stable.example.com)
type CrdClientConfig ¶
type CrdClientConfig struct {
KubeClient *klient.Client
CrdName string
Namespace string
ServiceName string
Path string
CABundle []byte
}
A clientConfig for a particular CRD.
type EventHandlerFn ¶
type Response ¶
type Response struct {
FailedMessage string `json:"failedMessage"`
ConvertedObjects []runtime.RawExtension `json:"convertedObjects,omitempty"`
}
Response is a holder of the conversion hook response.
Unlike ConverionsResponse, only one filed (FailedMessage) is used to determine success or fail:
Response is Success if FailedMessage is empty:
"result": {
"status": "Success"
},
Response is Failed:
"result": {
"status": "Failed",
"message": FailedMessage
}
ConvertedObjects: # Objects must match the order of request.objects, and have apiVersion set to <request.desiredAPIVersion>. # kind, metadata.uid, metadata.name, and metadata.namespace fields must not be changed by the webhook. # metadata.labels and metadata.annotations fields may be changed by the webhook. # All other changes to metadata fields by the webhook are ignored.
func ResponseFromBytes ¶
func ResponseFromFile ¶
type WebhookConfig ¶
type WebhookConfig struct {
Rules []Rule
CrdName string // This name is used as a suffix to create different URLs for clientConfig in CRD.
Metadata struct {
Name string
DebugName string
LogLabels map[string]string
MetricLabels map[string]string
}
}
WebhookConfig
type WebhookHandler ¶
type WebhookHandler struct {
Manager *WebhookManager
Router chi.Router
}
func NewWebhookHandler ¶
func NewWebhookHandler() *WebhookHandler
type WebhookManager ¶
type WebhookManager struct {
KubeClient *klient.Client
EventHandlerFn EventHandlerFn
Settings *WebhookSettings
Namespace string
Server *server.WebhookServer
ClientConfigs map[string]*CrdClientConfig
Handler *WebhookHandler
}
WebhookManager is a public interface to be used from operator.go.
No dynamic configuration for now. The steps are: - Init():
- Create a router to distinguish conversion requests between CRDs
- Create a handler to handle ConversionReview
- Create a server that listens for Kubernetes requests
- Call AddWebhook() to register a CRD name in conversion bindings in hooks
- Start():
- Start server loop.
- Update clientConfig in each registered CRD.
func NewWebhookManager ¶
func NewWebhookManager() *WebhookManager
func (*WebhookManager) AddWebhook ¶
func (m *WebhookManager) AddWebhook(webhook *WebhookConfig)
func (*WebhookManager) Start ¶
func (m *WebhookManager) Start() error
Start webhook server and update spec.conversion in CRDs.