use istio client-go library instead of knative (#1661)

use istio client-go library instead of knative
bump kubernetes dependency version
change code coverage to codecov
This commit is contained in:
zryfish
2019-12-13 11:26:18 +08:00
committed by GitHub
parent f249a6e081
commit ea88c8803d
2071 changed files with 354531 additions and 108336 deletions

View File

@@ -17,11 +17,13 @@ limitations under the License.
package inject
import (
"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission/types"
)
// Cache is used by the ControllerManager to inject Cache into Sources, EventHandlers, Predicates, and
@@ -39,6 +41,20 @@ func CacheInto(c cache.Cache, i interface{}) (bool, error) {
return false, nil
}
// APIReader is used by the Manager to inject the APIReader into necessary types.
type APIReader interface {
InjectAPIReader(client.Reader) error
}
// APIReaderInto will set APIReader on i and return the result if it implements APIReaderInto.
// Returns false if i does not implement APIReader
func APIReaderInto(reader client.Reader, i interface{}) (bool, error) {
if s, ok := i.(APIReader); ok {
return true, s.InjectAPIReader(reader)
}
return false, nil
}
// Config is used by the ControllerManager to inject Config into Sources, EventHandlers, Predicates, and
// Reconciles
type Config interface {
@@ -69,20 +85,6 @@ func ClientInto(client client.Client, i interface{}) (bool, error) {
return false, nil
}
// Decoder is used by the ControllerManager to inject decoder into webhook handlers.
type Decoder interface {
InjectDecoder(types.Decoder) error
}
// DecoderInto will set decoder on i and return the result if it implements Decoder. Returns
// false if i does not implement Decoder.
func DecoderInto(decoder types.Decoder, i interface{}) (bool, error) {
if s, ok := i.(Decoder); ok {
return true, s.InjectDecoder(decoder)
}
return false, nil
}
// Scheme is used by the ControllerManager to inject Scheme into Sources, EventHandlers, Predicates, and
// Reconciles
type Scheme interface {
@@ -113,6 +115,20 @@ func StopChannelInto(stop <-chan struct{}, i interface{}) (bool, error) {
return false, nil
}
// Mapper is used to inject the rest mapper to components that may need it
type Mapper interface {
InjectMapper(meta.RESTMapper) error
}
// MapperInto will set the rest mapper on i and return the result if it implements Mapper.
// Returns false if i does not implement Mapper.
func MapperInto(mapper meta.RESTMapper, i interface{}) (bool, error) {
if m, ok := i.(Mapper); ok {
return true, m.InjectMapper(mapper)
}
return false, nil
}
// Func injects dependencies into i.
type Func func(i interface{}) error
@@ -129,3 +145,18 @@ func InjectorInto(f Func, i interface{}) (bool, error) {
}
return false, nil
}
// Logger is used to inject Loggers into components that need them
// and don't otherwise have opinions.
type Logger interface {
InjectLogger(l logr.Logger) error
}
// LoggerInto will set the logger on the given object if it implements inject.Logger,
// returning true if a InjectLogger was called, and false otherwise.
func LoggerInto(l logr.Logger, i interface{}) (bool, error) {
if injectable, wantsLogger := i.(Logger); wantsLogger {
return true, injectable.InjectLogger(l)
}
return false, nil
}