fix(tiller): allow 3rd party APIs

This feature has been disabled in the past because simply enabling the
feature causes the Kubernetes library to make requests to a server.
Thus, running any tests that use the 'pkg/kube' library has required
running a kube API server.

This patch makes it possible to selectively activate 3rdParty API
support, and then disables that support during testing.

Future versions of the Kubernetes library appear to make it easier to
configure and mock this behavior, so this is most likely a stop-gap
measure. (Famous last words.)

Closes #1472
reviewable/pr1473/r1
Matt Butcher 9 years ago
parent 3ba2427278
commit c7a56aedeb
No known key found for this signature in database
GPG Key ID: DCD5F5E5EF32C345

@ -145,7 +145,7 @@ func (c *Client) Get(namespace string, reader io.Reader) (string, error) {
//
// Namespace will set the namespaces
func (c *Client) Update(namespace string, currentReader, targetReader io.Reader) error {
current := c.NewBuilder(includeThirdPartyAPIs).
current := c.NewBuilder(IncludeThirdPartyAPIs).
ContinueOnError().
NamespaceParam(namespace).
DefaultNamespace().
@ -153,7 +153,7 @@ func (c *Client) Update(namespace string, currentReader, targetReader io.Reader)
Flatten().
Do()
target := c.NewBuilder(includeThirdPartyAPIs).
target := c.NewBuilder(IncludeThirdPartyAPIs).
ContinueOnError().
NamespaceParam(namespace).
DefaultNamespace().
@ -275,10 +275,16 @@ func (c *Client) WatchUntilReady(namespace string, reader io.Reader) error {
return perform(c, namespace, reader, watchUntilReady)
}
const includeThirdPartyAPIs = false
// IncludeThirdPartyAPIs indicates whether to load "dynamic" APIs.
//
// This requires additional calls to the Kubernetes API server, and these calls
// are not supported by all versions. Additionally, during testing, initializing
// a client will still attempt to contact a live server. In these situations,
// this flag may need to be disabled.
var IncludeThirdPartyAPIs = true
func perform(c *Client, namespace string, reader io.Reader, fn ResourceActorFunc) error {
r := c.NewBuilder(includeThirdPartyAPIs).
r := c.NewBuilder(IncludeThirdPartyAPIs).
ContinueOnError().
NamespaceParam(namespace).
DefaultNamespace().

@ -33,6 +33,12 @@ import (
"k8s.io/kubernetes/pkg/runtime"
)
func init() {
// Disable 3rd party APIs because this requires a live Kube API server
// upon initialization.
IncludeThirdPartyAPIs = false
}
func TestUpdateResource(t *testing.T) {
tests := []struct {

Loading…
Cancel
Save