|
|
|
|
@ -186,32 +186,34 @@ func (i *Install) installCRDs(crds []chart.CRD) error {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If we have already gathered the capabilities, we need to invalidate
|
|
|
|
|
// the cache so that the new CRDs are recognized. This should only be
|
|
|
|
|
// the case when an action configuration is reused for multiple actions,
|
|
|
|
|
// as otherwise it is later loaded by ourselves when getCapabilities
|
|
|
|
|
// is called later on in the installation process.
|
|
|
|
|
if i.cfg.Capabilities != nil {
|
|
|
|
|
discoveryClient, err := i.cfg.RESTClientGetter.ToDiscoveryClient()
|
|
|
|
|
if i.cfg.RESTClientGetter != nil {
|
|
|
|
|
// If we have already gathered the capabilities, we need to invalidate
|
|
|
|
|
// the cache so that the new CRDs are recognized. This should only be
|
|
|
|
|
// the case when an action configuration is reused for multiple actions,
|
|
|
|
|
// as otherwise it is later loaded by ourselves when getCapabilities
|
|
|
|
|
// is called later on in the installation process.
|
|
|
|
|
if i.cfg.Capabilities != nil {
|
|
|
|
|
discoveryClient, err := i.cfg.RESTClientGetter.ToDiscoveryClient()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
if discoveryClient != nil {
|
|
|
|
|
i.cfg.Log("Clearing discovery cache")
|
|
|
|
|
discoveryClient.Invalidate()
|
|
|
|
|
_, _ = discoveryClient.ServerGroups()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Invalidate the REST mapper, since it will not have the new CRDs
|
|
|
|
|
// present.
|
|
|
|
|
restMapper, err := i.cfg.RESTClientGetter.ToRESTMapper()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i.cfg.Log("Clearing discovery cache")
|
|
|
|
|
discoveryClient.Invalidate()
|
|
|
|
|
|
|
|
|
|
_, _ = discoveryClient.ServerGroups()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Invalidate the REST mapper, since it will not have the new CRDs
|
|
|
|
|
// present.
|
|
|
|
|
restMapper, err := i.cfg.RESTClientGetter.ToRESTMapper()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
if resettable, ok := restMapper.(meta.ResettableRESTMapper); ok {
|
|
|
|
|
i.cfg.Log("Clearing REST mapper cache")
|
|
|
|
|
resettable.Reset()
|
|
|
|
|
if resettable, ok := restMapper.(meta.ResettableRESTMapper); ok {
|
|
|
|
|
i.cfg.Log("Clearing REST mapper cache")
|
|
|
|
|
resettable.Reset()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
|