Skip to content

Commit

Permalink
Merge pull request #3183 from justinsb/offline_channel
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

Read the channel from the local filesystem during tests
  • Loading branch information
Kubernetes Submit Queue authored Aug 25, 2017
2 parents 63480a7 + 4767ee9 commit 0aaafb8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/apis/kops/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import (
"net/url"
)

const DefaultChannelBase = "https://raw.githubusercontent.com/kubernetes/kops/master/channels/"
var DefaultChannelBase = "https://raw.githubusercontent.com/kubernetes/kops/master/channels/"

const DefaultChannel = "stable"
const AlphaChannel = "alpha"

Expand Down
21 changes: 21 additions & 0 deletions pkg/testutils/integrationtestharness.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,21 @@ import (
"io/ioutil"
"k8s.io/kops/cloudmock/aws/mockec2"
"k8s.io/kops/cloudmock/aws/mockroute53"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
"k8s.io/kops/util/pkg/vfs"
"os"
"path"
"path/filepath"
"testing"
)

type IntegrationTestHarness struct {
TempDir string
T *testing.T

// The original kops DefaultChannelBase value, restored on Close
originalDefaultChannelBase string
}

func NewIntegrationTestHarness(t *testing.T) *IntegrationTestHarness {
Expand All @@ -45,6 +51,17 @@ func NewIntegrationTestHarness(t *testing.T) *IntegrationTestHarness {

vfs.Context.ResetMemfsContext(true)

// Replace the default channel path with a local filesystem path, so we don't try to retrieve it from a server
{
channelPath, err := filepath.Abs(path.Join("../../channels/"))
if err != nil {
t.Fatalf("error resolving stable channel path: %v", err)
}
channelPath += "/"
h.originalDefaultChannelBase = kops.DefaultChannelBase
kops.DefaultChannelBase = "file://" + channelPath
}

return h
}

Expand All @@ -59,6 +76,10 @@ func (h *IntegrationTestHarness) Close() {
}
}
}

if h.originalDefaultChannelBase != "" {
kops.DefaultChannelBase = h.originalDefaultChannelBase
}
}

func (h *IntegrationTestHarness) SetupMockAWS() {
Expand Down

0 comments on commit 0aaafb8

Please sign in to comment.