diff --git a/agentclient/mocks/mocks.go b/agentclient/mocks/mocks.go index 0fd83c8f0..ba5cbe482 100644 --- a/agentclient/mocks/mocks.go +++ b/agentclient/mocks/mocks.go @@ -5,36 +5,37 @@ package mocks import ( + reflect "reflect" + agentclient "github.com/cloudfoundry/bosh-agent/agentclient" applyspec "github.com/cloudfoundry/bosh-agent/agentclient/applyspec" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockAgentClient is a mock of AgentClient interface +// MockAgentClient is a mock of AgentClient interface. type MockAgentClient struct { ctrl *gomock.Controller recorder *MockAgentClientMockRecorder } -// MockAgentClientMockRecorder is the mock recorder for MockAgentClient +// MockAgentClientMockRecorder is the mock recorder for MockAgentClient. type MockAgentClientMockRecorder struct { mock *MockAgentClient } -// NewMockAgentClient creates a new mock instance +// NewMockAgentClient creates a new mock instance. func NewMockAgentClient(ctrl *gomock.Controller) *MockAgentClient { mock := &MockAgentClient{ctrl: ctrl} mock.recorder = &MockAgentClientMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockAgentClient) EXPECT() *MockAgentClientMockRecorder { return m.recorder } -// AddPersistentDisk mocks base method +// AddPersistentDisk mocks base method. func (m *MockAgentClient) AddPersistentDisk(arg0 string, arg1 interface{}) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "AddPersistentDisk", arg0, arg1) @@ -42,13 +43,13 @@ func (m *MockAgentClient) AddPersistentDisk(arg0 string, arg1 interface{}) error return ret0 } -// AddPersistentDisk indicates an expected call of AddPersistentDisk +// AddPersistentDisk indicates an expected call of AddPersistentDisk. func (mr *MockAgentClientMockRecorder) AddPersistentDisk(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddPersistentDisk", reflect.TypeOf((*MockAgentClient)(nil).AddPersistentDisk), arg0, arg1) } -// Apply mocks base method +// Apply mocks base method. func (m *MockAgentClient) Apply(arg0 applyspec.ApplySpec) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Apply", arg0) @@ -56,13 +57,13 @@ func (m *MockAgentClient) Apply(arg0 applyspec.ApplySpec) error { return ret0 } -// Apply indicates an expected call of Apply +// Apply indicates an expected call of Apply. func (mr *MockAgentClientMockRecorder) Apply(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Apply", reflect.TypeOf((*MockAgentClient)(nil).Apply), arg0) } -// CompilePackage mocks base method +// CompilePackage mocks base method. func (m *MockAgentClient) CompilePackage(arg0 agentclient.BlobRef, arg1 []agentclient.BlobRef) (agentclient.BlobRef, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CompilePackage", arg0, arg1) @@ -71,13 +72,13 @@ func (m *MockAgentClient) CompilePackage(arg0 agentclient.BlobRef, arg1 []agentc return ret0, ret1 } -// CompilePackage indicates an expected call of CompilePackage +// CompilePackage indicates an expected call of CompilePackage. func (mr *MockAgentClientMockRecorder) CompilePackage(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CompilePackage", reflect.TypeOf((*MockAgentClient)(nil).CompilePackage), arg0, arg1) } -// DeleteARPEntries mocks base method +// DeleteARPEntries mocks base method. func (m *MockAgentClient) DeleteARPEntries(arg0 []string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteARPEntries", arg0) @@ -85,13 +86,13 @@ func (m *MockAgentClient) DeleteARPEntries(arg0 []string) error { return ret0 } -// DeleteARPEntries indicates an expected call of DeleteARPEntries +// DeleteARPEntries indicates an expected call of DeleteARPEntries. func (mr *MockAgentClientMockRecorder) DeleteARPEntries(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteARPEntries", reflect.TypeOf((*MockAgentClient)(nil).DeleteARPEntries), arg0) } -// Drain mocks base method +// Drain mocks base method. func (m *MockAgentClient) Drain(arg0 string) (int64, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Drain", arg0) @@ -100,13 +101,13 @@ func (m *MockAgentClient) Drain(arg0 string) (int64, error) { return ret0, ret1 } -// Drain indicates an expected call of Drain +// Drain indicates an expected call of Drain. func (mr *MockAgentClientMockRecorder) Drain(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Drain", reflect.TypeOf((*MockAgentClient)(nil).Drain), arg0) } -// GetState mocks base method +// GetState mocks base method. func (m *MockAgentClient) GetState() (agentclient.AgentState, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetState") @@ -115,13 +116,13 @@ func (m *MockAgentClient) GetState() (agentclient.AgentState, error) { return ret0, ret1 } -// GetState indicates an expected call of GetState +// GetState indicates an expected call of GetState. func (mr *MockAgentClientMockRecorder) GetState() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetState", reflect.TypeOf((*MockAgentClient)(nil).GetState)) } -// ListDisk mocks base method +// ListDisk mocks base method. func (m *MockAgentClient) ListDisk() ([]string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListDisk") @@ -130,13 +131,13 @@ func (m *MockAgentClient) ListDisk() ([]string, error) { return ret0, ret1 } -// ListDisk indicates an expected call of ListDisk +// ListDisk indicates an expected call of ListDisk. func (mr *MockAgentClientMockRecorder) ListDisk() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListDisk", reflect.TypeOf((*MockAgentClient)(nil).ListDisk)) } -// MigrateDisk mocks base method +// MigrateDisk mocks base method. func (m *MockAgentClient) MigrateDisk() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MigrateDisk") @@ -144,13 +145,13 @@ func (m *MockAgentClient) MigrateDisk() error { return ret0 } -// MigrateDisk indicates an expected call of MigrateDisk +// MigrateDisk indicates an expected call of MigrateDisk. func (mr *MockAgentClientMockRecorder) MigrateDisk() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MigrateDisk", reflect.TypeOf((*MockAgentClient)(nil).MigrateDisk)) } -// MountDisk mocks base method +// MountDisk mocks base method. func (m *MockAgentClient) MountDisk(arg0 string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MountDisk", arg0) @@ -158,13 +159,13 @@ func (m *MockAgentClient) MountDisk(arg0 string) error { return ret0 } -// MountDisk indicates an expected call of MountDisk +// MountDisk indicates an expected call of MountDisk. func (mr *MockAgentClientMockRecorder) MountDisk(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MountDisk", reflect.TypeOf((*MockAgentClient)(nil).MountDisk), arg0) } -// Ping mocks base method +// Ping mocks base method. func (m *MockAgentClient) Ping() (string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Ping") @@ -173,13 +174,13 @@ func (m *MockAgentClient) Ping() (string, error) { return ret0, ret1 } -// Ping indicates an expected call of Ping +// Ping indicates an expected call of Ping. func (mr *MockAgentClientMockRecorder) Ping() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ping", reflect.TypeOf((*MockAgentClient)(nil).Ping)) } -// RemovePersistentDisk mocks base method +// RemovePersistentDisk mocks base method. func (m *MockAgentClient) RemovePersistentDisk(arg0 string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RemovePersistentDisk", arg0) @@ -187,13 +188,13 @@ func (m *MockAgentClient) RemovePersistentDisk(arg0 string) error { return ret0 } -// RemovePersistentDisk indicates an expected call of RemovePersistentDisk +// RemovePersistentDisk indicates an expected call of RemovePersistentDisk. func (mr *MockAgentClientMockRecorder) RemovePersistentDisk(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemovePersistentDisk", reflect.TypeOf((*MockAgentClient)(nil).RemovePersistentDisk), arg0) } -// RunScript mocks base method +// RunScript mocks base method. func (m *MockAgentClient) RunScript(arg0 string, arg1 map[string]interface{}) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RunScript", arg0, arg1) @@ -201,13 +202,13 @@ func (m *MockAgentClient) RunScript(arg0 string, arg1 map[string]interface{}) er return ret0 } -// RunScript indicates an expected call of RunScript +// RunScript indicates an expected call of RunScript. func (mr *MockAgentClientMockRecorder) RunScript(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RunScript", reflect.TypeOf((*MockAgentClient)(nil).RunScript), arg0, arg1) } -// Start mocks base method +// Start mocks base method. func (m *MockAgentClient) Start() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Start") @@ -215,13 +216,13 @@ func (m *MockAgentClient) Start() error { return ret0 } -// Start indicates an expected call of Start +// Start indicates an expected call of Start. func (mr *MockAgentClientMockRecorder) Start() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockAgentClient)(nil).Start)) } -// Stop mocks base method +// Stop mocks base method. func (m *MockAgentClient) Stop() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Stop") @@ -229,13 +230,13 @@ func (m *MockAgentClient) Stop() error { return ret0 } -// Stop indicates an expected call of Stop +// Stop indicates an expected call of Stop. func (mr *MockAgentClientMockRecorder) Stop() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockAgentClient)(nil).Stop)) } -// SyncDNS mocks base method +// SyncDNS mocks base method. func (m *MockAgentClient) SyncDNS(arg0, arg1 string, arg2 uint64) (string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SyncDNS", arg0, arg1, arg2) @@ -244,13 +245,13 @@ func (m *MockAgentClient) SyncDNS(arg0, arg1 string, arg2 uint64) (string, error return ret0, ret1 } -// SyncDNS indicates an expected call of SyncDNS +// SyncDNS indicates an expected call of SyncDNS. func (mr *MockAgentClientMockRecorder) SyncDNS(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncDNS", reflect.TypeOf((*MockAgentClient)(nil).SyncDNS), arg0, arg1, arg2) } -// UnmountDisk mocks base method +// UnmountDisk mocks base method. func (m *MockAgentClient) UnmountDisk(arg0 string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UnmountDisk", arg0) @@ -258,7 +259,7 @@ func (m *MockAgentClient) UnmountDisk(arg0 string) error { return ret0 } -// UnmountDisk indicates an expected call of UnmountDisk +// UnmountDisk indicates an expected call of UnmountDisk. func (mr *MockAgentClientMockRecorder) UnmountDisk(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnmountDisk", reflect.TypeOf((*MockAgentClient)(nil).UnmountDisk), arg0) diff --git a/bin/mockgen b/bin/mockgen index 63ce63480..d90491b36 100755 --- a/bin/mockgen +++ b/bin/mockgen @@ -17,7 +17,6 @@ srcFiles=( deployment/disk/Disk,Manager deployment/vm/ManagerFactory deployment/release/JobResolver - registry/Server,ServerManager release/Manager,Extractor state/job/DependencyCompiler state/pkg/Compiler,CompiledPackageRepo @@ -38,8 +37,14 @@ for srcFile in ${srcFiles[*]}; do mkdir -p $srcDir/mocks echo mockgen -package mocks -destination $destFile $rootPackage/$package $class mockgen -package mocks -destination $destFile $rootPackage/$package $class - sed -i "" -e "s%github.com/cloudfoundry/bosh-cli/vendor/%%" $destFile - $bin/go fmt $destFile + if [[ "$(uname)" == "Linux" ]]; then + #gnu sed + sed -i "$destFile" -e "s%github.com/cloudfoundry/bosh-cli/vendor/%%" + else + #osx bsd sed + sed -i "" -e "s%github.com/cloudfoundry/bosh-cli/vendor/%%" $destFile + fi + go fmt $destFil done diff --git a/blobstore/mocks/mocks.go b/blobstore/mocks/mocks.go index 3bdf8fe3b..ffa768f1d 100644 --- a/blobstore/mocks/mocks.go +++ b/blobstore/mocks/mocks.go @@ -5,36 +5,37 @@ package mocks import ( - blobstore "github.com/cloudfoundry/bosh-cli/blobstore" - gomock "github.com/golang/mock/gomock" http "net/http" reflect "reflect" + + blobstore "github.com/cloudfoundry/bosh-cli/blobstore" + gomock "github.com/golang/mock/gomock" ) -// MockFactory is a mock of Factory interface +// MockFactory is a mock of Factory interface. type MockFactory struct { ctrl *gomock.Controller recorder *MockFactoryMockRecorder } -// MockFactoryMockRecorder is the mock recorder for MockFactory +// MockFactoryMockRecorder is the mock recorder for MockFactory. type MockFactoryMockRecorder struct { mock *MockFactory } -// NewMockFactory creates a new mock instance +// NewMockFactory creates a new mock instance. func NewMockFactory(ctrl *gomock.Controller) *MockFactory { mock := &MockFactory{ctrl: ctrl} mock.recorder = &MockFactoryMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockFactory) EXPECT() *MockFactoryMockRecorder { return m.recorder } -// Create mocks base method +// Create mocks base method. func (m *MockFactory) Create(arg0 string, arg1 *http.Client) (blobstore.Blobstore, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Create", arg0, arg1) @@ -43,36 +44,36 @@ func (m *MockFactory) Create(arg0 string, arg1 *http.Client) (blobstore.Blobstor return ret0, ret1 } -// Create indicates an expected call of Create +// Create indicates an expected call of Create. func (mr *MockFactoryMockRecorder) Create(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockFactory)(nil).Create), arg0, arg1) } -// MockBlobstore is a mock of Blobstore interface +// MockBlobstore is a mock of Blobstore interface. type MockBlobstore struct { ctrl *gomock.Controller recorder *MockBlobstoreMockRecorder } -// MockBlobstoreMockRecorder is the mock recorder for MockBlobstore +// MockBlobstoreMockRecorder is the mock recorder for MockBlobstore. type MockBlobstoreMockRecorder struct { mock *MockBlobstore } -// NewMockBlobstore creates a new mock instance +// NewMockBlobstore creates a new mock instance. func NewMockBlobstore(ctrl *gomock.Controller) *MockBlobstore { mock := &MockBlobstore{ctrl: ctrl} mock.recorder = &MockBlobstoreMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockBlobstore) EXPECT() *MockBlobstoreMockRecorder { return m.recorder } -// Add mocks base method +// Add mocks base method. func (m *MockBlobstore) Add(arg0 string) (string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Add", arg0) @@ -81,13 +82,13 @@ func (m *MockBlobstore) Add(arg0 string) (string, error) { return ret0, ret1 } -// Add indicates an expected call of Add +// Add indicates an expected call of Add. func (mr *MockBlobstoreMockRecorder) Add(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Add", reflect.TypeOf((*MockBlobstore)(nil).Add), arg0) } -// Get mocks base method +// Get mocks base method. func (m *MockBlobstore) Get(arg0 string) (blobstore.LocalBlob, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Get", arg0) @@ -96,7 +97,7 @@ func (m *MockBlobstore) Get(arg0 string) (blobstore.LocalBlob, error) { return ret0, ret1 } -// Get indicates an expected call of Get +// Get indicates an expected call of Get. func (mr *MockBlobstoreMockRecorder) Get(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockBlobstore)(nil).Get), arg0) diff --git a/cloud/mocks/mocks.go b/cloud/mocks/mocks.go index 63271a083..2c73008d9 100644 --- a/cloud/mocks/mocks.go +++ b/cloud/mocks/mocks.go @@ -5,37 +5,38 @@ package mocks import ( + reflect "reflect" + cloud "github.com/cloudfoundry/bosh-cli/cloud" installation "github.com/cloudfoundry/bosh-cli/installation" property "github.com/cloudfoundry/bosh-utils/property" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockCloud is a mock of Cloud interface +// MockCloud is a mock of Cloud interface. type MockCloud struct { ctrl *gomock.Controller recorder *MockCloudMockRecorder } -// MockCloudMockRecorder is the mock recorder for MockCloud +// MockCloudMockRecorder is the mock recorder for MockCloud. type MockCloudMockRecorder struct { mock *MockCloud } -// NewMockCloud creates a new mock instance +// NewMockCloud creates a new mock instance. func NewMockCloud(ctrl *gomock.Controller) *MockCloud { mock := &MockCloud{ctrl: ctrl} mock.recorder = &MockCloudMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockCloud) EXPECT() *MockCloudMockRecorder { return m.recorder } -// AttachDisk mocks base method +// AttachDisk mocks base method. func (m *MockCloud) AttachDisk(arg0, arg1 string) (interface{}, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "AttachDisk", arg0, arg1) @@ -44,13 +45,13 @@ func (m *MockCloud) AttachDisk(arg0, arg1 string) (interface{}, error) { return ret0, ret1 } -// AttachDisk indicates an expected call of AttachDisk +// AttachDisk indicates an expected call of AttachDisk. func (mr *MockCloudMockRecorder) AttachDisk(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AttachDisk", reflect.TypeOf((*MockCloud)(nil).AttachDisk), arg0, arg1) } -// CreateDisk mocks base method +// CreateDisk mocks base method. func (m *MockCloud) CreateDisk(arg0 int, arg1 property.Map, arg2 string) (string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateDisk", arg0, arg1, arg2) @@ -59,13 +60,13 @@ func (m *MockCloud) CreateDisk(arg0 int, arg1 property.Map, arg2 string) (string return ret0, ret1 } -// CreateDisk indicates an expected call of CreateDisk +// CreateDisk indicates an expected call of CreateDisk. func (mr *MockCloudMockRecorder) CreateDisk(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateDisk", reflect.TypeOf((*MockCloud)(nil).CreateDisk), arg0, arg1, arg2) } -// CreateStemcell mocks base method +// CreateStemcell mocks base method. func (m *MockCloud) CreateStemcell(arg0 string, arg1 property.Map) (string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateStemcell", arg0, arg1) @@ -74,13 +75,13 @@ func (m *MockCloud) CreateStemcell(arg0 string, arg1 property.Map) (string, erro return ret0, ret1 } -// CreateStemcell indicates an expected call of CreateStemcell +// CreateStemcell indicates an expected call of CreateStemcell. func (mr *MockCloudMockRecorder) CreateStemcell(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateStemcell", reflect.TypeOf((*MockCloud)(nil).CreateStemcell), arg0, arg1) } -// CreateVM mocks base method +// CreateVM mocks base method. func (m *MockCloud) CreateVM(arg0, arg1 string, arg2 property.Map, arg3 map[string]property.Map, arg4 property.Map) (string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateVM", arg0, arg1, arg2, arg3, arg4) @@ -89,13 +90,13 @@ func (m *MockCloud) CreateVM(arg0, arg1 string, arg2 property.Map, arg3 map[stri return ret0, ret1 } -// CreateVM indicates an expected call of CreateVM +// CreateVM indicates an expected call of CreateVM. func (mr *MockCloudMockRecorder) CreateVM(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateVM", reflect.TypeOf((*MockCloud)(nil).CreateVM), arg0, arg1, arg2, arg3, arg4) } -// DeleteDisk mocks base method +// DeleteDisk mocks base method. func (m *MockCloud) DeleteDisk(arg0 string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteDisk", arg0) @@ -103,13 +104,13 @@ func (m *MockCloud) DeleteDisk(arg0 string) error { return ret0 } -// DeleteDisk indicates an expected call of DeleteDisk +// DeleteDisk indicates an expected call of DeleteDisk. func (mr *MockCloudMockRecorder) DeleteDisk(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteDisk", reflect.TypeOf((*MockCloud)(nil).DeleteDisk), arg0) } -// DeleteStemcell mocks base method +// DeleteStemcell mocks base method. func (m *MockCloud) DeleteStemcell(arg0 string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteStemcell", arg0) @@ -117,13 +118,13 @@ func (m *MockCloud) DeleteStemcell(arg0 string) error { return ret0 } -// DeleteStemcell indicates an expected call of DeleteStemcell +// DeleteStemcell indicates an expected call of DeleteStemcell. func (mr *MockCloudMockRecorder) DeleteStemcell(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteStemcell", reflect.TypeOf((*MockCloud)(nil).DeleteStemcell), arg0) } -// DeleteVM mocks base method +// DeleteVM mocks base method. func (m *MockCloud) DeleteVM(arg0 string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteVM", arg0) @@ -131,13 +132,13 @@ func (m *MockCloud) DeleteVM(arg0 string) error { return ret0 } -// DeleteVM indicates an expected call of DeleteVM +// DeleteVM indicates an expected call of DeleteVM. func (mr *MockCloudMockRecorder) DeleteVM(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteVM", reflect.TypeOf((*MockCloud)(nil).DeleteVM), arg0) } -// DetachDisk mocks base method +// DetachDisk mocks base method. func (m *MockCloud) DetachDisk(arg0, arg1 string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DetachDisk", arg0, arg1) @@ -145,13 +146,13 @@ func (m *MockCloud) DetachDisk(arg0, arg1 string) error { return ret0 } -// DetachDisk indicates an expected call of DetachDisk +// DetachDisk indicates an expected call of DetachDisk. func (mr *MockCloudMockRecorder) DetachDisk(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DetachDisk", reflect.TypeOf((*MockCloud)(nil).DetachDisk), arg0, arg1) } -// HasVM mocks base method +// HasVM mocks base method. func (m *MockCloud) HasVM(arg0 string) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "HasVM", arg0) @@ -160,13 +161,13 @@ func (m *MockCloud) HasVM(arg0 string) (bool, error) { return ret0, ret1 } -// HasVM indicates an expected call of HasVM +// HasVM indicates an expected call of HasVM. func (mr *MockCloudMockRecorder) HasVM(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasVM", reflect.TypeOf((*MockCloud)(nil).HasVM), arg0) } -// Info mocks base method +// Info mocks base method. func (m *MockCloud) Info() (cloud.CpiInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Info") @@ -175,13 +176,13 @@ func (m *MockCloud) Info() (cloud.CpiInfo, error) { return ret0, ret1 } -// Info indicates an expected call of Info +// Info indicates an expected call of Info. func (mr *MockCloudMockRecorder) Info() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Info", reflect.TypeOf((*MockCloud)(nil).Info)) } -// SetDiskMetadata mocks base method +// SetDiskMetadata mocks base method. func (m *MockCloud) SetDiskMetadata(arg0 string, arg1 cloud.DiskMetadata) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetDiskMetadata", arg0, arg1) @@ -189,13 +190,13 @@ func (m *MockCloud) SetDiskMetadata(arg0 string, arg1 cloud.DiskMetadata) error return ret0 } -// SetDiskMetadata indicates an expected call of SetDiskMetadata +// SetDiskMetadata indicates an expected call of SetDiskMetadata. func (mr *MockCloudMockRecorder) SetDiskMetadata(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDiskMetadata", reflect.TypeOf((*MockCloud)(nil).SetDiskMetadata), arg0, arg1) } -// SetVMMetadata mocks base method +// SetVMMetadata mocks base method. func (m *MockCloud) SetVMMetadata(arg0 string, arg1 cloud.VMMetadata) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetVMMetadata", arg0, arg1) @@ -203,13 +204,13 @@ func (m *MockCloud) SetVMMetadata(arg0 string, arg1 cloud.VMMetadata) error { return ret0 } -// SetVMMetadata indicates an expected call of SetVMMetadata +// SetVMMetadata indicates an expected call of SetVMMetadata. func (mr *MockCloudMockRecorder) SetVMMetadata(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetVMMetadata", reflect.TypeOf((*MockCloud)(nil).SetVMMetadata), arg0, arg1) } -// String mocks base method +// String mocks base method. func (m *MockCloud) String() string { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "String") @@ -217,36 +218,36 @@ func (m *MockCloud) String() string { return ret0 } -// String indicates an expected call of String +// String indicates an expected call of String. func (mr *MockCloudMockRecorder) String() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "String", reflect.TypeOf((*MockCloud)(nil).String)) } -// MockFactory is a mock of Factory interface +// MockFactory is a mock of Factory interface. type MockFactory struct { ctrl *gomock.Controller recorder *MockFactoryMockRecorder } -// MockFactoryMockRecorder is the mock recorder for MockFactory +// MockFactoryMockRecorder is the mock recorder for MockFactory. type MockFactoryMockRecorder struct { mock *MockFactory } -// NewMockFactory creates a new mock instance +// NewMockFactory creates a new mock instance. func NewMockFactory(ctrl *gomock.Controller) *MockFactory { mock := &MockFactory{ctrl: ctrl} mock.recorder = &MockFactoryMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockFactory) EXPECT() *MockFactoryMockRecorder { return m.recorder } -// NewCloud mocks base method +// NewCloud mocks base method. func (m *MockFactory) NewCloud(arg0 installation.Installation, arg1 string, arg2 int) (cloud.Cloud, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewCloud", arg0, arg1, arg2) @@ -255,7 +256,7 @@ func (m *MockFactory) NewCloud(arg0 installation.Installation, arg1 string, arg2 return ret0, ret1 } -// NewCloud indicates an expected call of NewCloud +// NewCloud indicates an expected call of NewCloud. func (mr *MockFactoryMockRecorder) NewCloud(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewCloud", reflect.TypeOf((*MockFactory)(nil).NewCloud), arg0, arg1, arg2) diff --git a/cmd/cmdfakes/fake_downloader.go b/cmd/cmdfakes/fake_downloader.go index aedf8c182..9ff254473 100644 --- a/cmd/cmdfakes/fake_downloader.go +++ b/cmd/cmdfakes/fake_downloader.go @@ -8,13 +8,13 @@ import ( ) type FakeDownloader struct { - DownloadStub func(blobstoreID, sha1, prefix, dstDirPath string) error + DownloadStub func(string, string, string, string) error downloadMutex sync.RWMutex downloadArgsForCall []struct { - blobstoreID string - sha1 string - prefix string - dstDirPath string + arg1 string + arg2 string + arg3 string + arg4 string } downloadReturns struct { result1 error @@ -26,24 +26,26 @@ type FakeDownloader struct { invocationsMutex sync.RWMutex } -func (fake *FakeDownloader) Download(blobstoreID string, sha1 string, prefix string, dstDirPath string) error { +func (fake *FakeDownloader) Download(arg1 string, arg2 string, arg3 string, arg4 string) error { fake.downloadMutex.Lock() ret, specificReturn := fake.downloadReturnsOnCall[len(fake.downloadArgsForCall)] fake.downloadArgsForCall = append(fake.downloadArgsForCall, struct { - blobstoreID string - sha1 string - prefix string - dstDirPath string - }{blobstoreID, sha1, prefix, dstDirPath}) - fake.recordInvocation("Download", []interface{}{blobstoreID, sha1, prefix, dstDirPath}) + arg1 string + arg2 string + arg3 string + arg4 string + }{arg1, arg2, arg3, arg4}) + stub := fake.DownloadStub + fakeReturns := fake.downloadReturns + fake.recordInvocation("Download", []interface{}{arg1, arg2, arg3, arg4}) fake.downloadMutex.Unlock() - if fake.DownloadStub != nil { - return fake.DownloadStub(blobstoreID, sha1, prefix, dstDirPath) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1 } - return fake.downloadReturns.result1 + return fakeReturns.result1 } func (fake *FakeDownloader) DownloadCallCount() int { @@ -52,13 +54,22 @@ func (fake *FakeDownloader) DownloadCallCount() int { return len(fake.downloadArgsForCall) } +func (fake *FakeDownloader) DownloadCalls(stub func(string, string, string, string) error) { + fake.downloadMutex.Lock() + defer fake.downloadMutex.Unlock() + fake.DownloadStub = stub +} + func (fake *FakeDownloader) DownloadArgsForCall(i int) (string, string, string, string) { fake.downloadMutex.RLock() defer fake.downloadMutex.RUnlock() - return fake.downloadArgsForCall[i].blobstoreID, fake.downloadArgsForCall[i].sha1, fake.downloadArgsForCall[i].prefix, fake.downloadArgsForCall[i].dstDirPath + argsForCall := fake.downloadArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 } func (fake *FakeDownloader) DownloadReturns(result1 error) { + fake.downloadMutex.Lock() + defer fake.downloadMutex.Unlock() fake.DownloadStub = nil fake.downloadReturns = struct { result1 error @@ -66,6 +77,8 @@ func (fake *FakeDownloader) DownloadReturns(result1 error) { } func (fake *FakeDownloader) DownloadReturnsOnCall(i int, result1 error) { + fake.downloadMutex.Lock() + defer fake.downloadMutex.Unlock() fake.DownloadStub = nil if fake.downloadReturnsOnCall == nil { fake.downloadReturnsOnCall = make(map[int]struct { @@ -82,7 +95,11 @@ func (fake *FakeDownloader) Invocations() map[string][][]interface{} { defer fake.invocationsMutex.RUnlock() fake.downloadMutex.RLock() defer fake.downloadMutex.RUnlock() - return fake.invocations + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeDownloader) recordInvocation(key string, args []interface{}) { diff --git a/cmd/cmdfakes/fake_release_creating_cmd.go b/cmd/cmdfakes/fake_release_creating_cmd.go index c3acc2954..5a0068417 100644 --- a/cmd/cmdfakes/fake_release_creating_cmd.go +++ b/cmd/cmdfakes/fake_release_creating_cmd.go @@ -6,42 +6,44 @@ import ( "github.com/cloudfoundry/bosh-cli/cmd" "github.com/cloudfoundry/bosh-cli/cmd/opts" - boshrel "github.com/cloudfoundry/bosh-cli/release" + "github.com/cloudfoundry/bosh-cli/release" ) type FakeReleaseCreatingCmd struct { - RunStub func(opts.CreateReleaseOpts) (boshrel.Release, error) + RunStub func(opts.CreateReleaseOpts) (release.Release, error) runMutex sync.RWMutex runArgsForCall []struct { arg1 opts.CreateReleaseOpts } runReturns struct { - result1 boshrel.Release + result1 release.Release result2 error } runReturnsOnCall map[int]struct { - result1 boshrel.Release + result1 release.Release result2 error } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } -func (fake *FakeReleaseCreatingCmd) Run(arg1 opts.CreateReleaseOpts) (boshrel.Release, error) { +func (fake *FakeReleaseCreatingCmd) Run(arg1 opts.CreateReleaseOpts) (release.Release, error) { fake.runMutex.Lock() ret, specificReturn := fake.runReturnsOnCall[len(fake.runArgsForCall)] fake.runArgsForCall = append(fake.runArgsForCall, struct { arg1 opts.CreateReleaseOpts }{arg1}) + stub := fake.RunStub + fakeReturns := fake.runReturns fake.recordInvocation("Run", []interface{}{arg1}) fake.runMutex.Unlock() - if fake.RunStub != nil { - return fake.RunStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.runReturns.result1, fake.runReturns.result2 + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeReleaseCreatingCmd) RunCallCount() int { @@ -50,30 +52,41 @@ func (fake *FakeReleaseCreatingCmd) RunCallCount() int { return len(fake.runArgsForCall) } +func (fake *FakeReleaseCreatingCmd) RunCalls(stub func(opts.CreateReleaseOpts) (release.Release, error)) { + fake.runMutex.Lock() + defer fake.runMutex.Unlock() + fake.RunStub = stub +} + func (fake *FakeReleaseCreatingCmd) RunArgsForCall(i int) opts.CreateReleaseOpts { fake.runMutex.RLock() defer fake.runMutex.RUnlock() - return fake.runArgsForCall[i].arg1 + argsForCall := fake.runArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeReleaseCreatingCmd) RunReturns(result1 boshrel.Release, result2 error) { +func (fake *FakeReleaseCreatingCmd) RunReturns(result1 release.Release, result2 error) { + fake.runMutex.Lock() + defer fake.runMutex.Unlock() fake.RunStub = nil fake.runReturns = struct { - result1 boshrel.Release + result1 release.Release result2 error }{result1, result2} } -func (fake *FakeReleaseCreatingCmd) RunReturnsOnCall(i int, result1 boshrel.Release, result2 error) { +func (fake *FakeReleaseCreatingCmd) RunReturnsOnCall(i int, result1 release.Release, result2 error) { + fake.runMutex.Lock() + defer fake.runMutex.Unlock() fake.RunStub = nil if fake.runReturnsOnCall == nil { fake.runReturnsOnCall = make(map[int]struct { - result1 boshrel.Release + result1 release.Release result2 error }) } fake.runReturnsOnCall[i] = struct { - result1 boshrel.Release + result1 release.Release result2 error }{result1, result2} } @@ -83,7 +96,11 @@ func (fake *FakeReleaseCreatingCmd) Invocations() map[string][][]interface{} { defer fake.invocationsMutex.RUnlock() fake.runMutex.RLock() defer fake.runMutex.RUnlock() - return fake.invocations + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeReleaseCreatingCmd) recordInvocation(key string, args []interface{}) { diff --git a/cmd/cmdfakes/fake_release_uploader.go b/cmd/cmdfakes/fake_release_uploader.go index 85199469e..3f51c9eb1 100644 --- a/cmd/cmdfakes/fake_release_uploader.go +++ b/cmd/cmdfakes/fake_release_uploader.go @@ -49,15 +49,16 @@ func (fake *FakeReleaseUploader) UploadReleases(arg1 []byte) ([]byte, error) { fake.uploadReleasesArgsForCall = append(fake.uploadReleasesArgsForCall, struct { arg1 []byte }{arg1Copy}) + stub := fake.UploadReleasesStub + fakeReturns := fake.uploadReleasesReturns fake.recordInvocation("UploadReleases", []interface{}{arg1Copy}) fake.uploadReleasesMutex.Unlock() - if fake.UploadReleasesStub != nil { - return fake.UploadReleasesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.uploadReleasesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -117,15 +118,16 @@ func (fake *FakeReleaseUploader) UploadReleasesWithFix(arg1 []byte) ([]byte, err fake.uploadReleasesWithFixArgsForCall = append(fake.uploadReleasesWithFixArgsForCall, struct { arg1 []byte }{arg1Copy}) + stub := fake.UploadReleasesWithFixStub + fakeReturns := fake.uploadReleasesWithFixReturns fake.recordInvocation("UploadReleasesWithFix", []interface{}{arg1Copy}) fake.uploadReleasesWithFixMutex.Unlock() - if fake.UploadReleasesWithFixStub != nil { - return fake.UploadReleasesWithFixStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.uploadReleasesWithFixReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cmd/cmdfakes/fake_release_uploading_cmd.go b/cmd/cmdfakes/fake_release_uploading_cmd.go index a7bc6cee1..f7ad818be 100644 --- a/cmd/cmdfakes/fake_release_uploading_cmd.go +++ b/cmd/cmdfakes/fake_release_uploading_cmd.go @@ -30,15 +30,17 @@ func (fake *FakeReleaseUploadingCmd) Run(arg1 opts.UploadReleaseOpts) error { fake.runArgsForCall = append(fake.runArgsForCall, struct { arg1 opts.UploadReleaseOpts }{arg1}) + stub := fake.RunStub + fakeReturns := fake.runReturns fake.recordInvocation("Run", []interface{}{arg1}) fake.runMutex.Unlock() - if fake.RunStub != nil { - return fake.RunStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - return fake.runReturns.result1 + return fakeReturns.result1 } func (fake *FakeReleaseUploadingCmd) RunCallCount() int { @@ -47,13 +49,22 @@ func (fake *FakeReleaseUploadingCmd) RunCallCount() int { return len(fake.runArgsForCall) } +func (fake *FakeReleaseUploadingCmd) RunCalls(stub func(opts.UploadReleaseOpts) error) { + fake.runMutex.Lock() + defer fake.runMutex.Unlock() + fake.RunStub = stub +} + func (fake *FakeReleaseUploadingCmd) RunArgsForCall(i int) opts.UploadReleaseOpts { fake.runMutex.RLock() defer fake.runMutex.RUnlock() - return fake.runArgsForCall[i].arg1 + argsForCall := fake.runArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeReleaseUploadingCmd) RunReturns(result1 error) { + fake.runMutex.Lock() + defer fake.runMutex.Unlock() fake.RunStub = nil fake.runReturns = struct { result1 error @@ -61,6 +72,8 @@ func (fake *FakeReleaseUploadingCmd) RunReturns(result1 error) { } func (fake *FakeReleaseUploadingCmd) RunReturnsOnCall(i int, result1 error) { + fake.runMutex.Lock() + defer fake.runMutex.Unlock() fake.RunStub = nil if fake.runReturnsOnCall == nil { fake.runReturnsOnCall = make(map[int]struct { @@ -77,7 +90,11 @@ func (fake *FakeReleaseUploadingCmd) Invocations() map[string][][]interface{} { defer fake.invocationsMutex.RUnlock() fake.runMutex.RLock() defer fake.runMutex.RUnlock() - return fake.invocations + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeReleaseUploadingCmd) recordInvocation(key string, args []interface{}) { diff --git a/cmd/config_diff_table.go b/cmd/config_diff_table.go index 06e1741ae..5ef0aab8a 100644 --- a/cmd/config_diff_table.go +++ b/cmd/config_diff_table.go @@ -1,18 +1,18 @@ package cmd import ( - . "github.com/cloudfoundry/bosh-cli/cmd/opts" + boshcmd "github.com/cloudfoundry/bosh-cli/cmd/opts" boshui "github.com/cloudfoundry/bosh-cli/ui" boshtbl "github.com/cloudfoundry/bosh-cli/ui/table" ) type ConfigDiffTable struct { diff Diff - opts DiffConfigOpts + opts boshcmd.DiffConfigOpts ui boshui.UI } -func NewConfigDiffTable(diff Diff, opts DiffConfigOpts, ui boshui.UI) ConfigDiffTable { +func NewConfigDiffTable(diff Diff, opts boshcmd.DiffConfigOpts, ui boshui.UI) ConfigDiffTable { return ConfigDiffTable{diff, opts, ui} } diff --git a/cmd/create_env_test.go b/cmd/create_env_test.go index e31bed8fa..5d7785fc2 100644 --- a/cmd/create_env_test.go +++ b/cmd/create_env_test.go @@ -42,7 +42,6 @@ import ( fakebiinstallmanifest "github.com/cloudfoundry/bosh-cli/installation/manifest/fakes" mock_install "github.com/cloudfoundry/bosh-cli/installation/mocks" bitarball "github.com/cloudfoundry/bosh-cli/installation/tarball" - mock_registry "github.com/cloudfoundry/bosh-cli/registry/mocks" boshrel "github.com/cloudfoundry/bosh-cli/release" bireljob "github.com/cloudfoundry/bosh-cli/release/job" birelmanifest "github.com/cloudfoundry/bosh-cli/release/manifest" @@ -86,17 +85,16 @@ var _ = Describe("CreateEnvCmd", func() { userInterface biui.UI manifestSHA string - mockDeployer *mock_deployment.MockDeployer - mockInstaller *mock_install.MockInstaller - mockInstallerFactory *mock_install.MockInstallerFactory - releaseReader *fakerel.FakeReader - releaseManager biinstall.ReleaseManager - mockRegistryServerManager *mock_registry.MockServerManager - mockRegistryServer *mock_registry.MockServer - mockAgentClient *mock_agentclient.MockAgentClient - mockAgentClientFactory *mock_httpagent.MockAgentClientFactory - mockCloudFactory *mock_cloud.MockFactory - mockCloud *mock_cloud.MockCloud + mockDeployer *mock_deployment.MockDeployer + mockInstaller *mock_install.MockInstaller + mockInstallerFactory *mock_install.MockInstallerFactory + releaseReader *fakerel.FakeReader + releaseManager biinstall.ReleaseManager + + mockAgentClient *mock_agentclient.MockAgentClient + mockAgentClientFactory *mock_httpagent.MockAgentClientFactory + mockCloudFactory *mock_cloud.MockFactory + mockCloud *mock_cloud.MockCloud cpiRelease *fakebirel.FakeRelease logger boshlog.Logger @@ -150,8 +148,7 @@ var _ = Describe("CreateEnvCmd", func() { expectInstall *gomock.Call expectNewCloud *gomock.Call - expectedRegistryConfig biinstallmanifest.Registry - expectedDeployError error + expectedDeployError error ) BeforeEach(func() { @@ -178,9 +175,6 @@ var _ = Describe("CreateEnvCmd", func() { releaseReader = &fakerel.FakeReader{} releaseManager = biinstall.NewReleaseManager(logger) - mockRegistryServerManager = mock_registry.NewMockServerManager(mockCtrl) - mockRegistryServer = mock_registry.NewMockServer(mockCtrl) - mockAgentClientFactory = mock_httpagent.NewMockAgentClientFactory(mockCtrl) mockAgentClient = mock_agentclient.NewMockAgentClient(mockCtrl) mockAgentClientFactory.EXPECT().NewAgentClient(gomock.Any(), gomock.Any(), gomock.Any()).Return(mockAgentClient, nil).AnyTimes() @@ -260,8 +254,6 @@ var _ = Describe("CreateEnvCmd", func() { Mbus: mbusURL, } - expectedRegistryConfig = installationManifest.Registry - // parsed BOSH deployment manifest boshDeploymentManifest = bideplmanifest.Manifest{ Name: "fake-deployment-name", @@ -433,7 +425,7 @@ var _ = Describe("CreateEnvCmd", func() { mockInstallerFactory.EXPECT().NewInstaller(target).Return(mockInstaller).AnyTimes() - installation := biinstall.NewInstallation(target, installedJob, installationManifest, mockRegistryServerManager) + installation := biinstall.NewInstallation(target, installedJob, installationManifest) expectInstall = mockInstaller.EXPECT().Install(installationManifest, gomock.Any()).Do(func(_ interface{}, stage biui.Stage) { Expect(fakeStage.SubStages).To(ContainElement(stage)) @@ -446,12 +438,11 @@ var _ = Describe("CreateEnvCmd", func() { mockCloud, boshDeploymentManifest, cloudStemcell, - expectedRegistryConfig, fakeVMManager, mockBlobstore, expectedSkipDrain, gomock.Any(), - ).Do(func(_, _, _, _, _, _, _ interface{}, stage biui.Stage) { + ).Do(func(_, _, _, _, _, _ interface{}, stage biui.Stage) { Expect(fakeStage.SubStages).To(ContainElement(stage)) }).Return(nil, expectedDeployError).AnyTimes() @@ -598,79 +589,6 @@ var _ = Describe("CreateEnvCmd", func() { })) }) - Context("when the registry is configured", func() { - BeforeEach(func() { - installationManifest.Registry = biinstallmanifest.Registry{ - Username: "fake-username", - Password: "fake-password", - Host: "fake-host", - Port: 123, - } - expectedRegistryConfig = biinstallmanifest.Registry{} - }) - - It("should not start or attempt to stop the registry", func() { - mockRegistryServerManager.EXPECT().Start(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(0) - mockRegistryServer.EXPECT().Stop().Times(0) - - err := command.Run(fakeStage, defaultCreateEnvOpts) - Expect(err).NotTo(HaveOccurred()) - }) - - itStartsStopsRegistry := func() { - It("starts & stops the registry", func() { - mockRegistryServerManager.EXPECT().Start("fake-username", "fake-password", "fake-host", 123).Return(mockRegistryServer, nil) - mockRegistryServer.EXPECT().Stop() - - err := command.Run(fakeStage, defaultCreateEnvOpts) - Expect(err).NotTo(HaveOccurred()) - }) - - It("adds a new 'Starting registry' event logger stage", func() { - mockRegistryServerManager.EXPECT().Start("fake-username", "fake-password", "fake-host", 123).Return(mockRegistryServer, nil) - mockRegistryServer.EXPECT().Stop() - - err := command.Run(fakeStage, defaultCreateEnvOpts) - Expect(err).NotTo(HaveOccurred()) - - Expect(fakeStage.PerformCalls[2]).To(Equal(&fakebiui.PerformCall{ - Name: "Starting registry", - })) - }) - } - - Context("when stemcell version is 1", func() { - BeforeEach(func() { - stemcellApiVersion = 1 - - expectedRegistryConfig = biinstallmanifest.Registry{ - Username: "fake-username", - Password: "fake-password", - Host: "fake-host", - Port: 123, - } - }) - - itStartsStopsRegistry() - }) - - Context("when stemcell is 2 but cpi version is 1", func() { - BeforeEach(func() { - stemcellApiVersion = 2 - cpiApiVersion = 1 - - expectedRegistryConfig = biinstallmanifest.Registry{ - Username: "fake-username", - Password: "fake-password", - Host: "fake-host", - Port: 123, - } - }) - - itStartsStopsRegistry() - }) - }) - It("deletes the extracted CPI release", func() { err := command.Run(fakeStage, defaultCreateEnvOpts) Expect(err).NotTo(HaveOccurred()) @@ -1138,7 +1056,6 @@ var _ = Describe("CreateEnvCmd", func() { mockCloud, boshDeploymentManifest, cloudStemcell, - installationManifest.Registry, fakeVMManager, mockBlobstore, expectedSkipDrain, diff --git a/cmd/deployment_deleter.go b/cmd/deployment_deleter.go index d83c9c0e6..11573656e 100644 --- a/cmd/deployment_deleter.go +++ b/cmd/deployment_deleter.go @@ -146,21 +146,19 @@ func (c *deploymentDeleter) DeleteDeployment(skipDrain bool, stage biui.Stage) ( } err = c.cpiInstaller.WithInstalledCpiRelease(installationManifest, target, stage, func(localCpiInstallation biinstall.Installation) error { - return localCpiInstallation.WithRunningRegistry(c.logger, stage, func() error { - err = c.findAndDeleteDeployment(skipDrain, stage, localCpiInstallation, deploymentState.DirectorID, installationManifest.Mbus, installationManifest.Cert.CA) + err = c.findAndDeleteDeployment(skipDrain, stage, localCpiInstallation, deploymentState.DirectorID, installationManifest.Mbus, installationManifest.Cert.CA) + if err != nil { + return err + } + + return stage.Perform("Uninstalling local artifacts for CPI and deployment", func() error { + err := c.cpiUninstaller.Uninstall(localCpiInstallation.Target()) if err != nil { return err } - return stage.Perform("Uninstalling local artifacts for CPI and deployment", func() error { - err := c.cpiUninstaller.Uninstall(localCpiInstallation.Target()) - if err != nil { - return err - } - - return c.deploymentStateService.Cleanup() - }) + return c.deploymentStateService.Cleanup() }) }) diff --git a/cmd/deployment_preparer.go b/cmd/deployment_preparer.go index a1e390e8d..a283cf6b4 100644 --- a/cmd/deployment_preparer.go +++ b/cmd/deployment_preparer.go @@ -197,7 +197,7 @@ func (c *DeploymentPreparer) PrepareDeployment(stage biui.Stage, recreate bool, return bosherr.WrapError(err, "Creating CPI client from CPI installation") } - deploy := func(usesRegistry bool) error { + deploy := func() error { return c.deploy( installation, deploymentState, @@ -208,7 +208,7 @@ func (c *DeploymentPreparer) PrepareDeployment(stage biui.Stage, recreate bool, skipDrain, stage, cloud, - usesRegistry) + ) } cpiInfo, err := cloud.Info() @@ -218,11 +218,9 @@ func (c *DeploymentPreparer) PrepareDeployment(stage biui.Stage, recreate bool, if stemcellApiVersion >= bicloud.StemcellNoRegistryAsOfVersion && cpiInfo.ApiVersion == bicloud.MaxCpiApiVersionSupported { - return deploy(false) + return deploy() } else { - return installation.WithRunningRegistry(c.logger, stage, func() error { - return deploy(true) - }) + return bosherr.Errorf("Registry is not supported anymore") } }) return err @@ -238,7 +236,6 @@ func (c *DeploymentPreparer) deploy( skipDrain bool, stage biui.Stage, cloud bicloud.Cloud, - usesRegistry bool, ) (err error) { stemcellManager := c.stemcellManagerFactory.NewManager(cloud) @@ -264,16 +261,10 @@ func (c *DeploymentPreparer) deploy( return bosherr.WrapError(err, "Clearing deployment record") } - registrySettings := installationManifest.Registry - if !usesRegistry { - registrySettings = biinstallmanifest.Registry{} - } - _, err = c.deployer.Deploy( cloud, deploymentManifest, cloudStemcell, - registrySettings, vmManager, blobstore, skipDrain, diff --git a/cmd/env_factory.go b/cmd/env_factory.go index 0eaa849c1..d9e387380 100644 --- a/cmd/env_factory.go +++ b/cmd/env_factory.go @@ -26,7 +26,6 @@ import ( boshinst "github.com/cloudfoundry/bosh-cli/installation" boshinstmanifest "github.com/cloudfoundry/bosh-cli/installation/manifest" bitarball "github.com/cloudfoundry/bosh-cli/installation/tarball" - biregistry "github.com/cloudfoundry/bosh-cli/registry" boshrel "github.com/cloudfoundry/bosh-cli/release" birelsetmanifest "github.com/cloudfoundry/bosh-cli/release/set/manifest" bistatepkg "github.com/cloudfoundry/bosh-cli/state/pkg" @@ -116,10 +115,9 @@ func NewEnvFactory( deps.FS, deps.UUIDGen, deps.Logger, biconfig.DeploymentStatePath(manifestPath, statePath)) { - registryServer := biregistry.NewServerManager(deps.Logger) installerFactory := boshinst.NewInstallerFactory( deps.UI, deps.CmdRunner, deps.Compressor, releaseJobResolver, - deps.UUIDGen, registryServer, deps.Logger, deps.FS, deps.DigestCreationAlgorithms) + deps.UUIDGen, deps.Logger, deps.FS, deps.DigestCreationAlgorithms) f.cpiInstaller = bicpirel.CpiInstaller{ ReleaseManager: f.releaseManager, diff --git a/cmd/mocks/mocks.go b/cmd/mocks/mocks.go index f4971d58b..892a92843 100644 --- a/cmd/mocks/mocks.go +++ b/cmd/mocks/mocks.go @@ -5,35 +5,36 @@ package mocks import ( + reflect "reflect" + ui "github.com/cloudfoundry/bosh-cli/ui" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockDeploymentDeleter is a mock of DeploymentDeleter interface +// MockDeploymentDeleter is a mock of DeploymentDeleter interface. type MockDeploymentDeleter struct { ctrl *gomock.Controller recorder *MockDeploymentDeleterMockRecorder } -// MockDeploymentDeleterMockRecorder is the mock recorder for MockDeploymentDeleter +// MockDeploymentDeleterMockRecorder is the mock recorder for MockDeploymentDeleter. type MockDeploymentDeleterMockRecorder struct { mock *MockDeploymentDeleter } -// NewMockDeploymentDeleter creates a new mock instance +// NewMockDeploymentDeleter creates a new mock instance. func NewMockDeploymentDeleter(ctrl *gomock.Controller) *MockDeploymentDeleter { mock := &MockDeploymentDeleter{ctrl: ctrl} mock.recorder = &MockDeploymentDeleterMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockDeploymentDeleter) EXPECT() *MockDeploymentDeleterMockRecorder { return m.recorder } -// DeleteDeployment mocks base method +// DeleteDeployment mocks base method. func (m *MockDeploymentDeleter) DeleteDeployment(arg0 bool, arg1 ui.Stage) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteDeployment", arg0, arg1) @@ -41,36 +42,36 @@ func (m *MockDeploymentDeleter) DeleteDeployment(arg0 bool, arg1 ui.Stage) error return ret0 } -// DeleteDeployment indicates an expected call of DeleteDeployment +// DeleteDeployment indicates an expected call of DeleteDeployment. func (mr *MockDeploymentDeleterMockRecorder) DeleteDeployment(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteDeployment", reflect.TypeOf((*MockDeploymentDeleter)(nil).DeleteDeployment), arg0, arg1) } -// MockDeploymentStateManager is a mock of DeploymentStateManager interface +// MockDeploymentStateManager is a mock of DeploymentStateManager interface. type MockDeploymentStateManager struct { ctrl *gomock.Controller recorder *MockDeploymentStateManagerMockRecorder } -// MockDeploymentStateManagerMockRecorder is the mock recorder for MockDeploymentStateManager +// MockDeploymentStateManagerMockRecorder is the mock recorder for MockDeploymentStateManager. type MockDeploymentStateManagerMockRecorder struct { mock *MockDeploymentStateManager } -// NewMockDeploymentStateManager creates a new mock instance +// NewMockDeploymentStateManager creates a new mock instance. func NewMockDeploymentStateManager(ctrl *gomock.Controller) *MockDeploymentStateManager { mock := &MockDeploymentStateManager{ctrl: ctrl} mock.recorder = &MockDeploymentStateManagerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockDeploymentStateManager) EXPECT() *MockDeploymentStateManagerMockRecorder { return m.recorder } -// StartDeployment mocks base method +// StartDeployment mocks base method. func (m *MockDeploymentStateManager) StartDeployment(arg0 ui.Stage) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StartDeployment", arg0) @@ -78,13 +79,13 @@ func (m *MockDeploymentStateManager) StartDeployment(arg0 ui.Stage) error { return ret0 } -// StartDeployment indicates an expected call of StartDeployment +// StartDeployment indicates an expected call of StartDeployment. func (mr *MockDeploymentStateManagerMockRecorder) StartDeployment(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartDeployment", reflect.TypeOf((*MockDeploymentStateManager)(nil).StartDeployment), arg0) } -// StopDeployment mocks base method +// StopDeployment mocks base method. func (m *MockDeploymentStateManager) StopDeployment(arg0 bool, arg1 ui.Stage) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StopDeployment", arg0, arg1) @@ -92,7 +93,7 @@ func (m *MockDeploymentStateManager) StopDeployment(arg0 bool, arg1 ui.Stage) er return ret0 } -// StopDeployment indicates an expected call of StopDeployment +// StopDeployment indicates an expected call of StopDeployment. func (mr *MockDeploymentStateManagerMockRecorder) StopDeployment(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StopDeployment", reflect.TypeOf((*MockDeploymentStateManager)(nil).StopDeployment), arg0, arg1) diff --git a/config/deployment_repo_test.go b/config/deployment_repo_test.go index a67d685ef..e67448174 100644 --- a/config/deployment_repo_test.go +++ b/config/deployment_repo_test.go @@ -1,7 +1,7 @@ package config_test import ( - . "github.com/cloudfoundry/bosh-cli/config" + biconfig "github.com/cloudfoundry/bosh-cli/config" boshlog "github.com/cloudfoundry/bosh-utils/logger" fakesys "github.com/cloudfoundry/bosh-utils/system/fakes" fakeuuid "github.com/cloudfoundry/bosh-utils/uuid/fakes" @@ -11,8 +11,8 @@ import ( var _ = Describe("DeploymentRepo", func() { var ( - repo DeploymentRepo - deploymentStateService DeploymentStateService + repo biconfig.DeploymentRepo + deploymentStateService biconfig.DeploymentStateService fs *fakesys.FakeFileSystem fakeUUIDGenerator *fakeuuid.FakeGenerator ) @@ -21,8 +21,8 @@ var _ = Describe("DeploymentRepo", func() { logger := boshlog.NewLogger(boshlog.LevelNone) fs = fakesys.NewFakeFileSystem() fakeUUIDGenerator = fakeuuid.NewFakeGenerator() - deploymentStateService = NewFileSystemDeploymentStateService(fs, fakeUUIDGenerator, logger, "/fake/path") - repo = NewDeploymentRepo(deploymentStateService) + deploymentStateService = biconfig.NewFileSystemDeploymentStateService(fs, fakeUUIDGenerator, logger, "/fake/path") + repo = biconfig.NewDeploymentRepo(deploymentStateService) }) Describe("UpdateCurrent", func() { @@ -33,7 +33,7 @@ var _ = Describe("DeploymentRepo", func() { deploymentState, err := deploymentStateService.Load() Expect(err).ToNot(HaveOccurred()) - expectedConfig := DeploymentState{ + expectedConfig := biconfig.DeploymentState{ DirectorID: "fake-uuid-0", CurrentManifestSHA: "fake-manifest-sha1", } diff --git a/config/mocks/mocks.go b/config/mocks/mocks.go index 5931d8ffa..c9e32f7ad 100644 --- a/config/mocks/mocks.go +++ b/config/mocks/mocks.go @@ -5,34 +5,35 @@ package mocks import ( - gomock "github.com/golang/mock/gomock" reflect "reflect" + + gomock "github.com/golang/mock/gomock" ) -// MockLegacyDeploymentStateMigrator is a mock of LegacyDeploymentStateMigrator interface +// MockLegacyDeploymentStateMigrator is a mock of LegacyDeploymentStateMigrator interface. type MockLegacyDeploymentStateMigrator struct { ctrl *gomock.Controller recorder *MockLegacyDeploymentStateMigratorMockRecorder } -// MockLegacyDeploymentStateMigratorMockRecorder is the mock recorder for MockLegacyDeploymentStateMigrator +// MockLegacyDeploymentStateMigratorMockRecorder is the mock recorder for MockLegacyDeploymentStateMigrator. type MockLegacyDeploymentStateMigratorMockRecorder struct { mock *MockLegacyDeploymentStateMigrator } -// NewMockLegacyDeploymentStateMigrator creates a new mock instance +// NewMockLegacyDeploymentStateMigrator creates a new mock instance. func NewMockLegacyDeploymentStateMigrator(ctrl *gomock.Controller) *MockLegacyDeploymentStateMigrator { mock := &MockLegacyDeploymentStateMigrator{ctrl: ctrl} mock.recorder = &MockLegacyDeploymentStateMigratorMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockLegacyDeploymentStateMigrator) EXPECT() *MockLegacyDeploymentStateMigratorMockRecorder { return m.recorder } -// MigrateIfExists mocks base method +// MigrateIfExists mocks base method. func (m *MockLegacyDeploymentStateMigrator) MigrateIfExists(arg0 string) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MigrateIfExists", arg0) @@ -41,7 +42,7 @@ func (m *MockLegacyDeploymentStateMigrator) MigrateIfExists(arg0 string) (bool, return ret0, ret1 } -// MigrateIfExists indicates an expected call of MigrateIfExists +// MigrateIfExists indicates an expected call of MigrateIfExists. func (mr *MockLegacyDeploymentStateMigratorMockRecorder) MigrateIfExists(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MigrateIfExists", reflect.TypeOf((*MockLegacyDeploymentStateMigrator)(nil).MigrateIfExists), arg0) diff --git a/deployment/deployer.go b/deployment/deployer.go index d71af2870..8862898a0 100644 --- a/deployment/deployer.go +++ b/deployment/deployer.go @@ -9,7 +9,6 @@ import ( biinstance "github.com/cloudfoundry/bosh-cli/deployment/instance" bideplmanifest "github.com/cloudfoundry/bosh-cli/deployment/manifest" bivm "github.com/cloudfoundry/bosh-cli/deployment/vm" - biinstallmanifest "github.com/cloudfoundry/bosh-cli/installation/manifest" bistemcell "github.com/cloudfoundry/bosh-cli/stemcell" biui "github.com/cloudfoundry/bosh-cli/ui" bosherr "github.com/cloudfoundry/bosh-utils/errors" @@ -21,7 +20,6 @@ type Deployer interface { bicloud.Cloud, bideplmanifest.Manifest, bistemcell.CloudStemcell, - biinstallmanifest.Registry, bivm.Manager, biblobstore.Blobstore, bool, @@ -56,7 +54,6 @@ func (d *deployer) Deploy( cloud bicloud.Cloud, deploymentManifest bideplmanifest.Manifest, cloudStemcell bistemcell.CloudStemcell, - registryConfig biinstallmanifest.Registry, vmManager bivm.Manager, blobstore biblobstore.Blobstore, skipDrain bool, @@ -70,7 +67,7 @@ func (d *deployer) Deploy( return nil, err } - instances, disks, err := d.createAllInstances(deploymentManifest, instanceManager, cloudStemcell, registryConfig, deployStage) + instances, disks, err := d.createAllInstances(deploymentManifest, instanceManager, cloudStemcell, deployStage) if err != nil { return nil, err } @@ -83,7 +80,6 @@ func (d *deployer) createAllInstances( deploymentManifest bideplmanifest.Manifest, instanceManager biinstance.Manager, cloudStemcell bistemcell.CloudStemcell, - registryConfig biinstallmanifest.Registry, deployStage biui.Stage, ) ([]biinstance.Instance, []bidisk.Disk, error) { instances := []biinstance.Instance{} @@ -98,7 +94,7 @@ func (d *deployer) createAllInstances( return instances, disks, bosherr.Errorf("Job '%s' must have only one instance, found %d", jobSpec.Name, jobSpec.Instances) } for instanceID := 0; instanceID < jobSpec.Instances; instanceID++ { - instance, instanceDisks, err := instanceManager.Create(jobSpec.Name, instanceID, deploymentManifest, cloudStemcell, registryConfig, deployStage) + instance, instanceDisks, err := instanceManager.Create(jobSpec.Name, instanceID, deploymentManifest, cloudStemcell, deployStage) if err != nil { return instances, disks, bosherr.WrapErrorf(err, "Creating instance '%s/%d'", jobSpec.Name, instanceID) } diff --git a/deployment/deployer_test.go b/deployment/deployer_test.go index 06831cc2d..4f1f21d0e 100644 --- a/deployment/deployer_test.go +++ b/deployment/deployer_test.go @@ -1,7 +1,6 @@ package deployment_test import ( - "errors" "time" . "github.com/cloudfoundry/bosh-cli/deployment" @@ -19,8 +18,6 @@ import ( biconfig "github.com/cloudfoundry/bosh-cli/config" biinstance "github.com/cloudfoundry/bosh-cli/deployment/instance" bideplmanifest "github.com/cloudfoundry/bosh-cli/deployment/manifest" - bisshtunnel "github.com/cloudfoundry/bosh-cli/deployment/sshtunnel" - biinstallmanifest "github.com/cloudfoundry/bosh-cli/installation/manifest" bistemcell "github.com/cloudfoundry/bosh-cli/stemcell" bosherr "github.com/cloudfoundry/bosh-utils/errors" boshlog "github.com/cloudfoundry/bosh-utils/logger" @@ -56,7 +53,6 @@ var _ = Describe("Deployer", func() { cloud *fakebicloud.FakeCloud deploymentManifest bideplmanifest.Manifest diskPool bideplmanifest.DiskPool - registryConfig biinstallmanifest.Registry fakeStage *fakebiui.FakeStage fakeVM *fakebivm.FakeVM skipDrain bool @@ -98,15 +94,6 @@ var _ = Describe("Deployer", func() { }, }, } - registryConfig = biinstallmanifest.Registry{ - SSHTunnel: biinstallmanifest.SSHTunnel{ - User: "fake-ssh-username", - PrivateKey: "---BEGIN PRIVATE KEY--- qwerty ---END PRIVATE KEY---", - Password: "fake-password", - Host: "fake-ssh-host", - Port: 124, - }, - } skipDrain = false cloud = fakebicloud.NewFakeCloud() @@ -193,7 +180,7 @@ var _ = Describe("Deployer", func() { }) It("deletes existing vm", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) + _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, fakeVMManager, mockBlobstore, skipDrain, fakeStage) Expect(err).NotTo(HaveOccurred()) Expect(fakeExistingVM.DeleteCalled).To(Equal(1)) @@ -211,7 +198,7 @@ var _ = Describe("Deployer", func() { Context("when skip-drain is specified", func() { It("skips draining", func() { skipDrain = true - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) + _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, fakeVMManager, mockBlobstore, skipDrain, fakeStage) Expect(err).NotTo(HaveOccurred()) Expect(fakeExistingVM.DeleteCalled).To(Equal(1)) @@ -228,7 +215,7 @@ var _ = Describe("Deployer", func() { }) It("creates a vm", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) + _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, fakeVMManager, mockBlobstore, skipDrain, fakeStage) Expect(err).NotTo(HaveOccurred()) Expect(fakeVMManager.CreateInput).To(Equal(fakebivm.CreateInput{ @@ -237,53 +224,8 @@ var _ = Describe("Deployer", func() { })) }) - Context("when registry & ssh tunnel configs are not empty", func() { - BeforeEach(func() { - registryConfig = biinstallmanifest.Registry{ - Username: "fake-username", - Password: "fake-password", - Host: "fake-host", - Port: 123, - SSHTunnel: biinstallmanifest.SSHTunnel{ - User: "fake-ssh-username", - PrivateKey: "---BEGIN PRIVATE KEY--- huzzah! ---END PRIVATE KEY---", - Password: "fake-password", - Host: "fake-ssh-host", - Port: 124, - }, - } - }) - - It("starts the SSH tunnel", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) - Expect(err).NotTo(HaveOccurred()) - Expect(fakeSSHTunnel.Started).To(BeTrue()) - Expect(fakeSSHTunnelFactory.NewSSHTunnelOptions).To(Equal(bisshtunnel.Options{ - User: "fake-ssh-username", - PrivateKey: "---BEGIN PRIVATE KEY--- huzzah! ---END PRIVATE KEY---", - Password: "fake-password", - Host: "fake-ssh-host", - Port: 124, - LocalForwardPort: 123, - RemoteForwardPort: 123, - })) - }) - - Context("when starting SSH tunnel fails", func() { - BeforeEach(func() { - fakeSSHTunnel.SetStartBehavior(errors.New("fake-ssh-tunnel-start-error"), nil) - }) - - It("returns an error", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("fake-ssh-tunnel-start-error")) - }) - }) - }) - It("waits for the vm", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) + _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, fakeVMManager, mockBlobstore, skipDrain, fakeStage) Expect(err).NotTo(HaveOccurred()) Expect(fakeVM.WaitUntilReadyInputs).To(ContainElement(fakebivm.WaitUntilReadyInput{ Timeout: 10 * time.Minute, @@ -292,7 +234,7 @@ var _ = Describe("Deployer", func() { }) It("logs start and stop events to the eventLogger", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) + _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, fakeVMManager, mockBlobstore, skipDrain, fakeStage) Expect(err).NotTo(HaveOccurred()) Expect(fakeStage.PerformCalls[1]).To(Equal(&fakebiui.PerformCall{ @@ -310,7 +252,7 @@ var _ = Describe("Deployer", func() { }) It("logs start and stop events to the eventLogger", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) + _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, fakeVMManager, mockBlobstore, skipDrain, fakeStage) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("fake-wait-error")) @@ -322,7 +264,7 @@ var _ = Describe("Deployer", func() { }) It("updates the vm", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) + _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, fakeVMManager, mockBlobstore, skipDrain, fakeStage) Expect(err).NotTo(HaveOccurred()) Expect(fakeVM.ApplyInputs).To(Equal([]fakebivm.ApplyInput{ @@ -332,14 +274,14 @@ var _ = Describe("Deployer", func() { }) It("starts the agent", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) + _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, fakeVMManager, mockBlobstore, skipDrain, fakeStage) Expect(err).NotTo(HaveOccurred()) Expect(fakeVM.StartCalled).To(Equal(1)) }) It("waits until agent reports state as running", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) + _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, fakeVMManager, mockBlobstore, skipDrain, fakeStage) Expect(err).NotTo(HaveOccurred()) Expect(fakeVM.WaitToBeRunningInputs).To(ContainElement(fakebivm.WaitInput{ @@ -354,13 +296,13 @@ var _ = Describe("Deployer", func() { }) It("returns an error", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) + _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, fakeVMManager, mockBlobstore, skipDrain, fakeStage) Expect(err).To(HaveOccurred()) }) }) It("logs instance update ui stages", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) + _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, fakeVMManager, mockBlobstore, skipDrain, fakeStage) Expect(err).NotTo(HaveOccurred()) Expect(fakeStage.PerformCalls[2:4]).To(Equal([]*fakebiui.PerformCall{ @@ -375,7 +317,7 @@ var _ = Describe("Deployer", func() { }) It("fails with descriptive error", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) + _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, fakeVMManager, mockBlobstore, skipDrain, fakeStage) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(Equal("Applying the initial agent state: fake-apply-error")) }) @@ -387,7 +329,7 @@ var _ = Describe("Deployer", func() { }) It("logs start and stop events to the eventLogger", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) + _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, fakeVMManager, mockBlobstore, skipDrain, fakeStage) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("fake-start-error")) @@ -407,7 +349,7 @@ var _ = Describe("Deployer", func() { }) It("logs start and stop events to the eventLogger", func() { - _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, registryConfig, fakeVMManager, mockBlobstore, skipDrain, fakeStage) + _, err := deployer.Deploy(cloud, deploymentManifest, cloudStemcell, fakeVMManager, mockBlobstore, skipDrain, fakeStage) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("fake-wait-running-error")) diff --git a/deployment/disk/mocks/mocks.go b/deployment/disk/mocks/mocks.go index 9015d08e2..229ff74dd 100644 --- a/deployment/disk/mocks/mocks.go +++ b/deployment/disk/mocks/mocks.go @@ -5,38 +5,39 @@ package mocks import ( + reflect "reflect" + disk "github.com/cloudfoundry/bosh-cli/deployment/disk" manifest "github.com/cloudfoundry/bosh-cli/deployment/manifest" ui "github.com/cloudfoundry/bosh-cli/ui" property "github.com/cloudfoundry/bosh-utils/property" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockDisk is a mock of Disk interface +// MockDisk is a mock of Disk interface. type MockDisk struct { ctrl *gomock.Controller recorder *MockDiskMockRecorder } -// MockDiskMockRecorder is the mock recorder for MockDisk +// MockDiskMockRecorder is the mock recorder for MockDisk. type MockDiskMockRecorder struct { mock *MockDisk } -// NewMockDisk creates a new mock instance +// NewMockDisk creates a new mock instance. func NewMockDisk(ctrl *gomock.Controller) *MockDisk { mock := &MockDisk{ctrl: ctrl} mock.recorder = &MockDiskMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockDisk) EXPECT() *MockDiskMockRecorder { return m.recorder } -// CID mocks base method +// CID mocks base method. func (m *MockDisk) CID() string { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CID") @@ -44,13 +45,13 @@ func (m *MockDisk) CID() string { return ret0 } -// CID indicates an expected call of CID +// CID indicates an expected call of CID. func (mr *MockDiskMockRecorder) CID() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CID", reflect.TypeOf((*MockDisk)(nil).CID)) } -// Delete mocks base method +// Delete mocks base method. func (m *MockDisk) Delete() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delete") @@ -58,50 +59,51 @@ func (m *MockDisk) Delete() error { return ret0 } -// Delete indicates an expected call of Delete +// Delete indicates an expected call of Delete. func (mr *MockDiskMockRecorder) Delete() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockDisk)(nil).Delete)) } -// NeedsMigration mocks base method +// NeedsMigration mocks base method. func (m *MockDisk) NeedsMigration(arg0 int, arg1 property.Map) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NeedsMigration", arg0, arg1) ret0, _ := ret[0].(bool) - return ret0, nil + ret1, _ := ret[1].(error) + return ret0, ret1 } -// NeedsMigration indicates an expected call of NeedsMigration +// NeedsMigration indicates an expected call of NeedsMigration. func (mr *MockDiskMockRecorder) NeedsMigration(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NeedsMigration", reflect.TypeOf((*MockDisk)(nil).NeedsMigration), arg0, arg1) } -// MockManager is a mock of Manager interface +// MockManager is a mock of Manager interface. type MockManager struct { ctrl *gomock.Controller recorder *MockManagerMockRecorder } -// MockManagerMockRecorder is the mock recorder for MockManager +// MockManagerMockRecorder is the mock recorder for MockManager. type MockManagerMockRecorder struct { mock *MockManager } -// NewMockManager creates a new mock instance +// NewMockManager creates a new mock instance. func NewMockManager(ctrl *gomock.Controller) *MockManager { mock := &MockManager{ctrl: ctrl} mock.recorder = &MockManagerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockManager) EXPECT() *MockManagerMockRecorder { return m.recorder } -// Create mocks base method +// Create mocks base method. func (m *MockManager) Create(arg0 manifest.DiskPool, arg1 string) (disk.Disk, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Create", arg0, arg1) @@ -110,13 +112,13 @@ func (m *MockManager) Create(arg0 manifest.DiskPool, arg1 string) (disk.Disk, er return ret0, ret1 } -// Create indicates an expected call of Create +// Create indicates an expected call of Create. func (mr *MockManagerMockRecorder) Create(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockManager)(nil).Create), arg0, arg1) } -// DeleteUnused mocks base method +// DeleteUnused mocks base method. func (m *MockManager) DeleteUnused(arg0 ui.Stage) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteUnused", arg0) @@ -124,13 +126,13 @@ func (m *MockManager) DeleteUnused(arg0 ui.Stage) error { return ret0 } -// DeleteUnused indicates an expected call of DeleteUnused +// DeleteUnused indicates an expected call of DeleteUnused. func (mr *MockManagerMockRecorder) DeleteUnused(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteUnused", reflect.TypeOf((*MockManager)(nil).DeleteUnused), arg0) } -// FindCurrent mocks base method +// FindCurrent mocks base method. func (m *MockManager) FindCurrent() ([]disk.Disk, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindCurrent") @@ -139,13 +141,13 @@ func (m *MockManager) FindCurrent() ([]disk.Disk, error) { return ret0, ret1 } -// FindCurrent indicates an expected call of FindCurrent +// FindCurrent indicates an expected call of FindCurrent. func (mr *MockManagerMockRecorder) FindCurrent() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindCurrent", reflect.TypeOf((*MockManager)(nil).FindCurrent)) } -// FindUnused mocks base method +// FindUnused mocks base method. func (m *MockManager) FindUnused() ([]disk.Disk, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindUnused") @@ -154,7 +156,7 @@ func (m *MockManager) FindUnused() ([]disk.Disk, error) { return ret0, ret1 } -// FindUnused indicates an expected call of FindUnused +// FindUnused indicates an expected call of FindUnused. func (mr *MockManagerMockRecorder) FindUnused() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindUnused", reflect.TypeOf((*MockManager)(nil).FindUnused)) diff --git a/deployment/instance/instance.go b/deployment/instance/instance.go index 2f1110e97..4a029bb93 100644 --- a/deployment/instance/instance.go +++ b/deployment/instance/instance.go @@ -10,7 +10,6 @@ import ( bideplmanifest "github.com/cloudfoundry/bosh-cli/deployment/manifest" bisshtunnel "github.com/cloudfoundry/bosh-cli/deployment/sshtunnel" bivm "github.com/cloudfoundry/bosh-cli/deployment/vm" - biinstallmanifest "github.com/cloudfoundry/bosh-cli/installation/manifest" biui "github.com/cloudfoundry/bosh-cli/ui" bosherr "github.com/cloudfoundry/bosh-utils/errors" boshlog "github.com/cloudfoundry/bosh-utils/logger" @@ -20,7 +19,7 @@ type Instance interface { JobName() string ID() int Disks() ([]bidisk.Disk, error) - WaitUntilReady(biinstallmanifest.Registry, biui.Stage) error + WaitUntilReady(biui.Stage) error UpdateDisks(bideplmanifest.Manifest, biui.Stage) ([]bidisk.Disk, error) UpdateJobs(bideplmanifest.Manifest, biui.Stage) error Delete( @@ -92,38 +91,10 @@ func (i *instance) Disks() ([]bidisk.Disk, error) { } func (i *instance) WaitUntilReady( - registryConfig biinstallmanifest.Registry, stage biui.Stage, ) error { stepName := fmt.Sprintf("Waiting for the agent on VM '%s' to be ready", i.vm.CID()) err := stage.Perform(stepName, func() error { - if !registryConfig.IsEmpty() { - sshReadyErrCh := make(chan error) - sshErrCh := make(chan error) - - sshTunnelOptions := bisshtunnel.Options{ - Host: registryConfig.SSHTunnel.Host, - Port: registryConfig.SSHTunnel.Port, - User: registryConfig.SSHTunnel.User, - Password: registryConfig.SSHTunnel.Password, - PrivateKey: registryConfig.SSHTunnel.PrivateKey, - LocalForwardPort: registryConfig.Port, - RemoteForwardPort: registryConfig.Port, - } - sshTunnel := i.sshTunnelFactory.NewSSHTunnel(sshTunnelOptions) - go sshTunnel.Start(sshReadyErrCh, sshErrCh) - - go func() { - for sshErr := range sshErrCh { - i.logger.Warn(i.logTag, "Received SSH tunnel error: %s", sshErr) - } - }() - - err := <-sshReadyErrCh - if err != nil { - return bosherr.WrapError(err, "Starting SSH tunnel") - } - } return i.vm.WaitUntilReady(10*time.Minute, 500*time.Millisecond) }) diff --git a/deployment/instance/instance_test.go b/deployment/instance/instance_test.go index 28e35d4c2..a4c340974 100644 --- a/deployment/instance/instance_test.go +++ b/deployment/instance/instance_test.go @@ -15,8 +15,6 @@ import ( bicloud "github.com/cloudfoundry/bosh-cli/cloud" bidisk "github.com/cloudfoundry/bosh-cli/deployment/disk" bideplmanifest "github.com/cloudfoundry/bosh-cli/deployment/manifest" - bisshtunnel "github.com/cloudfoundry/bosh-cli/deployment/sshtunnel" - biinstallmanifest "github.com/cloudfoundry/bosh-cli/installation/manifest" bosherr "github.com/cloudfoundry/bosh-utils/errors" "github.com/cloudfoundry/bosh-utils/logger/loggerfakes" @@ -480,161 +478,46 @@ var _ = Describe("Instance", func() { }) Describe("WaitUntilReady", func() { - var ( - registryConfig biinstallmanifest.Registry - ) + It("waits for the vm", func() { + err := instance.WaitUntilReady(fakeStage) + Expect(err).NotTo(HaveOccurred()) + Expect(fakeVM.WaitUntilReadyInputs).To(ContainElement(fakebivm.WaitUntilReadyInput{ + Timeout: 10 * time.Minute, + Delay: 500 * time.Millisecond, + })) + }) - Context("When raw private key is provided", func() { - BeforeEach(func() { - registryConfig = biinstallmanifest.Registry{ - Port: 125, - SSHTunnel: biinstallmanifest.SSHTunnel{ - Host: "fake-ssh-host", - Port: 124, - User: "fake-ssh-username", - Password: "fake-password", - PrivateKey: "--BEGIN PRIVATE KEY-- asdf --END PRIVATE KEY--", - }, - } - }) + It("logs start and stop events to the eventLogger", func() { + err := instance.WaitUntilReady(fakeStage) + Expect(err).NotTo(HaveOccurred()) - It("starts & stops the SSH tunnel", func() { - err := instance.WaitUntilReady(registryConfig, fakeStage) - Expect(err).NotTo(HaveOccurred()) - Expect(fakeSSHTunnelFactory.NewSSHTunnelOptions).To(Equal(bisshtunnel.Options{ - User: "fake-ssh-username", - PrivateKey: "--BEGIN PRIVATE KEY-- asdf --END PRIVATE KEY--", - Password: "fake-password", - Host: "fake-ssh-host", - Port: 124, - LocalForwardPort: 125, - RemoteForwardPort: 125, - })) - Expect(fakeSSHTunnel.Started).To(BeTrue()) - }) + Expect(fakeStage.PerformCalls).To(Equal([]*fakebiui.PerformCall{ + {Name: "Waiting for the agent on VM 'fake-vm-cid' to be ready"}, + })) + }) - It("waits for the vm", func() { - err := instance.WaitUntilReady(registryConfig, fakeStage) - Expect(err).NotTo(HaveOccurred()) - Expect(fakeVM.WaitUntilReadyInputs).To(ContainElement(fakebivm.WaitUntilReadyInput{ - Timeout: 10 * time.Minute, - Delay: 500 * time.Millisecond, - })) + Context("when waiting for the agent fails", func() { + var ( + waitError = bosherr.Error("fake-wait-error") + ) + BeforeEach(func() { + fakeVM.WaitUntilReadyErr = waitError }) It("logs start and stop events to the eventLogger", func() { - err := instance.WaitUntilReady(registryConfig, fakeStage) - Expect(err).NotTo(HaveOccurred()) + err := instance.WaitUntilReady(fakeStage) + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("fake-wait-error")) Expect(fakeStage.PerformCalls).To(Equal([]*fakebiui.PerformCall{ - {Name: "Waiting for the agent on VM 'fake-vm-cid' to be ready"}, - })) - }) - - Context("when registry config is empty", func() { - BeforeEach(func() { - registryConfig = biinstallmanifest.Registry{} - }) - - It("does not start ssh tunnel", func() { - err := instance.WaitUntilReady(registryConfig, fakeStage) - Expect(err).ToNot(HaveOccurred()) - Expect(fakeSSHTunnel.Started).To(BeFalse()) - }) - }) - - Context("when registry config is empty", func() { - BeforeEach(func() { - registryConfig = biinstallmanifest.Registry{} - }) - - It("does not start ssh tunnel", func() { - err := instance.WaitUntilReady(registryConfig, fakeStage) - Expect(err).ToNot(HaveOccurred()) - Expect(fakeSSHTunnel.Started).To(BeFalse()) - }) - }) - - Context("when starting SSH tunnel fails", func() { - BeforeEach(func() { - fakeSSHTunnel.SetStartBehavior(bosherr.Error("fake-ssh-tunnel-start-error"), nil) - }) - - It("returns an error", func() { - err := instance.WaitUntilReady(registryConfig, fakeStage) - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("fake-ssh-tunnel-start-error")) - }) - }) - - Context("when waiting for the agent fails", func() { - var ( - waitError = bosherr.Error("fake-wait-error") - ) - BeforeEach(func() { - fakeVM.WaitUntilReadyErr = waitError - }) - - It("logs start and stop events to the eventLogger", func() { - err := instance.WaitUntilReady(registryConfig, fakeStage) - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("fake-wait-error")) - - Expect(fakeStage.PerformCalls).To(Equal([]*fakebiui.PerformCall{ - { - Name: "Waiting for the agent on VM 'fake-vm-cid' to be ready", - Error: waitError, - }, - })) - }) - }) - - Context("when receiving SSH tunnel errors", func() { - BeforeEach(func() { - fakeSSHTunnel.SetStartBehavior(nil, bosherr.Error("fake-ssh-tunnel-error")) - }) - - It("logs the error", func() { - err := instance.WaitUntilReady(registryConfig, fakeStage) - Expect(err).NotTo(HaveOccurred()) - - Eventually(logger.WarnCallCount).Should(Equal(1)) - tag, message, _ := logger.WarnArgsForCall(0) - Expect(tag).To(Equal("instance")) - Expect(message).To(Equal("Received SSH tunnel error: %s")) - }) - }) - }) - - Context("When the private key is provided", func() { - BeforeEach(func() { - registryConfig = biinstallmanifest.Registry{ - Port: 125, - SSHTunnel: biinstallmanifest.SSHTunnel{ - Host: "fake-ssh-host", - Port: 124, - User: "fake-ssh-username", - Password: "fake-password", - PrivateKey: "--BEGIN PRIVATE KEY-- asdf --END PRIVATE KEY--", + { + Name: "Waiting for the agent on VM 'fake-vm-cid' to be ready", + Error: waitError, }, - } - }) - - It("sets the SSHTunnel options", func() { - err := instance.WaitUntilReady(registryConfig, fakeStage) - Expect(err).NotTo(HaveOccurred()) - Expect(fakeSSHTunnelFactory.NewSSHTunnelOptions).To(Equal(bisshtunnel.Options{ - User: "fake-ssh-username", - PrivateKey: "--BEGIN PRIVATE KEY-- asdf --END PRIVATE KEY--", - Password: "fake-password", - Host: "fake-ssh-host", - Port: 124, - LocalForwardPort: 125, - RemoteForwardPort: 125, })) }) - }) + }) Describe("Stop", func() { diff --git a/deployment/instance/manager.go b/deployment/instance/manager.go index 49161c743..7b5614ebe 100644 --- a/deployment/instance/manager.go +++ b/deployment/instance/manager.go @@ -10,7 +10,6 @@ import ( bideplmanifest "github.com/cloudfoundry/bosh-cli/deployment/manifest" bisshtunnel "github.com/cloudfoundry/bosh-cli/deployment/sshtunnel" bivm "github.com/cloudfoundry/bosh-cli/deployment/vm" - biinstallmanifest "github.com/cloudfoundry/bosh-cli/installation/manifest" bistemcell "github.com/cloudfoundry/bosh-cli/stemcell" biui "github.com/cloudfoundry/bosh-cli/ui" bosherr "github.com/cloudfoundry/bosh-utils/errors" @@ -24,7 +23,6 @@ type Manager interface { id int, deploymentManifest bideplmanifest.Manifest, cloudStemcell bistemcell.CloudStemcell, - registryConfig biinstallmanifest.Registry, eventLoggerStage biui.Stage, ) (Instance, []bidisk.Disk, error) DeleteAll( @@ -98,7 +96,6 @@ func (m *manager) Create( id int, deploymentManifest bideplmanifest.Manifest, cloudStemcell bistemcell.CloudStemcell, - registryConfig biinstallmanifest.Registry, eventLoggerStage biui.Stage, ) (Instance, []bidisk.Disk, error) { var vm bivm.VM @@ -122,7 +119,7 @@ func (m *manager) Create( instance := m.instanceFactory.NewInstance(jobName, id, vm, m.vmManager, m.sshTunnelFactory, m.blobstore, m.logger) - if err := instance.WaitUntilReady(registryConfig, eventLoggerStage); err != nil { + if err := instance.WaitUntilReady(eventLoggerStage); err != nil { return instance, []bidisk.Disk{}, bosherr.WrapError(err, "Waiting until instance is ready") } diff --git a/deployment/instance/manager_test.go b/deployment/instance/manager_test.go index 4357630f6..832220486 100644 --- a/deployment/instance/manager_test.go +++ b/deployment/instance/manager_test.go @@ -17,8 +17,6 @@ import ( bias "github.com/cloudfoundry/bosh-agent/agentclient/applyspec" bidisk "github.com/cloudfoundry/bosh-cli/deployment/disk" bideplmanifest "github.com/cloudfoundry/bosh-cli/deployment/manifest" - bisshtunnel "github.com/cloudfoundry/bosh-cli/deployment/sshtunnel" - biinstallmanifest "github.com/cloudfoundry/bosh-cli/installation/manifest" boshlog "github.com/cloudfoundry/bosh-utils/logger" biproperty "github.com/cloudfoundry/bosh-utils/property" @@ -103,7 +101,6 @@ var _ = Describe("Manager", func() { diskPool bideplmanifest.DiskPool deploymentManifest bideplmanifest.Manifest fakeCloudStemcell *fakebistemcell.FakeCloudStemcell - registry biinstallmanifest.Registry expectedInstance Instance expectedDisk *fakebidisk.FakeDisk @@ -169,7 +166,6 @@ var _ = Describe("Manager", func() { } fakeCloudStemcell = fakebistemcell.NewFakeCloudStemcell("fake-stemcell-cid", "fake-stemcell-name", "fake-stemcell-version", apiVersion) - registry = biinstallmanifest.Registry{} fakeVM = fakebivm.NewFakeVM("fake-vm-cid") fakeVMManager.CreateVM = fakeVM @@ -201,7 +197,6 @@ var _ = Describe("Manager", func() { 0, deploymentManifest, fakeCloudStemcell, - registry, fakeStage, ) Expect(err).NotTo(HaveOccurred()) @@ -219,7 +214,6 @@ var _ = Describe("Manager", func() { 0, deploymentManifest, fakeCloudStemcell, - registry, fakeStage, ) Expect(err).NotTo(HaveOccurred()) @@ -233,7 +227,6 @@ var _ = Describe("Manager", func() { 0, deploymentManifest, fakeCloudStemcell, - registry, fakeStage, ) Expect(err).NotTo(HaveOccurred()) @@ -250,7 +243,6 @@ var _ = Describe("Manager", func() { 0, deploymentManifest, fakeCloudStemcell, - registry, fakeStage, ) Expect(err).NotTo(HaveOccurred()) @@ -273,7 +265,6 @@ var _ = Describe("Manager", func() { 0, deploymentManifest, fakeCloudStemcell, - registry, fakeStage, ) Expect(err).NotTo(HaveOccurred()) @@ -287,80 +278,6 @@ var _ = Describe("Manager", func() { })) }) - Context("when registry or sshTunnelConfig are not empty", func() { - BeforeEach(func() { - registry = biinstallmanifest.Registry{ - Username: "fake-registry-username", - Password: "fake-registry-password", - Host: "fake-registry-host", - Port: 124, - SSHTunnel: biinstallmanifest.SSHTunnel{ - User: "fake-ssh-user", - Host: "fake-ssh-host", - Port: 123, - Password: "fake-ssh-password", - PrivateKey: "---BEGIN PRIVATE KEY--- im a real key ---END PRIVATE KEY---", - }, - } - }) - - It("starts & stops the ssh tunnel", func() { - _, _, err := manager.Create( - "fake-job-name", - 0, - deploymentManifest, - fakeCloudStemcell, - registry, - fakeStage, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(fakeSSHTunnelFactory.NewSSHTunnelOptions).To(Equal(bisshtunnel.Options{ - User: "fake-ssh-user", - Host: "fake-ssh-host", - Port: 123, - Password: "fake-ssh-password", - PrivateKey: "---BEGIN PRIVATE KEY--- im a real key ---END PRIVATE KEY---", - LocalForwardPort: 124, - RemoteForwardPort: 124, - })) - Expect(fakeSSHTunnel.Started).To(BeTrue()) - }) - - Context("when starting the ssh tunnel fails", func() { - BeforeEach(func() { - fakeSSHTunnel.SetStartBehavior(errors.New("fake-ssh-tunnel-start-error"), nil) - }) - - It("returns an error", func() { - _, _, err := manager.Create( - "fake-job-name", - 0, - deploymentManifest, - fakeCloudStemcell, - registry, - fakeStage, - ) - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("fake-ssh-tunnel-start-error")) - }) - }) - }) - - Context("when ssh tunnel conifg is empty", func() { - It("does not start the ssh tunnel", func() { - _, _, err := manager.Create( - "fake-job-name", - 0, - deploymentManifest, - fakeCloudStemcell, - registry, - fakeStage, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(fakeSSHTunnel.Started).To(BeFalse()) - }) - }) - Context("when creating VM fails", func() { BeforeEach(func() { fakeVMManager.CreateErr = errors.New("fake-create-vm-error") @@ -372,7 +289,6 @@ var _ = Describe("Manager", func() { 0, deploymentManifest, fakeCloudStemcell, - registry, fakeStage, ) Expect(err).To(HaveOccurred()) @@ -385,7 +301,6 @@ var _ = Describe("Manager", func() { 0, deploymentManifest, fakeCloudStemcell, - registry, fakeStage, ) Expect(err).To(HaveOccurred()) diff --git a/deployment/instance/mocks/mocks.go b/deployment/instance/mocks/mocks.go index 5396349de..6732d7f20 100644 --- a/deployment/instance/mocks/mocks.go +++ b/deployment/instance/mocks/mocks.go @@ -5,41 +5,41 @@ package mocks import ( + reflect "reflect" + time "time" + disk "github.com/cloudfoundry/bosh-cli/deployment/disk" instance "github.com/cloudfoundry/bosh-cli/deployment/instance" manifest "github.com/cloudfoundry/bosh-cli/deployment/manifest" - manifest0 "github.com/cloudfoundry/bosh-cli/installation/manifest" stemcell "github.com/cloudfoundry/bosh-cli/stemcell" ui "github.com/cloudfoundry/bosh-cli/ui" gomock "github.com/golang/mock/gomock" - reflect "reflect" - time "time" ) -// MockInstance is a mock of Instance interface +// MockInstance is a mock of Instance interface. type MockInstance struct { ctrl *gomock.Controller recorder *MockInstanceMockRecorder } -// MockInstanceMockRecorder is the mock recorder for MockInstance +// MockInstanceMockRecorder is the mock recorder for MockInstance. type MockInstanceMockRecorder struct { mock *MockInstance } -// NewMockInstance creates a new mock instance +// NewMockInstance creates a new mock instance. func NewMockInstance(ctrl *gomock.Controller) *MockInstance { mock := &MockInstance{ctrl: ctrl} mock.recorder = &MockInstanceMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockInstance) EXPECT() *MockInstanceMockRecorder { return m.recorder } -// Delete mocks base method +// Delete mocks base method. func (m *MockInstance) Delete(arg0, arg1 time.Duration, arg2 bool, arg3 ui.Stage) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delete", arg0, arg1, arg2, arg3) @@ -47,13 +47,13 @@ func (m *MockInstance) Delete(arg0, arg1 time.Duration, arg2 bool, arg3 ui.Stage return ret0 } -// Delete indicates an expected call of Delete +// Delete indicates an expected call of Delete. func (mr *MockInstanceMockRecorder) Delete(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockInstance)(nil).Delete), arg0, arg1, arg2, arg3) } -// Disks mocks base method +// Disks mocks base method. func (m *MockInstance) Disks() ([]disk.Disk, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Disks") @@ -62,13 +62,13 @@ func (m *MockInstance) Disks() ([]disk.Disk, error) { return ret0, ret1 } -// Disks indicates an expected call of Disks +// Disks indicates an expected call of Disks. func (mr *MockInstanceMockRecorder) Disks() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Disks", reflect.TypeOf((*MockInstance)(nil).Disks)) } -// ID mocks base method +// ID mocks base method. func (m *MockInstance) ID() int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ID") @@ -76,13 +76,13 @@ func (m *MockInstance) ID() int { return ret0 } -// ID indicates an expected call of ID +// ID indicates an expected call of ID. func (mr *MockInstanceMockRecorder) ID() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ID", reflect.TypeOf((*MockInstance)(nil).ID)) } -// JobName mocks base method +// JobName mocks base method. func (m *MockInstance) JobName() string { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "JobName") @@ -90,13 +90,13 @@ func (m *MockInstance) JobName() string { return ret0 } -// JobName indicates an expected call of JobName +// JobName indicates an expected call of JobName. func (mr *MockInstanceMockRecorder) JobName() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "JobName", reflect.TypeOf((*MockInstance)(nil).JobName)) } -// Start mocks base method +// Start mocks base method. func (m *MockInstance) Start(arg0 manifest.Update, arg1, arg2 time.Duration, arg3 ui.Stage) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Start", arg0, arg1, arg2, arg3) @@ -104,13 +104,13 @@ func (m *MockInstance) Start(arg0 manifest.Update, arg1, arg2 time.Duration, arg return ret0 } -// Start indicates an expected call of Start +// Start indicates an expected call of Start. func (mr *MockInstanceMockRecorder) Start(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockInstance)(nil).Start), arg0, arg1, arg2, arg3) } -// Stop mocks base method +// Stop mocks base method. func (m *MockInstance) Stop(arg0, arg1 time.Duration, arg2 bool, arg3 ui.Stage) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Stop", arg0, arg1, arg2, arg3) @@ -118,13 +118,13 @@ func (m *MockInstance) Stop(arg0, arg1 time.Duration, arg2 bool, arg3 ui.Stage) return ret0 } -// Stop indicates an expected call of Stop +// Stop indicates an expected call of Stop. func (mr *MockInstanceMockRecorder) Stop(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockInstance)(nil).Stop), arg0, arg1, arg2, arg3) } -// UpdateDisks mocks base method +// UpdateDisks mocks base method. func (m *MockInstance) UpdateDisks(arg0 manifest.Manifest, arg1 ui.Stage) ([]disk.Disk, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateDisks", arg0, arg1) @@ -133,13 +133,13 @@ func (m *MockInstance) UpdateDisks(arg0 manifest.Manifest, arg1 ui.Stage) ([]dis return ret0, ret1 } -// UpdateDisks indicates an expected call of UpdateDisks +// UpdateDisks indicates an expected call of UpdateDisks. func (mr *MockInstanceMockRecorder) UpdateDisks(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateDisks", reflect.TypeOf((*MockInstance)(nil).UpdateDisks), arg0, arg1) } -// UpdateJobs mocks base method +// UpdateJobs mocks base method. func (m *MockInstance) UpdateJobs(arg0 manifest.Manifest, arg1 ui.Stage) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateJobs", arg0, arg1) @@ -147,66 +147,66 @@ func (m *MockInstance) UpdateJobs(arg0 manifest.Manifest, arg1 ui.Stage) error { return ret0 } -// UpdateJobs indicates an expected call of UpdateJobs +// UpdateJobs indicates an expected call of UpdateJobs. func (mr *MockInstanceMockRecorder) UpdateJobs(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateJobs", reflect.TypeOf((*MockInstance)(nil).UpdateJobs), arg0, arg1) } -// WaitUntilReady mocks base method -func (m *MockInstance) WaitUntilReady(arg0 manifest0.Registry, arg1 ui.Stage) error { +// WaitUntilReady mocks base method. +func (m *MockInstance) WaitUntilReady(arg0 ui.Stage) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WaitUntilReady", arg0, arg1) + ret := m.ctrl.Call(m, "WaitUntilReady", arg0) ret0, _ := ret[0].(error) return ret0 } -// WaitUntilReady indicates an expected call of WaitUntilReady -func (mr *MockInstanceMockRecorder) WaitUntilReady(arg0, arg1 interface{}) *gomock.Call { +// WaitUntilReady indicates an expected call of WaitUntilReady. +func (mr *MockInstanceMockRecorder) WaitUntilReady(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitUntilReady", reflect.TypeOf((*MockInstance)(nil).WaitUntilReady), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitUntilReady", reflect.TypeOf((*MockInstance)(nil).WaitUntilReady), arg0) } -// MockManager is a mock of Manager interface +// MockManager is a mock of Manager interface. type MockManager struct { ctrl *gomock.Controller recorder *MockManagerMockRecorder } -// MockManagerMockRecorder is the mock recorder for MockManager +// MockManagerMockRecorder is the mock recorder for MockManager. type MockManagerMockRecorder struct { mock *MockManager } -// NewMockManager creates a new mock instance +// NewMockManager creates a new mock instance. func NewMockManager(ctrl *gomock.Controller) *MockManager { mock := &MockManager{ctrl: ctrl} mock.recorder = &MockManagerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockManager) EXPECT() *MockManagerMockRecorder { return m.recorder } -// Create mocks base method -func (m *MockManager) Create(arg0 string, arg1 int, arg2 manifest.Manifest, arg3 stemcell.CloudStemcell, arg4 manifest0.Registry, arg5 ui.Stage) (instance.Instance, []disk.Disk, error) { +// Create mocks base method. +func (m *MockManager) Create(arg0 string, arg1 int, arg2 manifest.Manifest, arg3 stemcell.CloudStemcell, arg4 ui.Stage) (instance.Instance, []disk.Disk, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", arg0, arg1, arg2, arg3, arg4, arg5) + ret := m.ctrl.Call(m, "Create", arg0, arg1, arg2, arg3, arg4) ret0, _ := ret[0].(instance.Instance) ret1, _ := ret[1].([]disk.Disk) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } -// Create indicates an expected call of Create -func (mr *MockManagerMockRecorder) Create(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { +// Create indicates an expected call of Create. +func (mr *MockManagerMockRecorder) Create(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockManager)(nil).Create), arg0, arg1, arg2, arg3, arg4, arg5) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockManager)(nil).Create), arg0, arg1, arg2, arg3, arg4) } -// DeleteAll mocks base method +// DeleteAll mocks base method. func (m *MockManager) DeleteAll(arg0, arg1 time.Duration, arg2 bool, arg3 ui.Stage) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteAll", arg0, arg1, arg2, arg3) @@ -214,13 +214,13 @@ func (m *MockManager) DeleteAll(arg0, arg1 time.Duration, arg2 bool, arg3 ui.Sta return ret0 } -// DeleteAll indicates an expected call of DeleteAll +// DeleteAll indicates an expected call of DeleteAll. func (mr *MockManagerMockRecorder) DeleteAll(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAll", reflect.TypeOf((*MockManager)(nil).DeleteAll), arg0, arg1, arg2, arg3) } -// FindCurrent mocks base method +// FindCurrent mocks base method. func (m *MockManager) FindCurrent() ([]instance.Instance, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindCurrent") @@ -229,7 +229,7 @@ func (m *MockManager) FindCurrent() ([]instance.Instance, error) { return ret0, ret1 } -// FindCurrent indicates an expected call of FindCurrent +// FindCurrent indicates an expected call of FindCurrent. func (mr *MockManagerMockRecorder) FindCurrent() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindCurrent", reflect.TypeOf((*MockManager)(nil).FindCurrent)) diff --git a/deployment/instance/state/mocks/mocks.go b/deployment/instance/state/mocks/mocks.go index 0c8063eed..e05f4c6e8 100644 --- a/deployment/instance/state/mocks/mocks.go +++ b/deployment/instance/state/mocks/mocks.go @@ -5,6 +5,8 @@ package mocks import ( + reflect "reflect" + agentclient "github.com/cloudfoundry/bosh-agent/agentclient" applyspec "github.com/cloudfoundry/bosh-agent/agentclient/applyspec" blobstore "github.com/cloudfoundry/bosh-cli/blobstore" @@ -12,33 +14,32 @@ import ( manifest "github.com/cloudfoundry/bosh-cli/deployment/manifest" ui "github.com/cloudfoundry/bosh-cli/ui" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockBuilderFactory is a mock of BuilderFactory interface +// MockBuilderFactory is a mock of BuilderFactory interface. type MockBuilderFactory struct { ctrl *gomock.Controller recorder *MockBuilderFactoryMockRecorder } -// MockBuilderFactoryMockRecorder is the mock recorder for MockBuilderFactory +// MockBuilderFactoryMockRecorder is the mock recorder for MockBuilderFactory. type MockBuilderFactoryMockRecorder struct { mock *MockBuilderFactory } -// NewMockBuilderFactory creates a new mock instance +// NewMockBuilderFactory creates a new mock instance. func NewMockBuilderFactory(ctrl *gomock.Controller) *MockBuilderFactory { mock := &MockBuilderFactory{ctrl: ctrl} mock.recorder = &MockBuilderFactoryMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockBuilderFactory) EXPECT() *MockBuilderFactoryMockRecorder { return m.recorder } -// NewBuilder mocks base method +// NewBuilder mocks base method. func (m *MockBuilderFactory) NewBuilder(arg0 blobstore.Blobstore, arg1 agentclient.AgentClient) state.Builder { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewBuilder", arg0, arg1) @@ -46,36 +47,36 @@ func (m *MockBuilderFactory) NewBuilder(arg0 blobstore.Blobstore, arg1 agentclie return ret0 } -// NewBuilder indicates an expected call of NewBuilder +// NewBuilder indicates an expected call of NewBuilder. func (mr *MockBuilderFactoryMockRecorder) NewBuilder(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewBuilder", reflect.TypeOf((*MockBuilderFactory)(nil).NewBuilder), arg0, arg1) } -// MockBuilder is a mock of Builder interface +// MockBuilder is a mock of Builder interface. type MockBuilder struct { ctrl *gomock.Controller recorder *MockBuilderMockRecorder } -// MockBuilderMockRecorder is the mock recorder for MockBuilder +// MockBuilderMockRecorder is the mock recorder for MockBuilder. type MockBuilderMockRecorder struct { mock *MockBuilder } -// NewMockBuilder creates a new mock instance +// NewMockBuilder creates a new mock instance. func NewMockBuilder(ctrl *gomock.Controller) *MockBuilder { mock := &MockBuilder{ctrl: ctrl} mock.recorder = &MockBuilderMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockBuilder) EXPECT() *MockBuilderMockRecorder { return m.recorder } -// Build mocks base method +// Build mocks base method. func (m *MockBuilder) Build(arg0 string, arg1 int, arg2 manifest.Manifest, arg3 ui.Stage, arg4 agentclient.AgentState) (state.State, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Build", arg0, arg1, arg2, arg3, arg4) @@ -84,13 +85,13 @@ func (m *MockBuilder) Build(arg0 string, arg1 int, arg2 manifest.Manifest, arg3 return ret0, ret1 } -// Build indicates an expected call of Build +// Build indicates an expected call of Build. func (mr *MockBuilderMockRecorder) Build(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Build", reflect.TypeOf((*MockBuilder)(nil).Build), arg0, arg1, arg2, arg3, arg4) } -// BuildInitialState mocks base method +// BuildInitialState mocks base method. func (m *MockBuilder) BuildInitialState(arg0 string, arg1 int, arg2 manifest.Manifest) (state.State, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "BuildInitialState", arg0, arg1, arg2) @@ -99,36 +100,36 @@ func (m *MockBuilder) BuildInitialState(arg0 string, arg1 int, arg2 manifest.Man return ret0, ret1 } -// BuildInitialState indicates an expected call of BuildInitialState +// BuildInitialState indicates an expected call of BuildInitialState. func (mr *MockBuilderMockRecorder) BuildInitialState(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BuildInitialState", reflect.TypeOf((*MockBuilder)(nil).BuildInitialState), arg0, arg1, arg2) } -// MockState is a mock of State interface +// MockState is a mock of State interface. type MockState struct { ctrl *gomock.Controller recorder *MockStateMockRecorder } -// MockStateMockRecorder is the mock recorder for MockState +// MockStateMockRecorder is the mock recorder for MockState. type MockStateMockRecorder struct { mock *MockState } -// NewMockState creates a new mock instance +// NewMockState creates a new mock instance. func NewMockState(ctrl *gomock.Controller) *MockState { mock := &MockState{ctrl: ctrl} mock.recorder = &MockStateMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockState) EXPECT() *MockStateMockRecorder { return m.recorder } -// CompiledPackages mocks base method +// CompiledPackages mocks base method. func (m *MockState) CompiledPackages() []state.PackageRef { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CompiledPackages") @@ -136,13 +137,13 @@ func (m *MockState) CompiledPackages() []state.PackageRef { return ret0 } -// CompiledPackages indicates an expected call of CompiledPackages +// CompiledPackages indicates an expected call of CompiledPackages. func (mr *MockStateMockRecorder) CompiledPackages() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CompiledPackages", reflect.TypeOf((*MockState)(nil).CompiledPackages)) } -// NetworkInterfaces mocks base method +// NetworkInterfaces mocks base method. func (m *MockState) NetworkInterfaces() []state.NetworkRef { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NetworkInterfaces") @@ -150,13 +151,13 @@ func (m *MockState) NetworkInterfaces() []state.NetworkRef { return ret0 } -// NetworkInterfaces indicates an expected call of NetworkInterfaces +// NetworkInterfaces indicates an expected call of NetworkInterfaces. func (mr *MockStateMockRecorder) NetworkInterfaces() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NetworkInterfaces", reflect.TypeOf((*MockState)(nil).NetworkInterfaces)) } -// RenderedJobListArchive mocks base method +// RenderedJobListArchive mocks base method. func (m *MockState) RenderedJobListArchive() state.BlobRef { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RenderedJobListArchive") @@ -164,13 +165,13 @@ func (m *MockState) RenderedJobListArchive() state.BlobRef { return ret0 } -// RenderedJobListArchive indicates an expected call of RenderedJobListArchive +// RenderedJobListArchive indicates an expected call of RenderedJobListArchive. func (mr *MockStateMockRecorder) RenderedJobListArchive() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RenderedJobListArchive", reflect.TypeOf((*MockState)(nil).RenderedJobListArchive)) } -// RenderedJobs mocks base method +// RenderedJobs mocks base method. func (m *MockState) RenderedJobs() []state.JobRef { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RenderedJobs") @@ -178,13 +179,13 @@ func (m *MockState) RenderedJobs() []state.JobRef { return ret0 } -// RenderedJobs indicates an expected call of RenderedJobs +// RenderedJobs indicates an expected call of RenderedJobs. func (mr *MockStateMockRecorder) RenderedJobs() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RenderedJobs", reflect.TypeOf((*MockState)(nil).RenderedJobs)) } -// ToApplySpec mocks base method +// ToApplySpec mocks base method. func (m *MockState) ToApplySpec() applyspec.ApplySpec { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ToApplySpec") @@ -192,7 +193,7 @@ func (m *MockState) ToApplySpec() applyspec.ApplySpec { return ret0 } -// ToApplySpec indicates an expected call of ToApplySpec +// ToApplySpec indicates an expected call of ToApplySpec. func (mr *MockStateMockRecorder) ToApplySpec() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToApplySpec", reflect.TypeOf((*MockState)(nil).ToApplySpec)) diff --git a/deployment/manifest/manifestfakes/fake_parser.go b/deployment/manifest/manifestfakes/fake_parser.go index 38293fded..ab0930003 100644 --- a/deployment/manifest/manifestfakes/fake_parser.go +++ b/deployment/manifest/manifestfakes/fake_parser.go @@ -5,15 +5,15 @@ import ( "sync" "github.com/cloudfoundry/bosh-cli/deployment/manifest" - bidepltpl "github.com/cloudfoundry/bosh-cli/deployment/template" + "github.com/cloudfoundry/bosh-cli/deployment/template" ) type FakeParser struct { - ParseStub func(interpolatedTemplate bidepltpl.InterpolatedTemplate, path string) (manifest.Manifest, error) + ParseStub func(template.InterpolatedTemplate, string) (manifest.Manifest, error) parseMutex sync.RWMutex parseArgsForCall []struct { - interpolatedTemplate bidepltpl.InterpolatedTemplate - path string + arg1 template.InterpolatedTemplate + arg2 string } parseReturns struct { result1 manifest.Manifest @@ -27,22 +27,24 @@ type FakeParser struct { invocationsMutex sync.RWMutex } -func (fake *FakeParser) Parse(interpolatedTemplate bidepltpl.InterpolatedTemplate, path string) (manifest.Manifest, error) { +func (fake *FakeParser) Parse(arg1 template.InterpolatedTemplate, arg2 string) (manifest.Manifest, error) { fake.parseMutex.Lock() ret, specificReturn := fake.parseReturnsOnCall[len(fake.parseArgsForCall)] fake.parseArgsForCall = append(fake.parseArgsForCall, struct { - interpolatedTemplate bidepltpl.InterpolatedTemplate - path string - }{interpolatedTemplate, path}) - fake.recordInvocation("Parse", []interface{}{interpolatedTemplate, path}) + arg1 template.InterpolatedTemplate + arg2 string + }{arg1, arg2}) + stub := fake.ParseStub + fakeReturns := fake.parseReturns + fake.recordInvocation("Parse", []interface{}{arg1, arg2}) fake.parseMutex.Unlock() - if fake.ParseStub != nil { - return fake.ParseStub(interpolatedTemplate, path) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.parseReturns.result1, fake.parseReturns.result2 + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeParser) ParseCallCount() int { @@ -51,13 +53,22 @@ func (fake *FakeParser) ParseCallCount() int { return len(fake.parseArgsForCall) } -func (fake *FakeParser) ParseArgsForCall(i int) (bidepltpl.InterpolatedTemplate, string) { +func (fake *FakeParser) ParseCalls(stub func(template.InterpolatedTemplate, string) (manifest.Manifest, error)) { + fake.parseMutex.Lock() + defer fake.parseMutex.Unlock() + fake.ParseStub = stub +} + +func (fake *FakeParser) ParseArgsForCall(i int) (template.InterpolatedTemplate, string) { fake.parseMutex.RLock() defer fake.parseMutex.RUnlock() - return fake.parseArgsForCall[i].interpolatedTemplate, fake.parseArgsForCall[i].path + argsForCall := fake.parseArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeParser) ParseReturns(result1 manifest.Manifest, result2 error) { + fake.parseMutex.Lock() + defer fake.parseMutex.Unlock() fake.ParseStub = nil fake.parseReturns = struct { result1 manifest.Manifest @@ -66,6 +77,8 @@ func (fake *FakeParser) ParseReturns(result1 manifest.Manifest, result2 error) { } func (fake *FakeParser) ParseReturnsOnCall(i int, result1 manifest.Manifest, result2 error) { + fake.parseMutex.Lock() + defer fake.parseMutex.Unlock() fake.ParseStub = nil if fake.parseReturnsOnCall == nil { fake.parseReturnsOnCall = make(map[int]struct { @@ -84,7 +97,11 @@ func (fake *FakeParser) Invocations() map[string][][]interface{} { defer fake.invocationsMutex.RUnlock() fake.parseMutex.RLock() defer fake.parseMutex.RUnlock() - return fake.invocations + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeParser) recordInvocation(key string, args []interface{}) { diff --git a/deployment/mocks/mocks.go b/deployment/mocks/mocks.go index ccd5e123f..7b6aefa16 100644 --- a/deployment/mocks/mocks.go +++ b/deployment/mocks/mocks.go @@ -5,6 +5,8 @@ package mocks import ( + reflect "reflect" + agentclient "github.com/cloudfoundry/bosh-agent/agentclient" blobstore "github.com/cloudfoundry/bosh-cli/blobstore" cloud "github.com/cloudfoundry/bosh-cli/cloud" @@ -13,37 +15,35 @@ import ( instance "github.com/cloudfoundry/bosh-cli/deployment/instance" manifest "github.com/cloudfoundry/bosh-cli/deployment/manifest" vm "github.com/cloudfoundry/bosh-cli/deployment/vm" - manifest0 "github.com/cloudfoundry/bosh-cli/installation/manifest" stemcell "github.com/cloudfoundry/bosh-cli/stemcell" ui "github.com/cloudfoundry/bosh-cli/ui" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockDeployment is a mock of Deployment interface +// MockDeployment is a mock of Deployment interface. type MockDeployment struct { ctrl *gomock.Controller recorder *MockDeploymentMockRecorder } -// MockDeploymentMockRecorder is the mock recorder for MockDeployment +// MockDeploymentMockRecorder is the mock recorder for MockDeployment. type MockDeploymentMockRecorder struct { mock *MockDeployment } -// NewMockDeployment creates a new mock instance +// NewMockDeployment creates a new mock instance. func NewMockDeployment(ctrl *gomock.Controller) *MockDeployment { mock := &MockDeployment{ctrl: ctrl} mock.recorder = &MockDeploymentMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockDeployment) EXPECT() *MockDeploymentMockRecorder { return m.recorder } -// Delete mocks base method +// Delete mocks base method. func (m *MockDeployment) Delete(arg0 bool, arg1 ui.Stage) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delete", arg0, arg1) @@ -51,13 +51,13 @@ func (m *MockDeployment) Delete(arg0 bool, arg1 ui.Stage) error { return ret0 } -// Delete indicates an expected call of Delete +// Delete indicates an expected call of Delete. func (mr *MockDeploymentMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockDeployment)(nil).Delete), arg0, arg1) } -// Start mocks base method +// Start mocks base method. func (m *MockDeployment) Start(arg0 ui.Stage, arg1 manifest.Update) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Start", arg0, arg1) @@ -65,13 +65,13 @@ func (m *MockDeployment) Start(arg0 ui.Stage, arg1 manifest.Update) error { return ret0 } -// Start indicates an expected call of Start +// Start indicates an expected call of Start. func (mr *MockDeploymentMockRecorder) Start(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockDeployment)(nil).Start), arg0, arg1) } -// Stop mocks base method +// Stop mocks base method. func (m *MockDeployment) Stop(arg0 bool, arg1 ui.Stage) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Stop", arg0, arg1) @@ -79,36 +79,36 @@ func (m *MockDeployment) Stop(arg0 bool, arg1 ui.Stage) error { return ret0 } -// Stop indicates an expected call of Stop +// Stop indicates an expected call of Stop. func (mr *MockDeploymentMockRecorder) Stop(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockDeployment)(nil).Stop), arg0, arg1) } -// MockFactory is a mock of Factory interface +// MockFactory is a mock of Factory interface. type MockFactory struct { ctrl *gomock.Controller recorder *MockFactoryMockRecorder } -// MockFactoryMockRecorder is the mock recorder for MockFactory +// MockFactoryMockRecorder is the mock recorder for MockFactory. type MockFactoryMockRecorder struct { mock *MockFactory } -// NewMockFactory creates a new mock instance +// NewMockFactory creates a new mock instance. func NewMockFactory(ctrl *gomock.Controller) *MockFactory { mock := &MockFactory{ctrl: ctrl} mock.recorder = &MockFactoryMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockFactory) EXPECT() *MockFactoryMockRecorder { return m.recorder } -// NewDeployment mocks base method +// NewDeployment mocks base method. func (m *MockFactory) NewDeployment(arg0 []instance.Instance, arg1 []disk.Disk, arg2 []stemcell.CloudStemcell) deployment.Deployment { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewDeployment", arg0, arg1, arg2) @@ -116,74 +116,74 @@ func (m *MockFactory) NewDeployment(arg0 []instance.Instance, arg1 []disk.Disk, return ret0 } -// NewDeployment indicates an expected call of NewDeployment +// NewDeployment indicates an expected call of NewDeployment. func (mr *MockFactoryMockRecorder) NewDeployment(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewDeployment", reflect.TypeOf((*MockFactory)(nil).NewDeployment), arg0, arg1, arg2) } -// MockDeployer is a mock of Deployer interface +// MockDeployer is a mock of Deployer interface. type MockDeployer struct { ctrl *gomock.Controller recorder *MockDeployerMockRecorder } -// MockDeployerMockRecorder is the mock recorder for MockDeployer +// MockDeployerMockRecorder is the mock recorder for MockDeployer. type MockDeployerMockRecorder struct { mock *MockDeployer } -// NewMockDeployer creates a new mock instance +// NewMockDeployer creates a new mock instance. func NewMockDeployer(ctrl *gomock.Controller) *MockDeployer { mock := &MockDeployer{ctrl: ctrl} mock.recorder = &MockDeployerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockDeployer) EXPECT() *MockDeployerMockRecorder { return m.recorder } -// Deploy mocks base method -func (m *MockDeployer) Deploy(arg0 cloud.Cloud, arg1 manifest.Manifest, arg2 stemcell.CloudStemcell, arg3 manifest0.Registry, arg4 vm.Manager, arg5 blobstore.Blobstore, arg6 bool, arg7 ui.Stage) (deployment.Deployment, error) { +// Deploy mocks base method. +func (m *MockDeployer) Deploy(arg0 cloud.Cloud, arg1 manifest.Manifest, arg2 stemcell.CloudStemcell, arg3 vm.Manager, arg4 blobstore.Blobstore, arg5 bool, arg6 ui.Stage) (deployment.Deployment, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Deploy", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) + ret := m.ctrl.Call(m, "Deploy", arg0, arg1, arg2, arg3, arg4, arg5, arg6) ret0, _ := ret[0].(deployment.Deployment) ret1, _ := ret[1].(error) return ret0, ret1 } -// Deploy indicates an expected call of Deploy -func (mr *MockDeployerMockRecorder) Deploy(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 interface{}) *gomock.Call { +// Deploy indicates an expected call of Deploy. +func (mr *MockDeployerMockRecorder) Deploy(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Deploy", reflect.TypeOf((*MockDeployer)(nil).Deploy), arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Deploy", reflect.TypeOf((*MockDeployer)(nil).Deploy), arg0, arg1, arg2, arg3, arg4, arg5, arg6) } -// MockManager is a mock of Manager interface +// MockManager is a mock of Manager interface. type MockManager struct { ctrl *gomock.Controller recorder *MockManagerMockRecorder } -// MockManagerMockRecorder is the mock recorder for MockManager +// MockManagerMockRecorder is the mock recorder for MockManager. type MockManagerMockRecorder struct { mock *MockManager } -// NewMockManager creates a new mock instance +// NewMockManager creates a new mock instance. func NewMockManager(ctrl *gomock.Controller) *MockManager { mock := &MockManager{ctrl: ctrl} mock.recorder = &MockManagerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockManager) EXPECT() *MockManagerMockRecorder { return m.recorder } -// Cleanup mocks base method +// Cleanup mocks base method. func (m *MockManager) Cleanup(arg0 ui.Stage) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Cleanup", arg0) @@ -191,13 +191,13 @@ func (m *MockManager) Cleanup(arg0 ui.Stage) error { return ret0 } -// Cleanup indicates an expected call of Cleanup +// Cleanup indicates an expected call of Cleanup. func (mr *MockManagerMockRecorder) Cleanup(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Cleanup", reflect.TypeOf((*MockManager)(nil).Cleanup), arg0) } -// FindCurrent mocks base method +// FindCurrent mocks base method. func (m *MockManager) FindCurrent() (deployment.Deployment, bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindCurrent") @@ -207,36 +207,36 @@ func (m *MockManager) FindCurrent() (deployment.Deployment, bool, error) { return ret0, ret1, ret2 } -// FindCurrent indicates an expected call of FindCurrent +// FindCurrent indicates an expected call of FindCurrent. func (mr *MockManagerMockRecorder) FindCurrent() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindCurrent", reflect.TypeOf((*MockManager)(nil).FindCurrent)) } -// MockManagerFactory is a mock of ManagerFactory interface +// MockManagerFactory is a mock of ManagerFactory interface. type MockManagerFactory struct { ctrl *gomock.Controller recorder *MockManagerFactoryMockRecorder } -// MockManagerFactoryMockRecorder is the mock recorder for MockManagerFactory +// MockManagerFactoryMockRecorder is the mock recorder for MockManagerFactory. type MockManagerFactoryMockRecorder struct { mock *MockManagerFactory } -// NewMockManagerFactory creates a new mock instance +// NewMockManagerFactory creates a new mock instance. func NewMockManagerFactory(ctrl *gomock.Controller) *MockManagerFactory { mock := &MockManagerFactory{ctrl: ctrl} mock.recorder = &MockManagerFactoryMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockManagerFactory) EXPECT() *MockManagerFactoryMockRecorder { return m.recorder } -// NewManager mocks base method +// NewManager mocks base method. func (m *MockManagerFactory) NewManager(arg0 cloud.Cloud, arg1 agentclient.AgentClient, arg2 blobstore.Blobstore) deployment.Manager { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewManager", arg0, arg1, arg2) @@ -244,7 +244,7 @@ func (m *MockManagerFactory) NewManager(arg0 cloud.Cloud, arg1 agentclient.Agent return ret0 } -// NewManager indicates an expected call of NewManager +// NewManager indicates an expected call of NewManager. func (mr *MockManagerFactoryMockRecorder) NewManager(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewManager", reflect.TypeOf((*MockManagerFactory)(nil).NewManager), arg0, arg1, arg2) diff --git a/deployment/release/mocks/mocks.go b/deployment/release/mocks/mocks.go index c06db75ce..67262a279 100644 --- a/deployment/release/mocks/mocks.go +++ b/deployment/release/mocks/mocks.go @@ -5,35 +5,36 @@ package mocks import ( + reflect "reflect" + job "github.com/cloudfoundry/bosh-cli/release/job" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockJobResolver is a mock of JobResolver interface +// MockJobResolver is a mock of JobResolver interface. type MockJobResolver struct { ctrl *gomock.Controller recorder *MockJobResolverMockRecorder } -// MockJobResolverMockRecorder is the mock recorder for MockJobResolver +// MockJobResolverMockRecorder is the mock recorder for MockJobResolver. type MockJobResolverMockRecorder struct { mock *MockJobResolver } -// NewMockJobResolver creates a new mock instance +// NewMockJobResolver creates a new mock instance. func NewMockJobResolver(ctrl *gomock.Controller) *MockJobResolver { mock := &MockJobResolver{ctrl: ctrl} mock.recorder = &MockJobResolverMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockJobResolver) EXPECT() *MockJobResolverMockRecorder { return m.recorder } -// Resolve mocks base method +// Resolve mocks base method. func (m *MockJobResolver) Resolve(arg0, arg1 string) (job.Job, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Resolve", arg0, arg1) @@ -42,7 +43,7 @@ func (m *MockJobResolver) Resolve(arg0, arg1 string) (job.Job, error) { return ret0, ret1 } -// Resolve indicates an expected call of Resolve +// Resolve indicates an expected call of Resolve. func (mr *MockJobResolverMockRecorder) Resolve(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Resolve", reflect.TypeOf((*MockJobResolver)(nil).Resolve), arg0, arg1) diff --git a/deployment/template/templatefakes/fake_deployment_template_factory.go b/deployment/template/templatefakes/fake_deployment_template_factory.go index ec08f6a72..ceca5d087 100644 --- a/deployment/template/templatefakes/fake_deployment_template_factory.go +++ b/deployment/template/templatefakes/fake_deployment_template_factory.go @@ -8,10 +8,10 @@ import ( ) type FakeDeploymentTemplateFactory struct { - NewDeploymentTemplateFromPathStub func(path string) (template.DeploymentTemplate, error) + NewDeploymentTemplateFromPathStub func(string) (template.DeploymentTemplate, error) newDeploymentTemplateFromPathMutex sync.RWMutex newDeploymentTemplateFromPathArgsForCall []struct { - path string + arg1 string } newDeploymentTemplateFromPathReturns struct { result1 template.DeploymentTemplate @@ -25,21 +25,23 @@ type FakeDeploymentTemplateFactory struct { invocationsMutex sync.RWMutex } -func (fake *FakeDeploymentTemplateFactory) NewDeploymentTemplateFromPath(path string) (template.DeploymentTemplate, error) { +func (fake *FakeDeploymentTemplateFactory) NewDeploymentTemplateFromPath(arg1 string) (template.DeploymentTemplate, error) { fake.newDeploymentTemplateFromPathMutex.Lock() ret, specificReturn := fake.newDeploymentTemplateFromPathReturnsOnCall[len(fake.newDeploymentTemplateFromPathArgsForCall)] fake.newDeploymentTemplateFromPathArgsForCall = append(fake.newDeploymentTemplateFromPathArgsForCall, struct { - path string - }{path}) - fake.recordInvocation("NewDeploymentTemplateFromPath", []interface{}{path}) + arg1 string + }{arg1}) + stub := fake.NewDeploymentTemplateFromPathStub + fakeReturns := fake.newDeploymentTemplateFromPathReturns + fake.recordInvocation("NewDeploymentTemplateFromPath", []interface{}{arg1}) fake.newDeploymentTemplateFromPathMutex.Unlock() - if fake.NewDeploymentTemplateFromPathStub != nil { - return fake.NewDeploymentTemplateFromPathStub(path) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.newDeploymentTemplateFromPathReturns.result1, fake.newDeploymentTemplateFromPathReturns.result2 + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeDeploymentTemplateFactory) NewDeploymentTemplateFromPathCallCount() int { @@ -48,13 +50,22 @@ func (fake *FakeDeploymentTemplateFactory) NewDeploymentTemplateFromPathCallCoun return len(fake.newDeploymentTemplateFromPathArgsForCall) } +func (fake *FakeDeploymentTemplateFactory) NewDeploymentTemplateFromPathCalls(stub func(string) (template.DeploymentTemplate, error)) { + fake.newDeploymentTemplateFromPathMutex.Lock() + defer fake.newDeploymentTemplateFromPathMutex.Unlock() + fake.NewDeploymentTemplateFromPathStub = stub +} + func (fake *FakeDeploymentTemplateFactory) NewDeploymentTemplateFromPathArgsForCall(i int) string { fake.newDeploymentTemplateFromPathMutex.RLock() defer fake.newDeploymentTemplateFromPathMutex.RUnlock() - return fake.newDeploymentTemplateFromPathArgsForCall[i].path + argsForCall := fake.newDeploymentTemplateFromPathArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeDeploymentTemplateFactory) NewDeploymentTemplateFromPathReturns(result1 template.DeploymentTemplate, result2 error) { + fake.newDeploymentTemplateFromPathMutex.Lock() + defer fake.newDeploymentTemplateFromPathMutex.Unlock() fake.NewDeploymentTemplateFromPathStub = nil fake.newDeploymentTemplateFromPathReturns = struct { result1 template.DeploymentTemplate @@ -63,6 +74,8 @@ func (fake *FakeDeploymentTemplateFactory) NewDeploymentTemplateFromPathReturns( } func (fake *FakeDeploymentTemplateFactory) NewDeploymentTemplateFromPathReturnsOnCall(i int, result1 template.DeploymentTemplate, result2 error) { + fake.newDeploymentTemplateFromPathMutex.Lock() + defer fake.newDeploymentTemplateFromPathMutex.Unlock() fake.NewDeploymentTemplateFromPathStub = nil if fake.newDeploymentTemplateFromPathReturnsOnCall == nil { fake.newDeploymentTemplateFromPathReturnsOnCall = make(map[int]struct { @@ -81,7 +94,11 @@ func (fake *FakeDeploymentTemplateFactory) Invocations() map[string][][]interfac defer fake.invocationsMutex.RUnlock() fake.newDeploymentTemplateFromPathMutex.RLock() defer fake.newDeploymentTemplateFromPathMutex.RUnlock() - return fake.invocations + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeDeploymentTemplateFactory) recordInvocation(key string, args []interface{}) { diff --git a/deployment/vm/mocks/mocks.go b/deployment/vm/mocks/mocks.go index 69da28154..512adf902 100644 --- a/deployment/vm/mocks/mocks.go +++ b/deployment/vm/mocks/mocks.go @@ -5,37 +5,38 @@ package mocks import ( + reflect "reflect" + agentclient "github.com/cloudfoundry/bosh-agent/agentclient" cloud "github.com/cloudfoundry/bosh-cli/cloud" vm "github.com/cloudfoundry/bosh-cli/deployment/vm" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockManagerFactory is a mock of ManagerFactory interface +// MockManagerFactory is a mock of ManagerFactory interface. type MockManagerFactory struct { ctrl *gomock.Controller recorder *MockManagerFactoryMockRecorder } -// MockManagerFactoryMockRecorder is the mock recorder for MockManagerFactory +// MockManagerFactoryMockRecorder is the mock recorder for MockManagerFactory. type MockManagerFactoryMockRecorder struct { mock *MockManagerFactory } -// NewMockManagerFactory creates a new mock instance +// NewMockManagerFactory creates a new mock instance. func NewMockManagerFactory(ctrl *gomock.Controller) *MockManagerFactory { mock := &MockManagerFactory{ctrl: ctrl} mock.recorder = &MockManagerFactoryMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockManagerFactory) EXPECT() *MockManagerFactoryMockRecorder { return m.recorder } -// NewManager mocks base method +// NewManager mocks base method. func (m *MockManagerFactory) NewManager(arg0 cloud.Cloud, arg1 agentclient.AgentClient) vm.Manager { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewManager", arg0, arg1) @@ -43,7 +44,7 @@ func (m *MockManagerFactory) NewManager(arg0 cloud.Cloud, arg1 agentclient.Agent return ret0 } -// NewManager indicates an expected call of NewManager +// NewManager indicates an expected call of NewManager. func (mr *MockManagerFactoryMockRecorder) NewManager(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewManager", reflect.TypeOf((*MockManagerFactory)(nil).NewManager), arg0, arg1) diff --git a/director/directorfakes/fake_task.go b/director/directorfakes/fake_task.go index 3e515ef52..edba84cbc 100644 --- a/director/directorfakes/fake_task.go +++ b/director/directorfakes/fake_task.go @@ -9,94 +9,66 @@ import ( ) type FakeTask struct { - IDStub func() int - iDMutex sync.RWMutex - iDArgsForCall []struct{} - iDReturns struct { - result1 int + CPIOutputStub func(director.TaskReporter) error + cPIOutputMutex sync.RWMutex + cPIOutputArgsForCall []struct { + arg1 director.TaskReporter } - iDReturnsOnCall map[int]struct { - result1 int + cPIOutputReturns struct { + result1 error } - StartedAtStub func() time.Time - startedAtMutex sync.RWMutex - startedAtArgsForCall []struct{} - startedAtReturns struct { - result1 time.Time + cPIOutputReturnsOnCall map[int]struct { + result1 error } - startedAtReturnsOnCall map[int]struct { - result1 time.Time + CancelStub func() error + cancelMutex sync.RWMutex + cancelArgsForCall []struct { } - FinishedAtStub func() time.Time - finishedAtMutex sync.RWMutex - finishedAtArgsForCall []struct{} - finishedAtReturns struct { - result1 time.Time + cancelReturns struct { + result1 error } - finishedAtReturnsOnCall map[int]struct { - result1 time.Time + cancelReturnsOnCall map[int]struct { + result1 error } - StateStub func() string - stateMutex sync.RWMutex - stateArgsForCall []struct{} - stateReturns struct { - result1 string + ContextIDStub func() string + contextIDMutex sync.RWMutex + contextIDArgsForCall []struct { } - stateReturnsOnCall map[int]struct { + contextIDReturns struct { result1 string } - IsErrorStub func() bool - isErrorMutex sync.RWMutex - isErrorArgsForCall []struct{} - isErrorReturns struct { - result1 bool + contextIDReturnsOnCall map[int]struct { + result1 string } - isErrorReturnsOnCall map[int]struct { - result1 bool + DebugOutputStub func(director.TaskReporter) error + debugOutputMutex sync.RWMutex + debugOutputArgsForCall []struct { + arg1 director.TaskReporter } - UserStub func() string - userMutex sync.RWMutex - userArgsForCall []struct{} - userReturns struct { - result1 string + debugOutputReturns struct { + result1 error } - userReturnsOnCall map[int]struct { - result1 string + debugOutputReturnsOnCall map[int]struct { + result1 error } DeploymentNameStub func() string deploymentNameMutex sync.RWMutex - deploymentNameArgsForCall []struct{} - deploymentNameReturns struct { - result1 string - } - deploymentNameReturnsOnCall map[int]struct { - result1 string + deploymentNameArgsForCall []struct { } - ContextIDStub func() string - contextIDMutex sync.RWMutex - contextIDArgsForCall []struct{} - contextIDReturns struct { + deploymentNameReturns struct { result1 string } - contextIDReturnsOnCall map[int]struct { + deploymentNameReturnsOnCall map[int]struct { result1 string } DescriptionStub func() string descriptionMutex sync.RWMutex - descriptionArgsForCall []struct{} - descriptionReturns struct { - result1 string + descriptionArgsForCall []struct { } - descriptionReturnsOnCall map[int]struct { - result1 string - } - ResultStub func() string - resultMutex sync.RWMutex - resultArgsForCall []struct{} - resultReturns struct { + descriptionReturns struct { result1 string } - resultReturnsOnCall map[int]struct { + descriptionReturnsOnCall map[int]struct { result1 string } EventOutputStub func(director.TaskReporter) error @@ -110,27 +82,45 @@ type FakeTask struct { eventOutputReturnsOnCall map[int]struct { result1 error } - CPIOutputStub func(director.TaskReporter) error - cPIOutputMutex sync.RWMutex - cPIOutputArgsForCall []struct { - arg1 director.TaskReporter + FinishedAtStub func() time.Time + finishedAtMutex sync.RWMutex + finishedAtArgsForCall []struct { } - cPIOutputReturns struct { - result1 error + finishedAtReturns struct { + result1 time.Time } - cPIOutputReturnsOnCall map[int]struct { - result1 error + finishedAtReturnsOnCall map[int]struct { + result1 time.Time } - DebugOutputStub func(director.TaskReporter) error - debugOutputMutex sync.RWMutex - debugOutputArgsForCall []struct { - arg1 director.TaskReporter + IDStub func() int + iDMutex sync.RWMutex + iDArgsForCall []struct { } - debugOutputReturns struct { - result1 error + iDReturns struct { + result1 int } - debugOutputReturnsOnCall map[int]struct { - result1 error + iDReturnsOnCall map[int]struct { + result1 int + } + IsErrorStub func() bool + isErrorMutex sync.RWMutex + isErrorArgsForCall []struct { + } + isErrorReturns struct { + result1 bool + } + isErrorReturnsOnCall map[int]struct { + result1 bool + } + ResultStub func() string + resultMutex sync.RWMutex + resultArgsForCall []struct { + } + resultReturns struct { + result1 string + } + resultReturnsOnCall map[int]struct { + result1 string } ResultOutputStub func(director.TaskReporter) error resultOutputMutex sync.RWMutex @@ -143,272 +133,284 @@ type FakeTask struct { resultOutputReturnsOnCall map[int]struct { result1 error } - CancelStub func() error - cancelMutex sync.RWMutex - cancelArgsForCall []struct{} - cancelReturns struct { - result1 error + StartedAtStub func() time.Time + startedAtMutex sync.RWMutex + startedAtArgsForCall []struct { } - cancelReturnsOnCall map[int]struct { - result1 error + startedAtReturns struct { + result1 time.Time + } + startedAtReturnsOnCall map[int]struct { + result1 time.Time + } + StateStub func() string + stateMutex sync.RWMutex + stateArgsForCall []struct { + } + stateReturns struct { + result1 string + } + stateReturnsOnCall map[int]struct { + result1 string + } + UserStub func() string + userMutex sync.RWMutex + userArgsForCall []struct { + } + userReturns struct { + result1 string + } + userReturnsOnCall map[int]struct { + result1 string } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } -func (fake *FakeTask) ID() int { - fake.iDMutex.Lock() - ret, specificReturn := fake.iDReturnsOnCall[len(fake.iDArgsForCall)] - fake.iDArgsForCall = append(fake.iDArgsForCall, struct{}{}) - fake.recordInvocation("ID", []interface{}{}) - fake.iDMutex.Unlock() - if fake.IDStub != nil { - return fake.IDStub() +func (fake *FakeTask) CPIOutput(arg1 director.TaskReporter) error { + fake.cPIOutputMutex.Lock() + ret, specificReturn := fake.cPIOutputReturnsOnCall[len(fake.cPIOutputArgsForCall)] + fake.cPIOutputArgsForCall = append(fake.cPIOutputArgsForCall, struct { + arg1 director.TaskReporter + }{arg1}) + stub := fake.CPIOutputStub + fakeReturns := fake.cPIOutputReturns + fake.recordInvocation("CPIOutput", []interface{}{arg1}) + fake.cPIOutputMutex.Unlock() + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - return fake.iDReturns.result1 -} - -func (fake *FakeTask) IDCallCount() int { - fake.iDMutex.RLock() - defer fake.iDMutex.RUnlock() - return len(fake.iDArgsForCall) + return fakeReturns.result1 } -func (fake *FakeTask) IDReturns(result1 int) { - fake.IDStub = nil - fake.iDReturns = struct { - result1 int - }{result1} -} - -func (fake *FakeTask) IDReturnsOnCall(i int, result1 int) { - fake.IDStub = nil - if fake.iDReturnsOnCall == nil { - fake.iDReturnsOnCall = make(map[int]struct { - result1 int - }) - } - fake.iDReturnsOnCall[i] = struct { - result1 int - }{result1} +func (fake *FakeTask) CPIOutputCallCount() int { + fake.cPIOutputMutex.RLock() + defer fake.cPIOutputMutex.RUnlock() + return len(fake.cPIOutputArgsForCall) } -func (fake *FakeTask) StartedAt() time.Time { - fake.startedAtMutex.Lock() - ret, specificReturn := fake.startedAtReturnsOnCall[len(fake.startedAtArgsForCall)] - fake.startedAtArgsForCall = append(fake.startedAtArgsForCall, struct{}{}) - fake.recordInvocation("StartedAt", []interface{}{}) - fake.startedAtMutex.Unlock() - if fake.StartedAtStub != nil { - return fake.StartedAtStub() - } - if specificReturn { - return ret.result1 - } - return fake.startedAtReturns.result1 +func (fake *FakeTask) CPIOutputCalls(stub func(director.TaskReporter) error) { + fake.cPIOutputMutex.Lock() + defer fake.cPIOutputMutex.Unlock() + fake.CPIOutputStub = stub } -func (fake *FakeTask) StartedAtCallCount() int { - fake.startedAtMutex.RLock() - defer fake.startedAtMutex.RUnlock() - return len(fake.startedAtArgsForCall) +func (fake *FakeTask) CPIOutputArgsForCall(i int) director.TaskReporter { + fake.cPIOutputMutex.RLock() + defer fake.cPIOutputMutex.RUnlock() + argsForCall := fake.cPIOutputArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeTask) StartedAtReturns(result1 time.Time) { - fake.StartedAtStub = nil - fake.startedAtReturns = struct { - result1 time.Time +func (fake *FakeTask) CPIOutputReturns(result1 error) { + fake.cPIOutputMutex.Lock() + defer fake.cPIOutputMutex.Unlock() + fake.CPIOutputStub = nil + fake.cPIOutputReturns = struct { + result1 error }{result1} } -func (fake *FakeTask) StartedAtReturnsOnCall(i int, result1 time.Time) { - fake.StartedAtStub = nil - if fake.startedAtReturnsOnCall == nil { - fake.startedAtReturnsOnCall = make(map[int]struct { - result1 time.Time +func (fake *FakeTask) CPIOutputReturnsOnCall(i int, result1 error) { + fake.cPIOutputMutex.Lock() + defer fake.cPIOutputMutex.Unlock() + fake.CPIOutputStub = nil + if fake.cPIOutputReturnsOnCall == nil { + fake.cPIOutputReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.startedAtReturnsOnCall[i] = struct { - result1 time.Time + fake.cPIOutputReturnsOnCall[i] = struct { + result1 error }{result1} } -func (fake *FakeTask) FinishedAt() time.Time { - fake.finishedAtMutex.Lock() - ret, specificReturn := fake.finishedAtReturnsOnCall[len(fake.finishedAtArgsForCall)] - fake.finishedAtArgsForCall = append(fake.finishedAtArgsForCall, struct{}{}) - fake.recordInvocation("FinishedAt", []interface{}{}) - fake.finishedAtMutex.Unlock() - if fake.FinishedAtStub != nil { - return fake.FinishedAtStub() +func (fake *FakeTask) Cancel() error { + fake.cancelMutex.Lock() + ret, specificReturn := fake.cancelReturnsOnCall[len(fake.cancelArgsForCall)] + fake.cancelArgsForCall = append(fake.cancelArgsForCall, struct { + }{}) + stub := fake.CancelStub + fakeReturns := fake.cancelReturns + fake.recordInvocation("Cancel", []interface{}{}) + fake.cancelMutex.Unlock() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - return fake.finishedAtReturns.result1 -} - -func (fake *FakeTask) FinishedAtCallCount() int { - fake.finishedAtMutex.RLock() - defer fake.finishedAtMutex.RUnlock() - return len(fake.finishedAtArgsForCall) -} - -func (fake *FakeTask) FinishedAtReturns(result1 time.Time) { - fake.FinishedAtStub = nil - fake.finishedAtReturns = struct { - result1 time.Time - }{result1} -} - -func (fake *FakeTask) FinishedAtReturnsOnCall(i int, result1 time.Time) { - fake.FinishedAtStub = nil - if fake.finishedAtReturnsOnCall == nil { - fake.finishedAtReturnsOnCall = make(map[int]struct { - result1 time.Time - }) - } - fake.finishedAtReturnsOnCall[i] = struct { - result1 time.Time - }{result1} + return fakeReturns.result1 } -func (fake *FakeTask) State() string { - fake.stateMutex.Lock() - ret, specificReturn := fake.stateReturnsOnCall[len(fake.stateArgsForCall)] - fake.stateArgsForCall = append(fake.stateArgsForCall, struct{}{}) - fake.recordInvocation("State", []interface{}{}) - fake.stateMutex.Unlock() - if fake.StateStub != nil { - return fake.StateStub() - } - if specificReturn { - return ret.result1 - } - return fake.stateReturns.result1 +func (fake *FakeTask) CancelCallCount() int { + fake.cancelMutex.RLock() + defer fake.cancelMutex.RUnlock() + return len(fake.cancelArgsForCall) } -func (fake *FakeTask) StateCallCount() int { - fake.stateMutex.RLock() - defer fake.stateMutex.RUnlock() - return len(fake.stateArgsForCall) +func (fake *FakeTask) CancelCalls(stub func() error) { + fake.cancelMutex.Lock() + defer fake.cancelMutex.Unlock() + fake.CancelStub = stub } -func (fake *FakeTask) StateReturns(result1 string) { - fake.StateStub = nil - fake.stateReturns = struct { - result1 string +func (fake *FakeTask) CancelReturns(result1 error) { + fake.cancelMutex.Lock() + defer fake.cancelMutex.Unlock() + fake.CancelStub = nil + fake.cancelReturns = struct { + result1 error }{result1} } -func (fake *FakeTask) StateReturnsOnCall(i int, result1 string) { - fake.StateStub = nil - if fake.stateReturnsOnCall == nil { - fake.stateReturnsOnCall = make(map[int]struct { - result1 string +func (fake *FakeTask) CancelReturnsOnCall(i int, result1 error) { + fake.cancelMutex.Lock() + defer fake.cancelMutex.Unlock() + fake.CancelStub = nil + if fake.cancelReturnsOnCall == nil { + fake.cancelReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.stateReturnsOnCall[i] = struct { - result1 string + fake.cancelReturnsOnCall[i] = struct { + result1 error }{result1} } -func (fake *FakeTask) IsError() bool { - fake.isErrorMutex.Lock() - ret, specificReturn := fake.isErrorReturnsOnCall[len(fake.isErrorArgsForCall)] - fake.isErrorArgsForCall = append(fake.isErrorArgsForCall, struct{}{}) - fake.recordInvocation("IsError", []interface{}{}) - fake.isErrorMutex.Unlock() - if fake.IsErrorStub != nil { - return fake.IsErrorStub() +func (fake *FakeTask) ContextID() string { + fake.contextIDMutex.Lock() + ret, specificReturn := fake.contextIDReturnsOnCall[len(fake.contextIDArgsForCall)] + fake.contextIDArgsForCall = append(fake.contextIDArgsForCall, struct { + }{}) + stub := fake.ContextIDStub + fakeReturns := fake.contextIDReturns + fake.recordInvocation("ContextID", []interface{}{}) + fake.contextIDMutex.Unlock() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - return fake.isErrorReturns.result1 + return fakeReturns.result1 } -func (fake *FakeTask) IsErrorCallCount() int { - fake.isErrorMutex.RLock() - defer fake.isErrorMutex.RUnlock() - return len(fake.isErrorArgsForCall) +func (fake *FakeTask) ContextIDCallCount() int { + fake.contextIDMutex.RLock() + defer fake.contextIDMutex.RUnlock() + return len(fake.contextIDArgsForCall) } -func (fake *FakeTask) IsErrorReturns(result1 bool) { - fake.IsErrorStub = nil - fake.isErrorReturns = struct { - result1 bool +func (fake *FakeTask) ContextIDCalls(stub func() string) { + fake.contextIDMutex.Lock() + defer fake.contextIDMutex.Unlock() + fake.ContextIDStub = stub +} + +func (fake *FakeTask) ContextIDReturns(result1 string) { + fake.contextIDMutex.Lock() + defer fake.contextIDMutex.Unlock() + fake.ContextIDStub = nil + fake.contextIDReturns = struct { + result1 string }{result1} } -func (fake *FakeTask) IsErrorReturnsOnCall(i int, result1 bool) { - fake.IsErrorStub = nil - if fake.isErrorReturnsOnCall == nil { - fake.isErrorReturnsOnCall = make(map[int]struct { - result1 bool +func (fake *FakeTask) ContextIDReturnsOnCall(i int, result1 string) { + fake.contextIDMutex.Lock() + defer fake.contextIDMutex.Unlock() + fake.ContextIDStub = nil + if fake.contextIDReturnsOnCall == nil { + fake.contextIDReturnsOnCall = make(map[int]struct { + result1 string }) } - fake.isErrorReturnsOnCall[i] = struct { - result1 bool + fake.contextIDReturnsOnCall[i] = struct { + result1 string }{result1} } -func (fake *FakeTask) User() string { - fake.userMutex.Lock() - ret, specificReturn := fake.userReturnsOnCall[len(fake.userArgsForCall)] - fake.userArgsForCall = append(fake.userArgsForCall, struct{}{}) - fake.recordInvocation("User", []interface{}{}) - fake.userMutex.Unlock() - if fake.UserStub != nil { - return fake.UserStub() +func (fake *FakeTask) DebugOutput(arg1 director.TaskReporter) error { + fake.debugOutputMutex.Lock() + ret, specificReturn := fake.debugOutputReturnsOnCall[len(fake.debugOutputArgsForCall)] + fake.debugOutputArgsForCall = append(fake.debugOutputArgsForCall, struct { + arg1 director.TaskReporter + }{arg1}) + stub := fake.DebugOutputStub + fakeReturns := fake.debugOutputReturns + fake.recordInvocation("DebugOutput", []interface{}{arg1}) + fake.debugOutputMutex.Unlock() + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - return fake.userReturns.result1 + return fakeReturns.result1 } -func (fake *FakeTask) UserCallCount() int { - fake.userMutex.RLock() - defer fake.userMutex.RUnlock() - return len(fake.userArgsForCall) +func (fake *FakeTask) DebugOutputCallCount() int { + fake.debugOutputMutex.RLock() + defer fake.debugOutputMutex.RUnlock() + return len(fake.debugOutputArgsForCall) } -func (fake *FakeTask) UserReturns(result1 string) { - fake.UserStub = nil - fake.userReturns = struct { - result1 string +func (fake *FakeTask) DebugOutputCalls(stub func(director.TaskReporter) error) { + fake.debugOutputMutex.Lock() + defer fake.debugOutputMutex.Unlock() + fake.DebugOutputStub = stub +} + +func (fake *FakeTask) DebugOutputArgsForCall(i int) director.TaskReporter { + fake.debugOutputMutex.RLock() + defer fake.debugOutputMutex.RUnlock() + argsForCall := fake.debugOutputArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeTask) DebugOutputReturns(result1 error) { + fake.debugOutputMutex.Lock() + defer fake.debugOutputMutex.Unlock() + fake.DebugOutputStub = nil + fake.debugOutputReturns = struct { + result1 error }{result1} } -func (fake *FakeTask) UserReturnsOnCall(i int, result1 string) { - fake.UserStub = nil - if fake.userReturnsOnCall == nil { - fake.userReturnsOnCall = make(map[int]struct { - result1 string +func (fake *FakeTask) DebugOutputReturnsOnCall(i int, result1 error) { + fake.debugOutputMutex.Lock() + defer fake.debugOutputMutex.Unlock() + fake.DebugOutputStub = nil + if fake.debugOutputReturnsOnCall == nil { + fake.debugOutputReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.userReturnsOnCall[i] = struct { - result1 string + fake.debugOutputReturnsOnCall[i] = struct { + result1 error }{result1} } func (fake *FakeTask) DeploymentName() string { fake.deploymentNameMutex.Lock() ret, specificReturn := fake.deploymentNameReturnsOnCall[len(fake.deploymentNameArgsForCall)] - fake.deploymentNameArgsForCall = append(fake.deploymentNameArgsForCall, struct{}{}) + fake.deploymentNameArgsForCall = append(fake.deploymentNameArgsForCall, struct { + }{}) + stub := fake.DeploymentNameStub + fakeReturns := fake.deploymentNameReturns fake.recordInvocation("DeploymentName", []interface{}{}) fake.deploymentNameMutex.Unlock() - if fake.DeploymentNameStub != nil { - return fake.DeploymentNameStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - return fake.deploymentNameReturns.result1 + return fakeReturns.result1 } func (fake *FakeTask) DeploymentNameCallCount() int { @@ -417,7 +419,15 @@ func (fake *FakeTask) DeploymentNameCallCount() int { return len(fake.deploymentNameArgsForCall) } +func (fake *FakeTask) DeploymentNameCalls(stub func() string) { + fake.deploymentNameMutex.Lock() + defer fake.deploymentNameMutex.Unlock() + fake.DeploymentNameStub = stub +} + func (fake *FakeTask) DeploymentNameReturns(result1 string) { + fake.deploymentNameMutex.Lock() + defer fake.deploymentNameMutex.Unlock() fake.DeploymentNameStub = nil fake.deploymentNameReturns = struct { result1 string @@ -425,6 +435,8 @@ func (fake *FakeTask) DeploymentNameReturns(result1 string) { } func (fake *FakeTask) DeploymentNameReturnsOnCall(i int, result1 string) { + fake.deploymentNameMutex.Lock() + defer fake.deploymentNameMutex.Unlock() fake.DeploymentNameStub = nil if fake.deploymentNameReturnsOnCall == nil { fake.deploymentNameReturnsOnCall = make(map[int]struct { @@ -436,59 +448,22 @@ func (fake *FakeTask) DeploymentNameReturnsOnCall(i int, result1 string) { }{result1} } -func (fake *FakeTask) ContextID() string { - fake.contextIDMutex.Lock() - ret, specificReturn := fake.contextIDReturnsOnCall[len(fake.contextIDArgsForCall)] - fake.contextIDArgsForCall = append(fake.contextIDArgsForCall, struct{}{}) - fake.recordInvocation("ContextID", []interface{}{}) - fake.contextIDMutex.Unlock() - if fake.ContextIDStub != nil { - return fake.ContextIDStub() - } - if specificReturn { - return ret.result1 - } - return fake.contextIDReturns.result1 -} - -func (fake *FakeTask) ContextIDCallCount() int { - fake.contextIDMutex.RLock() - defer fake.contextIDMutex.RUnlock() - return len(fake.contextIDArgsForCall) -} - -func (fake *FakeTask) ContextIDReturns(result1 string) { - fake.ContextIDStub = nil - fake.contextIDReturns = struct { - result1 string - }{result1} -} - -func (fake *FakeTask) ContextIDReturnsOnCall(i int, result1 string) { - fake.ContextIDStub = nil - if fake.contextIDReturnsOnCall == nil { - fake.contextIDReturnsOnCall = make(map[int]struct { - result1 string - }) - } - fake.contextIDReturnsOnCall[i] = struct { - result1 string - }{result1} -} - func (fake *FakeTask) Description() string { fake.descriptionMutex.Lock() ret, specificReturn := fake.descriptionReturnsOnCall[len(fake.descriptionArgsForCall)] - fake.descriptionArgsForCall = append(fake.descriptionArgsForCall, struct{}{}) + fake.descriptionArgsForCall = append(fake.descriptionArgsForCall, struct { + }{}) + stub := fake.DescriptionStub + fakeReturns := fake.descriptionReturns fake.recordInvocation("Description", []interface{}{}) fake.descriptionMutex.Unlock() - if fake.DescriptionStub != nil { - return fake.DescriptionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - return fake.descriptionReturns.result1 + return fakeReturns.result1 } func (fake *FakeTask) DescriptionCallCount() int { @@ -497,7 +472,15 @@ func (fake *FakeTask) DescriptionCallCount() int { return len(fake.descriptionArgsForCall) } +func (fake *FakeTask) DescriptionCalls(stub func() string) { + fake.descriptionMutex.Lock() + defer fake.descriptionMutex.Unlock() + fake.DescriptionStub = stub +} + func (fake *FakeTask) DescriptionReturns(result1 string) { + fake.descriptionMutex.Lock() + defer fake.descriptionMutex.Unlock() fake.DescriptionStub = nil fake.descriptionReturns = struct { result1 string @@ -505,6 +488,8 @@ func (fake *FakeTask) DescriptionReturns(result1 string) { } func (fake *FakeTask) DescriptionReturnsOnCall(i int, result1 string) { + fake.descriptionMutex.Lock() + defer fake.descriptionMutex.Unlock() fake.DescriptionStub = nil if fake.descriptionReturnsOnCall == nil { fake.descriptionReturnsOnCall = make(map[int]struct { @@ -516,61 +501,23 @@ func (fake *FakeTask) DescriptionReturnsOnCall(i int, result1 string) { }{result1} } -func (fake *FakeTask) Result() string { - fake.resultMutex.Lock() - ret, specificReturn := fake.resultReturnsOnCall[len(fake.resultArgsForCall)] - fake.resultArgsForCall = append(fake.resultArgsForCall, struct{}{}) - fake.recordInvocation("Result", []interface{}{}) - fake.resultMutex.Unlock() - if fake.ResultStub != nil { - return fake.ResultStub() - } - if specificReturn { - return ret.result1 - } - return fake.resultReturns.result1 -} - -func (fake *FakeTask) ResultCallCount() int { - fake.resultMutex.RLock() - defer fake.resultMutex.RUnlock() - return len(fake.resultArgsForCall) -} - -func (fake *FakeTask) ResultReturns(result1 string) { - fake.ResultStub = nil - fake.resultReturns = struct { - result1 string - }{result1} -} - -func (fake *FakeTask) ResultReturnsOnCall(i int, result1 string) { - fake.ResultStub = nil - if fake.resultReturnsOnCall == nil { - fake.resultReturnsOnCall = make(map[int]struct { - result1 string - }) - } - fake.resultReturnsOnCall[i] = struct { - result1 string - }{result1} -} - func (fake *FakeTask) EventOutput(arg1 director.TaskReporter) error { fake.eventOutputMutex.Lock() ret, specificReturn := fake.eventOutputReturnsOnCall[len(fake.eventOutputArgsForCall)] fake.eventOutputArgsForCall = append(fake.eventOutputArgsForCall, struct { arg1 director.TaskReporter }{arg1}) + stub := fake.EventOutputStub + fakeReturns := fake.eventOutputReturns fake.recordInvocation("EventOutput", []interface{}{arg1}) fake.eventOutputMutex.Unlock() - if fake.EventOutputStub != nil { - return fake.EventOutputStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - return fake.eventOutputReturns.result1 + return fakeReturns.result1 } func (fake *FakeTask) EventOutputCallCount() int { @@ -579,13 +526,22 @@ func (fake *FakeTask) EventOutputCallCount() int { return len(fake.eventOutputArgsForCall) } +func (fake *FakeTask) EventOutputCalls(stub func(director.TaskReporter) error) { + fake.eventOutputMutex.Lock() + defer fake.eventOutputMutex.Unlock() + fake.EventOutputStub = stub +} + func (fake *FakeTask) EventOutputArgsForCall(i int) director.TaskReporter { fake.eventOutputMutex.RLock() defer fake.eventOutputMutex.RUnlock() - return fake.eventOutputArgsForCall[i].arg1 + argsForCall := fake.eventOutputArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeTask) EventOutputReturns(result1 error) { + fake.eventOutputMutex.Lock() + defer fake.eventOutputMutex.Unlock() fake.EventOutputStub = nil fake.eventOutputReturns = struct { result1 error @@ -593,6 +549,8 @@ func (fake *FakeTask) EventOutputReturns(result1 error) { } func (fake *FakeTask) EventOutputReturnsOnCall(i int, result1 error) { + fake.eventOutputMutex.Lock() + defer fake.eventOutputMutex.Unlock() fake.EventOutputStub = nil if fake.eventOutputReturnsOnCall == nil { fake.eventOutputReturnsOnCall = make(map[int]struct { @@ -604,99 +562,215 @@ func (fake *FakeTask) EventOutputReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeTask) CPIOutput(arg1 director.TaskReporter) error { - fake.cPIOutputMutex.Lock() - ret, specificReturn := fake.cPIOutputReturnsOnCall[len(fake.cPIOutputArgsForCall)] - fake.cPIOutputArgsForCall = append(fake.cPIOutputArgsForCall, struct { - arg1 director.TaskReporter - }{arg1}) - fake.recordInvocation("CPIOutput", []interface{}{arg1}) - fake.cPIOutputMutex.Unlock() - if fake.CPIOutputStub != nil { - return fake.CPIOutputStub(arg1) +func (fake *FakeTask) FinishedAt() time.Time { + fake.finishedAtMutex.Lock() + ret, specificReturn := fake.finishedAtReturnsOnCall[len(fake.finishedAtArgsForCall)] + fake.finishedAtArgsForCall = append(fake.finishedAtArgsForCall, struct { + }{}) + stub := fake.FinishedAtStub + fakeReturns := fake.finishedAtReturns + fake.recordInvocation("FinishedAt", []interface{}{}) + fake.finishedAtMutex.Unlock() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - return fake.cPIOutputReturns.result1 + return fakeReturns.result1 } -func (fake *FakeTask) CPIOutputCallCount() int { - fake.cPIOutputMutex.RLock() - defer fake.cPIOutputMutex.RUnlock() - return len(fake.cPIOutputArgsForCall) +func (fake *FakeTask) FinishedAtCallCount() int { + fake.finishedAtMutex.RLock() + defer fake.finishedAtMutex.RUnlock() + return len(fake.finishedAtArgsForCall) +} + +func (fake *FakeTask) FinishedAtCalls(stub func() time.Time) { + fake.finishedAtMutex.Lock() + defer fake.finishedAtMutex.Unlock() + fake.FinishedAtStub = stub +} + +func (fake *FakeTask) FinishedAtReturns(result1 time.Time) { + fake.finishedAtMutex.Lock() + defer fake.finishedAtMutex.Unlock() + fake.FinishedAtStub = nil + fake.finishedAtReturns = struct { + result1 time.Time + }{result1} +} + +func (fake *FakeTask) FinishedAtReturnsOnCall(i int, result1 time.Time) { + fake.finishedAtMutex.Lock() + defer fake.finishedAtMutex.Unlock() + fake.FinishedAtStub = nil + if fake.finishedAtReturnsOnCall == nil { + fake.finishedAtReturnsOnCall = make(map[int]struct { + result1 time.Time + }) + } + fake.finishedAtReturnsOnCall[i] = struct { + result1 time.Time + }{result1} +} + +func (fake *FakeTask) ID() int { + fake.iDMutex.Lock() + ret, specificReturn := fake.iDReturnsOnCall[len(fake.iDArgsForCall)] + fake.iDArgsForCall = append(fake.iDArgsForCall, struct { + }{}) + stub := fake.IDStub + fakeReturns := fake.iDReturns + fake.recordInvocation("ID", []interface{}{}) + fake.iDMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeTask) IDCallCount() int { + fake.iDMutex.RLock() + defer fake.iDMutex.RUnlock() + return len(fake.iDArgsForCall) +} + +func (fake *FakeTask) IDCalls(stub func() int) { + fake.iDMutex.Lock() + defer fake.iDMutex.Unlock() + fake.IDStub = stub +} + +func (fake *FakeTask) IDReturns(result1 int) { + fake.iDMutex.Lock() + defer fake.iDMutex.Unlock() + fake.IDStub = nil + fake.iDReturns = struct { + result1 int + }{result1} +} + +func (fake *FakeTask) IDReturnsOnCall(i int, result1 int) { + fake.iDMutex.Lock() + defer fake.iDMutex.Unlock() + fake.IDStub = nil + if fake.iDReturnsOnCall == nil { + fake.iDReturnsOnCall = make(map[int]struct { + result1 int + }) + } + fake.iDReturnsOnCall[i] = struct { + result1 int + }{result1} +} + +func (fake *FakeTask) IsError() bool { + fake.isErrorMutex.Lock() + ret, specificReturn := fake.isErrorReturnsOnCall[len(fake.isErrorArgsForCall)] + fake.isErrorArgsForCall = append(fake.isErrorArgsForCall, struct { + }{}) + stub := fake.IsErrorStub + fakeReturns := fake.isErrorReturns + fake.recordInvocation("IsError", []interface{}{}) + fake.isErrorMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeTask) IsErrorCallCount() int { + fake.isErrorMutex.RLock() + defer fake.isErrorMutex.RUnlock() + return len(fake.isErrorArgsForCall) } -func (fake *FakeTask) CPIOutputArgsForCall(i int) director.TaskReporter { - fake.cPIOutputMutex.RLock() - defer fake.cPIOutputMutex.RUnlock() - return fake.cPIOutputArgsForCall[i].arg1 +func (fake *FakeTask) IsErrorCalls(stub func() bool) { + fake.isErrorMutex.Lock() + defer fake.isErrorMutex.Unlock() + fake.IsErrorStub = stub } -func (fake *FakeTask) CPIOutputReturns(result1 error) { - fake.CPIOutputStub = nil - fake.cPIOutputReturns = struct { - result1 error +func (fake *FakeTask) IsErrorReturns(result1 bool) { + fake.isErrorMutex.Lock() + defer fake.isErrorMutex.Unlock() + fake.IsErrorStub = nil + fake.isErrorReturns = struct { + result1 bool }{result1} } -func (fake *FakeTask) CPIOutputReturnsOnCall(i int, result1 error) { - fake.CPIOutputStub = nil - if fake.cPIOutputReturnsOnCall == nil { - fake.cPIOutputReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeTask) IsErrorReturnsOnCall(i int, result1 bool) { + fake.isErrorMutex.Lock() + defer fake.isErrorMutex.Unlock() + fake.IsErrorStub = nil + if fake.isErrorReturnsOnCall == nil { + fake.isErrorReturnsOnCall = make(map[int]struct { + result1 bool }) } - fake.cPIOutputReturnsOnCall[i] = struct { - result1 error + fake.isErrorReturnsOnCall[i] = struct { + result1 bool }{result1} } -func (fake *FakeTask) DebugOutput(arg1 director.TaskReporter) error { - fake.debugOutputMutex.Lock() - ret, specificReturn := fake.debugOutputReturnsOnCall[len(fake.debugOutputArgsForCall)] - fake.debugOutputArgsForCall = append(fake.debugOutputArgsForCall, struct { - arg1 director.TaskReporter - }{arg1}) - fake.recordInvocation("DebugOutput", []interface{}{arg1}) - fake.debugOutputMutex.Unlock() - if fake.DebugOutputStub != nil { - return fake.DebugOutputStub(arg1) +func (fake *FakeTask) Result() string { + fake.resultMutex.Lock() + ret, specificReturn := fake.resultReturnsOnCall[len(fake.resultArgsForCall)] + fake.resultArgsForCall = append(fake.resultArgsForCall, struct { + }{}) + stub := fake.ResultStub + fakeReturns := fake.resultReturns + fake.recordInvocation("Result", []interface{}{}) + fake.resultMutex.Unlock() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - return fake.debugOutputReturns.result1 + return fakeReturns.result1 } -func (fake *FakeTask) DebugOutputCallCount() int { - fake.debugOutputMutex.RLock() - defer fake.debugOutputMutex.RUnlock() - return len(fake.debugOutputArgsForCall) +func (fake *FakeTask) ResultCallCount() int { + fake.resultMutex.RLock() + defer fake.resultMutex.RUnlock() + return len(fake.resultArgsForCall) } -func (fake *FakeTask) DebugOutputArgsForCall(i int) director.TaskReporter { - fake.debugOutputMutex.RLock() - defer fake.debugOutputMutex.RUnlock() - return fake.debugOutputArgsForCall[i].arg1 +func (fake *FakeTask) ResultCalls(stub func() string) { + fake.resultMutex.Lock() + defer fake.resultMutex.Unlock() + fake.ResultStub = stub } -func (fake *FakeTask) DebugOutputReturns(result1 error) { - fake.DebugOutputStub = nil - fake.debugOutputReturns = struct { - result1 error +func (fake *FakeTask) ResultReturns(result1 string) { + fake.resultMutex.Lock() + defer fake.resultMutex.Unlock() + fake.ResultStub = nil + fake.resultReturns = struct { + result1 string }{result1} } -func (fake *FakeTask) DebugOutputReturnsOnCall(i int, result1 error) { - fake.DebugOutputStub = nil - if fake.debugOutputReturnsOnCall == nil { - fake.debugOutputReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeTask) ResultReturnsOnCall(i int, result1 string) { + fake.resultMutex.Lock() + defer fake.resultMutex.Unlock() + fake.ResultStub = nil + if fake.resultReturnsOnCall == nil { + fake.resultReturnsOnCall = make(map[int]struct { + result1 string }) } - fake.debugOutputReturnsOnCall[i] = struct { - result1 error + fake.resultReturnsOnCall[i] = struct { + result1 string }{result1} } @@ -706,15 +780,17 @@ func (fake *FakeTask) ResultOutput(arg1 director.TaskReporter) error { fake.resultOutputArgsForCall = append(fake.resultOutputArgsForCall, struct { arg1 director.TaskReporter }{arg1}) + stub := fake.ResultOutputStub + fakeReturns := fake.resultOutputReturns fake.recordInvocation("ResultOutput", []interface{}{arg1}) fake.resultOutputMutex.Unlock() - if fake.ResultOutputStub != nil { - return fake.ResultOutputStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - return fake.resultOutputReturns.result1 + return fakeReturns.result1 } func (fake *FakeTask) ResultOutputCallCount() int { @@ -723,13 +799,22 @@ func (fake *FakeTask) ResultOutputCallCount() int { return len(fake.resultOutputArgsForCall) } +func (fake *FakeTask) ResultOutputCalls(stub func(director.TaskReporter) error) { + fake.resultOutputMutex.Lock() + defer fake.resultOutputMutex.Unlock() + fake.ResultOutputStub = stub +} + func (fake *FakeTask) ResultOutputArgsForCall(i int) director.TaskReporter { fake.resultOutputMutex.RLock() defer fake.resultOutputMutex.RUnlock() - return fake.resultOutputArgsForCall[i].arg1 + argsForCall := fake.resultOutputArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeTask) ResultOutputReturns(result1 error) { + fake.resultOutputMutex.Lock() + defer fake.resultOutputMutex.Unlock() fake.ResultOutputStub = nil fake.resultOutputReturns = struct { result1 error @@ -737,6 +822,8 @@ func (fake *FakeTask) ResultOutputReturns(result1 error) { } func (fake *FakeTask) ResultOutputReturnsOnCall(i int, result1 error) { + fake.resultOutputMutex.Lock() + defer fake.resultOutputMutex.Unlock() fake.ResultOutputStub = nil if fake.resultOutputReturnsOnCall == nil { fake.resultOutputReturnsOnCall = make(map[int]struct { @@ -748,80 +835,203 @@ func (fake *FakeTask) ResultOutputReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeTask) Cancel() error { - fake.cancelMutex.Lock() - ret, specificReturn := fake.cancelReturnsOnCall[len(fake.cancelArgsForCall)] - fake.cancelArgsForCall = append(fake.cancelArgsForCall, struct{}{}) - fake.recordInvocation("Cancel", []interface{}{}) - fake.cancelMutex.Unlock() - if fake.CancelStub != nil { - return fake.CancelStub() +func (fake *FakeTask) StartedAt() time.Time { + fake.startedAtMutex.Lock() + ret, specificReturn := fake.startedAtReturnsOnCall[len(fake.startedAtArgsForCall)] + fake.startedAtArgsForCall = append(fake.startedAtArgsForCall, struct { + }{}) + stub := fake.StartedAtStub + fakeReturns := fake.startedAtReturns + fake.recordInvocation("StartedAt", []interface{}{}) + fake.startedAtMutex.Unlock() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - return fake.cancelReturns.result1 + return fakeReturns.result1 } -func (fake *FakeTask) CancelCallCount() int { - fake.cancelMutex.RLock() - defer fake.cancelMutex.RUnlock() - return len(fake.cancelArgsForCall) +func (fake *FakeTask) StartedAtCallCount() int { + fake.startedAtMutex.RLock() + defer fake.startedAtMutex.RUnlock() + return len(fake.startedAtArgsForCall) } -func (fake *FakeTask) CancelReturns(result1 error) { - fake.CancelStub = nil - fake.cancelReturns = struct { - result1 error +func (fake *FakeTask) StartedAtCalls(stub func() time.Time) { + fake.startedAtMutex.Lock() + defer fake.startedAtMutex.Unlock() + fake.StartedAtStub = stub +} + +func (fake *FakeTask) StartedAtReturns(result1 time.Time) { + fake.startedAtMutex.Lock() + defer fake.startedAtMutex.Unlock() + fake.StartedAtStub = nil + fake.startedAtReturns = struct { + result1 time.Time }{result1} } -func (fake *FakeTask) CancelReturnsOnCall(i int, result1 error) { - fake.CancelStub = nil - if fake.cancelReturnsOnCall == nil { - fake.cancelReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeTask) StartedAtReturnsOnCall(i int, result1 time.Time) { + fake.startedAtMutex.Lock() + defer fake.startedAtMutex.Unlock() + fake.StartedAtStub = nil + if fake.startedAtReturnsOnCall == nil { + fake.startedAtReturnsOnCall = make(map[int]struct { + result1 time.Time }) } - fake.cancelReturnsOnCall[i] = struct { - result1 error + fake.startedAtReturnsOnCall[i] = struct { + result1 time.Time }{result1} } -func (fake *FakeTask) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.iDMutex.RLock() - defer fake.iDMutex.RUnlock() - fake.startedAtMutex.RLock() - defer fake.startedAtMutex.RUnlock() - fake.finishedAtMutex.RLock() - defer fake.finishedAtMutex.RUnlock() +func (fake *FakeTask) State() string { + fake.stateMutex.Lock() + ret, specificReturn := fake.stateReturnsOnCall[len(fake.stateArgsForCall)] + fake.stateArgsForCall = append(fake.stateArgsForCall, struct { + }{}) + stub := fake.StateStub + fakeReturns := fake.stateReturns + fake.recordInvocation("State", []interface{}{}) + fake.stateMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeTask) StateCallCount() int { fake.stateMutex.RLock() defer fake.stateMutex.RUnlock() - fake.isErrorMutex.RLock() - defer fake.isErrorMutex.RUnlock() + return len(fake.stateArgsForCall) +} + +func (fake *FakeTask) StateCalls(stub func() string) { + fake.stateMutex.Lock() + defer fake.stateMutex.Unlock() + fake.StateStub = stub +} + +func (fake *FakeTask) StateReturns(result1 string) { + fake.stateMutex.Lock() + defer fake.stateMutex.Unlock() + fake.StateStub = nil + fake.stateReturns = struct { + result1 string + }{result1} +} + +func (fake *FakeTask) StateReturnsOnCall(i int, result1 string) { + fake.stateMutex.Lock() + defer fake.stateMutex.Unlock() + fake.StateStub = nil + if fake.stateReturnsOnCall == nil { + fake.stateReturnsOnCall = make(map[int]struct { + result1 string + }) + } + fake.stateReturnsOnCall[i] = struct { + result1 string + }{result1} +} + +func (fake *FakeTask) User() string { + fake.userMutex.Lock() + ret, specificReturn := fake.userReturnsOnCall[len(fake.userArgsForCall)] + fake.userArgsForCall = append(fake.userArgsForCall, struct { + }{}) + stub := fake.UserStub + fakeReturns := fake.userReturns + fake.recordInvocation("User", []interface{}{}) + fake.userMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeTask) UserCallCount() int { fake.userMutex.RLock() defer fake.userMutex.RUnlock() - fake.deploymentNameMutex.RLock() - defer fake.deploymentNameMutex.RUnlock() + return len(fake.userArgsForCall) +} + +func (fake *FakeTask) UserCalls(stub func() string) { + fake.userMutex.Lock() + defer fake.userMutex.Unlock() + fake.UserStub = stub +} + +func (fake *FakeTask) UserReturns(result1 string) { + fake.userMutex.Lock() + defer fake.userMutex.Unlock() + fake.UserStub = nil + fake.userReturns = struct { + result1 string + }{result1} +} + +func (fake *FakeTask) UserReturnsOnCall(i int, result1 string) { + fake.userMutex.Lock() + defer fake.userMutex.Unlock() + fake.UserStub = nil + if fake.userReturnsOnCall == nil { + fake.userReturnsOnCall = make(map[int]struct { + result1 string + }) + } + fake.userReturnsOnCall[i] = struct { + result1 string + }{result1} +} + +func (fake *FakeTask) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.cPIOutputMutex.RLock() + defer fake.cPIOutputMutex.RUnlock() + fake.cancelMutex.RLock() + defer fake.cancelMutex.RUnlock() fake.contextIDMutex.RLock() defer fake.contextIDMutex.RUnlock() + fake.debugOutputMutex.RLock() + defer fake.debugOutputMutex.RUnlock() + fake.deploymentNameMutex.RLock() + defer fake.deploymentNameMutex.RUnlock() fake.descriptionMutex.RLock() defer fake.descriptionMutex.RUnlock() - fake.resultMutex.RLock() - defer fake.resultMutex.RUnlock() fake.eventOutputMutex.RLock() defer fake.eventOutputMutex.RUnlock() - fake.cPIOutputMutex.RLock() - defer fake.cPIOutputMutex.RUnlock() - fake.debugOutputMutex.RLock() - defer fake.debugOutputMutex.RUnlock() + fake.finishedAtMutex.RLock() + defer fake.finishedAtMutex.RUnlock() + fake.iDMutex.RLock() + defer fake.iDMutex.RUnlock() + fake.isErrorMutex.RLock() + defer fake.isErrorMutex.RUnlock() + fake.resultMutex.RLock() + defer fake.resultMutex.RUnlock() fake.resultOutputMutex.RLock() defer fake.resultOutputMutex.RUnlock() - fake.cancelMutex.RLock() - defer fake.cancelMutex.RUnlock() - return fake.invocations + fake.startedAtMutex.RLock() + defer fake.startedAtMutex.RUnlock() + fake.stateMutex.RLock() + defer fake.stateMutex.RUnlock() + fake.userMutex.RLock() + defer fake.userMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeTask) recordInvocation(key string, args []interface{}) { diff --git a/docs/cli_workflow.md b/docs/cli_workflow.md index 85a6fe0f6..fa239cf78 100644 --- a/docs/cli_workflow.md +++ b/docs/cli_workflow.md @@ -26,31 +26,23 @@ The compiled packages and rendered job templates are stored in a `~/.bosh//blobs` endpoint. For each of the templates specified, the CLI downloads the corresponding job template from the blobstore, renders the template with the properties specified for the job in the deployment manifest. Once all the templates are rendered, the CLI uploads the archive of all the rendered templates to the blobstore and generates an `apply` message. This `apply` message contains the list of all packages, spec of the templates archive with uploaded blob ID, networks spec parsed from deployment manifest and configuration hash which is a digest of all rendered job template files. -## 13. Sending start message +## 12. Sending start message Once the `apply` task is finished the CLI sends a `start` message to the agent which starts installed jobs. diff --git a/installation/installation.go b/installation/installation.go index 1293b5b35..235c891f1 100644 --- a/installation/installation.go +++ b/installation/installation.go @@ -2,40 +2,28 @@ package installation import ( biinstallmanifest "github.com/cloudfoundry/bosh-cli/installation/manifest" - biregistry "github.com/cloudfoundry/bosh-cli/registry" - biui "github.com/cloudfoundry/bosh-cli/ui" - bosherr "github.com/cloudfoundry/bosh-utils/errors" - boshlog "github.com/cloudfoundry/bosh-utils/logger" ) type Installation interface { Target() Target Job() InstalledJob - WithRunningRegistry(boshlog.Logger, biui.Stage, func() error) error - StartRegistry() error - StopRegistry() error } type installation struct { - target Target - job InstalledJob - manifest biinstallmanifest.Manifest - registryServerManager biregistry.ServerManager - - registryServer biregistry.Server + target Target + job InstalledJob + manifest biinstallmanifest.Manifest } func NewInstallation( target Target, job InstalledJob, manifest biinstallmanifest.Manifest, - registryServerManager biregistry.ServerManager, ) Installation { return &installation{ - target: target, - job: job, - manifest: manifest, - registryServerManager: registryServerManager, + target: target, + job: job, + manifest: manifest, } } @@ -46,52 +34,3 @@ func (i *installation) Target() Target { func (i *installation) Job() InstalledJob { return i.job } - -func (i *installation) WithRunningRegistry(logger boshlog.Logger, stage biui.Stage, fn func() error) error { - err := stage.Perform("Starting registry", func() error { - return i.StartRegistry() - }) - if err != nil { - return err - } - defer i.stopRegistryNice(logger, stage) - return fn() -} - -func (i *installation) stopRegistryNice(logger boshlog.Logger, stage biui.Stage) { - err := stage.Perform("Stopping registry", func() error { - return i.StopRegistry() - }) - if err != nil { - logger.Warn("installation", "Registry failed to stop: %s", err) - } -} - -func (i *installation) StartRegistry() error { - if !i.manifest.Registry.IsEmpty() { - if i.registryServer != nil { - return bosherr.Error("Registry already started") - } - config := i.manifest.Registry - registryServer, err := i.registryServerManager.Start(config.Username, config.Password, config.Host, config.Port) - if err != nil { - return bosherr.WrapError(err, "Starting registry") - } - i.registryServer = registryServer - } - return nil -} - -func (i *installation) StopRegistry() error { - if !i.manifest.Registry.IsEmpty() { - if i.registryServer == nil { - return bosherr.Error("Registry must be started before it can be stopped") - } - err := i.registryServer.Stop() - if err != nil { - return bosherr.WrapError(err, "Stopping registry") - } - i.registryServer = nil - } - return nil -} diff --git a/installation/installation_test.go b/installation/installation_test.go deleted file mode 100644 index 587d86c0f..000000000 --- a/installation/installation_test.go +++ /dev/null @@ -1,273 +0,0 @@ -package installation_test - -import ( - "errors" - "log" - - . "github.com/cloudfoundry/bosh-cli/installation" - - biinstallmanifest "github.com/cloudfoundry/bosh-cli/installation/manifest" - mock_registry "github.com/cloudfoundry/bosh-cli/registry/mocks" - test_support_mocks "github.com/cloudfoundry/bosh-cli/test_support/mocks" - fakebiui "github.com/cloudfoundry/bosh-cli/ui/fakes" - boshlog "github.com/cloudfoundry/bosh-utils/logger" - "github.com/golang/mock/gomock" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/onsi/gomega/gbytes" -) - -var _ = Describe("Installation", func() { - var mockCtrl *gomock.Controller - - BeforeEach(func() { - mockCtrl = gomock.NewController(GinkgoT()) - }) - - AfterEach(func() { - mockCtrl.Finish() - }) - - var ( - manifest biinstallmanifest.Manifest - mockRegistryServerManager *mock_registry.MockServerManager - mockRegistryServer *mock_registry.MockServer - - target Target - installedJob InstalledJob - ) - - var newInstalation = func() Installation { - return NewInstallation(target, installedJob, manifest, mockRegistryServerManager) - } - - BeforeEach(func() { - manifest = biinstallmanifest.Manifest{} - - mockRegistryServerManager = mock_registry.NewMockServerManager(mockCtrl) - mockRegistryServer = mock_registry.NewMockServer(mockCtrl) - - target = NewTarget("fake-installation-path") - - installedJob = NewInstalledJob(RenderedJobRef{Name: "cpi"}, "fake-job-path") - }) - - Describe("WithRunningRegistry", func() { - var ( - startCall, spyCall, stopCall *gomock.Call - spy *test_support_mocks.MockSpy - logBuffer *gbytes.Buffer - logger boshlog.Logger - fakeStage *fakebiui.FakeStage - ) - - BeforeEach(func() { - manifest.Registry = biinstallmanifest.Registry{ - Username: "fake-username", - Password: "fake-password", - Host: "fake-host", - Port: 123, - } - - spy = test_support_mocks.NewMockSpy(mockCtrl) - startCall = mockRegistryServerManager.EXPECT().Start("fake-username", "fake-password", "fake-host", 123).Return(mockRegistryServer, nil) - spyCall = spy.EXPECT().Record() - stopCall = mockRegistryServer.EXPECT().Stop().Return(nil) - - logBuffer = gbytes.NewBuffer() - goLogger := log.New(logBuffer, "", log.LstdFlags) - logger = boshlog.New(boshlog.LevelWarn, goLogger) - fakeStage = fakebiui.NewFakeStage() - }) - - It("starts the registry before calling the function", func() { - spyCall.After(startCall) - - err := newInstalation().WithRunningRegistry(logger, fakeStage, func() error { - spy.Record() - return nil - }) - Expect(err).NotTo(HaveOccurred()) - }) - - It("performs stages for starting and stopping the registry", func() { - err := newInstalation().WithRunningRegistry(logger, fakeStage, func() error { - spy.Record() - return nil - }) - Expect(err).NotTo(HaveOccurred()) - - Expect(fakeStage.PerformCalls).To(ContainElement(&fakebiui.PerformCall{ - Name: "Starting registry", - })) - Expect(fakeStage.PerformCalls).To(ContainElement(&fakebiui.PerformCall{ - Name: "Stopping registry", - })) - }) - - Context("the function succeeds", func() { - It("stops the registry and returns nil", func() { - stopCall.After(spyCall) - - err := newInstalation().WithRunningRegistry(logger, fakeStage, func() error { - spy.Record() - return nil - }) - Expect(err).NotTo(HaveOccurred()) - }) - }) - - Context("the function fails", func() { - It("stops the registry and returns the error", func() { - stopCall.After(spyCall) - err := newInstalation().WithRunningRegistry(logger, fakeStage, func() error { - spy.Record() - return errors.New("blarg!") - }) - Expect(err).To(HaveOccurred()) - }) - }) - - Context("when starting registry fails", func() { - It("returns an error and doesn't call the function", func() { - startCall.Return(mockRegistryServer, errors.New("registry-start-error")) - spyCall.Times(0) - stopCall.Times(0) - - err := newInstalation().WithRunningRegistry(logger, fakeStage, func() error { - spy.Record() - return nil - }) - - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(Equal("Starting registry: registry-start-error")) - }) - }) - - Context("when stopping registry fails", func() { - Context("when the function fails", func() { - It("logs a warning and returns the function error", func() { - stopCall.Return(errors.New("registry-stop-error")) - - err := newInstalation().WithRunningRegistry(logger, fakeStage, func() error { - spy.Record() - return errors.New("blarg!") - }) - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(Equal("blarg!")) - - Expect(logBuffer).To(gbytes.Say("registry-stop-error")) - }) - }) - - Context("when the function succeeds", func() { - It("logs a warning and returns nil", func() { - err := newInstalation().WithRunningRegistry(logger, fakeStage, func() error { - spy.Record() - return nil - }) - Expect(err).NotTo(HaveOccurred()) - }) - }) - }) - }) - - Describe("StartRegistry", func() { - Context("when registry config is not empty", func() { - BeforeEach(func() { - manifest.Registry = biinstallmanifest.Registry{ - Username: "fake-username", - Password: "fake-password", - Host: "fake-host", - Port: 123, - } - }) - - It("starts the registry", func() { - mockRegistryServerManager.EXPECT().Start("fake-username", "fake-password", "fake-host", 123).Return(mockRegistryServer, nil) - - err := newInstalation().StartRegistry() - Expect(err).NotTo(HaveOccurred()) - }) - - Context("when starting registry fails", func() { - BeforeEach(func() { - mockRegistryServerManager.EXPECT().Start("fake-username", "fake-password", "fake-host", 123).Return(nil, errors.New("fake-registry-start-error")) - }) - - It("returns an error", func() { - err := newInstalation().StartRegistry() - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("fake-registry-start-error")) - }) - }) - }) - - Context("when registry config is empty", func() { - BeforeEach(func() { - manifest.Registry = biinstallmanifest.Registry{} - }) - - It("does not start the registry", func() { - err := newInstalation().StartRegistry() - Expect(err).ToNot(HaveOccurred()) - }) - }) - }) - - Describe("StopRegistry", func() { - Context("when registry has been started", func() { - var installation Installation - - BeforeEach(func() { - manifest.Registry = biinstallmanifest.Registry{ - Username: "fake-username", - Password: "fake-password", - Host: "fake-host", - Port: 123, - } - - installation = newInstalation() - - mockRegistryServerManager.EXPECT().Start("fake-username", "fake-password", "fake-host", 123).Return(mockRegistryServer, nil) - err := installation.StartRegistry() - Expect(err).ToNot(HaveOccurred()) - }) - - It("stops the registry", func() { - mockRegistryServer.EXPECT().Stop() - - err := installation.StopRegistry() - Expect(err).NotTo(HaveOccurred()) - }) - }) - - Context("when registry is configured but has not been started", func() { - BeforeEach(func() { - manifest.Registry = biinstallmanifest.Registry{ - Username: "fake-username", - Password: "fake-password", - Host: "fake-host", - Port: 123, - } - }) - - It("returns an error", func() { - err := newInstalation().StopRegistry() - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("Registry must be started before it can be stopped")) - }) - }) - - Context("when registry config is empty", func() { - BeforeEach(func() { - manifest.Registry = biinstallmanifest.Registry{} - }) - - It("does not stop the registry", func() { - err := newInstalation().StopRegistry() - Expect(err).ToNot(HaveOccurred()) - }) - }) - }) -}) diff --git a/installation/installer.go b/installation/installer.go index 482baed7e..fe5749930 100644 --- a/installation/installer.go +++ b/installation/installer.go @@ -6,7 +6,6 @@ import ( "github.com/cloudfoundry/bosh-cli/installation/blobextract" biinstallmanifest "github.com/cloudfoundry/bosh-cli/installation/manifest" - biregistry "github.com/cloudfoundry/bosh-cli/registry" biui "github.com/cloudfoundry/bosh-cli/ui" bosherr "github.com/cloudfoundry/bosh-utils/errors" boshlog "github.com/cloudfoundry/bosh-utils/logger" @@ -27,14 +26,13 @@ type Installer interface { } type installer struct { - target Target - jobRenderer JobRenderer - jobResolver JobResolver - packageCompiler PackageCompiler - blobExtractor blobextract.Extractor - registryServerManager biregistry.ServerManager - logger boshlog.Logger - logTag string + target Target + jobRenderer JobRenderer + jobResolver JobResolver + packageCompiler PackageCompiler + blobExtractor blobextract.Extractor + logger boshlog.Logger + logTag string } func NewInstaller( @@ -43,18 +41,16 @@ func NewInstaller( jobResolver JobResolver, packageCompiler PackageCompiler, blobExtractor blobextract.Extractor, - registryServerManager biregistry.ServerManager, logger boshlog.Logger, ) Installer { return &installer{ - target: target, - jobRenderer: jobRenderer, - jobResolver: jobResolver, - packageCompiler: packageCompiler, - blobExtractor: blobExtractor, - registryServerManager: registryServerManager, - logger: logger, - logTag: "installer", + target: target, + jobRenderer: jobRenderer, + jobResolver: jobResolver, + packageCompiler: packageCompiler, + blobExtractor: blobExtractor, + logger: logger, + logTag: "installer", } } @@ -94,7 +90,6 @@ func (i *installer) Install(manifest biinstallmanifest.Manifest, stage biui.Stag i.target, installedJob, manifest, - i.registryServerManager, ), nil } diff --git a/installation/installer_factory.go b/installation/installer_factory.go index f51ca026f..c7bb97ddc 100644 --- a/installation/installer_factory.go +++ b/installation/installer_factory.go @@ -5,7 +5,6 @@ import ( biindex "github.com/cloudfoundry/bosh-cli/index" "github.com/cloudfoundry/bosh-cli/installation/blobextract" biinstallpkg "github.com/cloudfoundry/bosh-cli/installation/pkg" - biregistry "github.com/cloudfoundry/bosh-cli/registry" bistatejob "github.com/cloudfoundry/bosh-cli/state/job" bistatepkg "github.com/cloudfoundry/bosh-cli/state/pkg" bitemplate "github.com/cloudfoundry/bosh-cli/templatescompiler" @@ -29,7 +28,6 @@ type installerFactory struct { extractor boshcmd.Compressor releaseJobResolver bideplrel.JobResolver uuidGenerator boshuuid.Generator - registryServerManager biregistry.ServerManager logger boshlog.Logger logTag string fs boshsys.FileSystem @@ -42,7 +40,6 @@ func NewInstallerFactory( extractor boshcmd.Compressor, releaseJobResolver bideplrel.JobResolver, uuidGenerator boshuuid.Generator, - registryServerManager biregistry.ServerManager, logger boshlog.Logger, fs boshsys.FileSystem, digestCreateAlgorithms []boshcrypto.Algorithm, @@ -53,7 +50,6 @@ func NewInstallerFactory( extractor: extractor, releaseJobResolver: releaseJobResolver, uuidGenerator: uuidGenerator, - registryServerManager: registryServerManager, logger: logger, logTag: "installer", fs: fs, @@ -79,7 +75,6 @@ func (f *installerFactory) NewInstaller(target Target) Installer { context.JobResolver(), context.PackageCompiler(), context.BlobExtractor(), - f.registryServerManager, f.logger, ) } diff --git a/installation/installer_test.go b/installation/installer_test.go index b384988f8..954c22e4f 100644 --- a/installation/installer_test.go +++ b/installation/installer_test.go @@ -9,7 +9,6 @@ import ( "github.com/cloudfoundry/bosh-cli/installation/blobextract/blobextractfakes" mock_install "github.com/cloudfoundry/bosh-cli/installation/mocks" - mock_registry "github.com/cloudfoundry/bosh-cli/registry/mocks" "github.com/golang/mock/gomock" biinstallmanifest "github.com/cloudfoundry/bosh-cli/installation/manifest" @@ -32,12 +31,11 @@ var _ = Describe("Installer", func() { }) var ( - installationManifest biinstallmanifest.Manifest - mockJobRenderer *mock_install.MockJobRenderer - mockJobResolver *mock_install.MockJobResolver - mockPackageCompiler *mock_install.MockPackageCompiler - fakeExtractor *blobextractfakes.FakeExtractor - mockRegistryServerManager *mock_registry.MockServerManager + installationManifest biinstallmanifest.Manifest + mockJobRenderer *mock_install.MockJobRenderer + mockJobResolver *mock_install.MockJobResolver + mockPackageCompiler *mock_install.MockPackageCompiler + fakeExtractor *blobextractfakes.FakeExtractor logger boshlog.Logger @@ -53,7 +51,6 @@ var _ = Describe("Installer", func() { mockJobResolver = mock_install.NewMockJobResolver(mockCtrl) mockPackageCompiler = mock_install.NewMockPackageCompiler(mockCtrl) fakeExtractor = &blobextractfakes.FakeExtractor{} - mockRegistryServerManager = mock_registry.NewMockServerManager(mockCtrl) target = NewTarget("fake-installation-path") installationManifest = biinstallmanifest.Manifest{ @@ -71,7 +68,6 @@ var _ = Describe("Installer", func() { mockJobResolver, mockPackageCompiler, fakeExtractor, - mockRegistryServerManager, logger, ) }) @@ -145,7 +141,6 @@ var _ = Describe("Installer", func() { target, installedJob, installationManifest, - mockRegistryServerManager, ) }) diff --git a/installation/manifest/manifest.go b/installation/manifest/manifest.go index c32cde8b1..cb95407b4 100644 --- a/installation/manifest/manifest.go +++ b/installation/manifest/manifest.go @@ -10,7 +10,6 @@ type Manifest struct { Properties biproperty.Map Mbus string Cert Certificate - Registry Registry } type Certificate struct { @@ -22,18 +21,6 @@ type ReleaseJobRef struct { Release string } -type Registry struct { - Username string - Password string - Host string - Port int - SSHTunnel SSHTunnel -} - -func (r Registry) IsEmpty() bool { - return r == Registry{} -} - type SSHTunnel struct { User string Host string @@ -41,19 +28,3 @@ type SSHTunnel struct { Password string PrivateKey string `yaml:"private_key"` } - -func (m *Manifest) PopulateRegistry(username string, password string, host string, port int, sshTunnel SSHTunnel) { - m.Properties["registry"] = biproperty.Map{ - "host": host, - "port": port, - "username": username, - "password": password, - } - m.Registry = Registry{ - Username: username, - Password: password, - Host: host, - Port: port, - SSHTunnel: sshTunnel, - } -} diff --git a/installation/manifest/parser.go b/installation/manifest/parser.go index 93d259401..33585782f 100644 --- a/installation/manifest/parser.go +++ b/installation/manifest/parser.go @@ -127,14 +127,6 @@ func (p *parser) Parse(path string, vars boshtpl.Variables, op patch.Op, release } installationManifest.Properties = properties - if comboManifest.CloudProvider.HasSSHTunnel() { - password, err := p.uuidGenerator.Generate() - if err != nil { - return Manifest{}, bosherr.WrapError(err, "Generating registry password") - } - installationManifest.PopulateRegistry("registry", password, "127.0.0.1", 6901, comboManifest.CloudProvider.SSHTunnel) - } - err = p.validator.Validate(installationManifest, releaseSetManifest) if err != nil { return Manifest{}, bosherr.WrapError(err, "Validating installation manifest") diff --git a/installation/manifest/parser_test.go b/installation/manifest/parser_test.go index 1782d1eb4..b89cc2791 100644 --- a/installation/manifest/parser_test.go +++ b/installation/manifest/parser_test.go @@ -160,39 +160,8 @@ cloud_provider: Name: "fake-cpi-job-name", Release: "fake-cpi-release-name", }, - Properties: biproperty.Map{ - "registry": biproperty.Map{ - "host": "127.0.0.1", - "port": 6901, - "username": "registry", - "password": "fake-uuid", - }, - }, - Registry: manifest.Registry{ - SSHTunnel: manifest.SSHTunnel{ - Host: "54.34.56.8", - Port: 22, - User: "fake-ssh-user", - PrivateKey: `-----BEGIN RSA PRIVATE KEY----- -MIIByQIBAAJhANs/tl5Tv7CD0Gz5TYocWZbGwHIjDU8dY1oszVMb8bhybfF4y88k -7oaFYlyZ0oZATpx1EGXZAcgDszq5XSXhYKWQL6+u0qEylWsbra7qQefm2+WbZDfh -ugqbt+kD0F6CjQIDAQABAmBS8yDxQShGBSjnAc9XUHCIvftzc1WGuCytokOwjOMA -ELMN59DcNzHTTUWwmTXwOwWPnz1c7PYRnFmy99dEcyWeugU0C5QS96XWwGdXcOjY -Kr1q/yDJZh416/nWkyGlIOECMQDvT36aXqf0xZHb47aEWmeezGS9IyK1BDMEqvcD -DNU/GK86ymoEqtIyQbnuBUqSbkUCMQDqigydhP7j1IGABdVrWXX/WFhABjAmNWrf -YYEecgjhjdM83QSkpwu7tYCHtZjny6kCMCZO6GpXurUxJ0823ZHEUxAVkg7A4B5w -BKa7o30GgeBu2CYmHuCOY8WNxfC3Qh+8rQIwGQIXTkR8GTbzh/8XPpcPaea1oj4G -rExN1PvElMZ8A/DncTnv4M6fBajYx5+pai3hAjBui9LTgI1fZeOtgBEo+Q3ZLm/O -bX621YeY03FF5+TCF6Zwk4yT/NWMwJz8Fpb9QQA= ------END RSA PRIVATE KEY----- -`, - }, - Host: "127.0.0.1", - Port: 6901, - Username: "registry", - Password: "fake-uuid", - }, - Mbus: "http://fake-mbus-user:fake-mbus-password@0.0.0.0:6868", + Properties: biproperty.Map{}, + Mbus: "http://fake-mbus-user:fake-mbus-password@0.0.0.0:6868", })) }) @@ -272,42 +241,8 @@ cloud_provider: Name: "fake-cpi-job-name", Release: "fake-cpi-release-name", }, - Properties: biproperty.Map{ - "registry": biproperty.Map{ - "host": "127.0.0.1", - "port": 6901, - "username": "registry", - "password": "fake-uuid", - }, - }, - Registry: manifest.Registry{ - SSHTunnel: manifest.SSHTunnel{ - Host: "54.34.56.8", - Port: 22, - User: "fake-ssh-user", - PrivateKey: `-----BEGIN OPENSSH PRIVATE KEY----- -b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAdwAAAAdz -c2gtcnNhAAAAAwEAAQAAAGEA2z+2XlO/sIPQbPlNihxZlsbAciMNTx1jWizNUxvx -uHJt8XjLzyTuhoViXJnShkBOnHUQZdkByAOzOrldJeFgpZAvr67SoTKVaxutrupB -5+bb5ZtkN+G6Cpu36QPQXoKNAAABoOJ0x/nidMf5AAAAB3NzaC1yc2EAAABhANs/ -tl5Tv7CD0Gz5TYocWZbGwHIjDU8dY1oszVMb8bhybfF4y88k7oaFYlyZ0oZATpx1 -EGXZAcgDszq5XSXhYKWQL6+u0qEylWsbra7qQefm2+WbZDfhugqbt+kD0F6CjQAA -AAMBAAEAAABgUvMg8UEoRgUo5wHPV1BwiL37c3NVhrgsraJDsIzjABCzDefQ3Dcx -001FsJk18DsFj589XOz2EZxZsvfXRHMlnroFNAuUEvel1sBnV3Do2Cq9av8gyWYe -Nev51pMhpSDhAAAAMG6L0tOAjV9l462AESj5Ddkub85tfrbVh5jTcUXn5MIXpnCT -jJP81YzAnPwWlv1BAAAAADEA709+ml6n9MWR2+O2hFpnnsxkvSMitQQzBKr3AwzV -PxivOspqBKrSMkG57gVKkm5FAAAAMQDqigydhP7j1IGABdVrWXX/WFhABjAmNWrf -YYEecgjhjdM83QSkpwu7tYCHtZjny6kAAAAUaW1wb3J0ZWQtb3BlbnNzaC1rZXkB -AgMEBQYH ------END OPENSSH PRIVATE KEY----- -`, - }, - Host: "127.0.0.1", - Port: 6901, - Username: "registry", - Password: "fake-uuid", - }, - Mbus: "http://fake-mbus-user:fake-mbus-password@0.0.0.0:6868", + Properties: biproperty.Map{}, + Mbus: "http://fake-mbus-user:fake-mbus-password@0.0.0.0:6868", })) }) @@ -403,39 +338,6 @@ cloud_provider: fakeFs.WriteFileString("/path/to/fake-ssh-key.pem", "--- BEGIN KEY --- blah --- END KEY ---") }) - It("generates registry config and populates properties in manifest with absolute path for private_key", func() { - installationManifest, err := parser.Parse(comboManifestPath, boshtpl.StaticVariables{}, patch.Ops{}, releaseSetManifest) - Expect(err).ToNot(HaveOccurred()) - - Expect(installationManifest).To(Equal(manifest.Manifest{ - Name: "fake-deployment-name", - Template: manifest.ReleaseJobRef{ - Name: "fake-cpi-job-name", - Release: "fake-cpi-release-name", - }, - Properties: biproperty.Map{ - "registry": biproperty.Map{ - "host": "127.0.0.1", - "port": 6901, - "username": "registry", - "password": "fake-uuid", - }, - }, - Registry: manifest.Registry{ - SSHTunnel: manifest.SSHTunnel{ - Host: "54.34.56.8", - Port: 22, - User: "fake-ssh-user", - PrivateKey: "--- BEGIN KEY --- blah --- END KEY ---", - }, - Host: "127.0.0.1", - Port: 6901, - Username: "registry", - Password: "fake-uuid", - }, - Mbus: "http://fake-mbus-user:fake-mbus-password@0.0.0.0:6868", - })) - }) }) Context("with relative private_key path", func() { @@ -456,40 +358,6 @@ cloud_provider: fakeUUIDGenerator.GeneratedUUID = "fake-uuid" fakeFs.WriteFileString("/path/to/tmp/fake-ssh-key.pem", "--- BEGIN KEY --- blah --- END KEY ---") }) - - It("generates registry config and populates properties in manifest with expanded path for private_key", func() { - installationManifest, err := parser.Parse(comboManifestPath, boshtpl.StaticVariables{}, patch.Ops{}, releaseSetManifest) - Expect(err).ToNot(HaveOccurred()) - - Expect(installationManifest).To(Equal(manifest.Manifest{ - Name: "fake-deployment-name", - Template: manifest.ReleaseJobRef{ - Name: "fake-cpi-job-name", - Release: "fake-cpi-release-name", - }, - Properties: biproperty.Map{ - "registry": biproperty.Map{ - "host": "127.0.0.1", - "port": 6901, - "username": "registry", - "password": "fake-uuid", - }, - }, - Registry: manifest.Registry{ - SSHTunnel: manifest.SSHTunnel{ - Host: "54.34.56.8", - Port: 22, - User: "fake-ssh-user", - PrivateKey: "--- BEGIN KEY --- blah --- END KEY ---", - }, - Host: "127.0.0.1", - Port: 6901, - Username: "registry", - Password: "fake-uuid", - }, - Mbus: "http://fake-mbus-user:fake-mbus-password@0.0.0.0:6868", - })) - }) }) Context("with private_key path beginning with '~'", func() { @@ -512,39 +380,6 @@ cloud_provider: fakeFs.WriteFileString(fakeFs.ExpandPathExpanded, "--- BEGIN KEY --- blah --- END KEY ---") }) - It("generates registry config and populates properties in manifest with expanded path for private_key", func() { - installationManifest, err := parser.Parse(comboManifestPath, boshtpl.StaticVariables{}, patch.Ops{}, releaseSetManifest) - Expect(err).ToNot(HaveOccurred()) - - Expect(installationManifest).To(Equal(manifest.Manifest{ - Name: "fake-deployment-name", - Template: manifest.ReleaseJobRef{ - Name: "fake-cpi-job-name", - Release: "fake-cpi-release-name", - }, - Properties: biproperty.Map{ - "registry": biproperty.Map{ - "host": "127.0.0.1", - "port": 6901, - "username": "registry", - "password": "fake-uuid", - }, - }, - Registry: manifest.Registry{ - SSHTunnel: manifest.SSHTunnel{ - Host: "54.34.56.8", - Port: 22, - User: "fake-ssh-user", - PrivateKey: "--- BEGIN KEY --- blah --- END KEY ---", - }, - Host: "127.0.0.1", - Port: 6901, - Username: "registry", - Password: "fake-uuid", - }, - Mbus: "http://fake-mbus-user:fake-mbus-password@0.0.0.0:6868", - })) - }) }) Context("when expanding to the home directory fails", func() { @@ -597,18 +432,6 @@ cloud_provider: }) }) - Context("when private_key is not provided", func() { - BeforeEach(func() { - fakeFs.WriteFileString(comboManifestPath, fixtures.missingPrivateKeyManifest) - }) - - It("does not expand the path", func() { - installationManifest, err := parser.Parse(comboManifestPath, boshtpl.StaticVariables{}, patch.Ops{}, releaseSetManifest) - Expect(err).ToNot(HaveOccurred()) - - Expect(installationManifest.Registry.SSHTunnel.PrivateKey).To(Equal("")) - }) - }) }) It("handles installation manifest validation errors", func() { @@ -659,27 +482,8 @@ cloud_provider: Name: "fake-cpi-job-name", Release: "fake-cpi-release-name", }, - Properties: biproperty.Map{ - "registry": biproperty.Map{ - "host": "127.0.0.1", - "port": 6901, - "username": "registry", - "password": "fake-uuid", - }, - }, - Registry: manifest.Registry{ - SSHTunnel: manifest.SSHTunnel{ - Host: "54.34.56.8", - Port: 22, - User: "fake-ssh-user", - PrivateKey: "--- BEGIN KEY --- blah --- END KEY ---", - }, - Host: "127.0.0.1", - Port: 6901, - Username: "registry", - Password: "fake-uuid", - }, - Mbus: "http://fake-mbus-user:fake-mbus-password@0.0.0.0:6868", + Properties: biproperty.Map{}, + Mbus: "http://fake-mbus-user:fake-mbus-password@0.0.0.0:6868", })) }) diff --git a/installation/mocks/mocks.go b/installation/mocks/mocks.go index dd50f1a9f..33f228321 100644 --- a/installation/mocks/mocks.go +++ b/installation/mocks/mocks.go @@ -5,39 +5,39 @@ package mocks import ( + reflect "reflect" + installation "github.com/cloudfoundry/bosh-cli/installation" manifest "github.com/cloudfoundry/bosh-cli/installation/manifest" job "github.com/cloudfoundry/bosh-cli/release/job" ui "github.com/cloudfoundry/bosh-cli/ui" - logger "github.com/cloudfoundry/bosh-utils/logger" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockInstallation is a mock of Installation interface +// MockInstallation is a mock of Installation interface. type MockInstallation struct { ctrl *gomock.Controller recorder *MockInstallationMockRecorder } -// MockInstallationMockRecorder is the mock recorder for MockInstallation +// MockInstallationMockRecorder is the mock recorder for MockInstallation. type MockInstallationMockRecorder struct { mock *MockInstallation } -// NewMockInstallation creates a new mock instance +// NewMockInstallation creates a new mock instance. func NewMockInstallation(ctrl *gomock.Controller) *MockInstallation { mock := &MockInstallation{ctrl: ctrl} mock.recorder = &MockInstallationMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockInstallation) EXPECT() *MockInstallationMockRecorder { return m.recorder } -// Job mocks base method +// Job mocks base method. func (m *MockInstallation) Job() installation.InstalledJob { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Job") @@ -45,41 +45,13 @@ func (m *MockInstallation) Job() installation.InstalledJob { return ret0 } -// Job indicates an expected call of Job +// Job indicates an expected call of Job. func (mr *MockInstallationMockRecorder) Job() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Job", reflect.TypeOf((*MockInstallation)(nil).Job)) } -// StartRegistry mocks base method -func (m *MockInstallation) StartRegistry() error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StartRegistry") - ret0, _ := ret[0].(error) - return ret0 -} - -// StartRegistry indicates an expected call of StartRegistry -func (mr *MockInstallationMockRecorder) StartRegistry() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartRegistry", reflect.TypeOf((*MockInstallation)(nil).StartRegistry)) -} - -// StopRegistry mocks base method -func (m *MockInstallation) StopRegistry() error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StopRegistry") - ret0, _ := ret[0].(error) - return ret0 -} - -// StopRegistry indicates an expected call of StopRegistry -func (mr *MockInstallationMockRecorder) StopRegistry() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StopRegistry", reflect.TypeOf((*MockInstallation)(nil).StopRegistry)) -} - -// Target mocks base method +// Target mocks base method. func (m *MockInstallation) Target() installation.Target { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Target") @@ -87,50 +59,36 @@ func (m *MockInstallation) Target() installation.Target { return ret0 } -// Target indicates an expected call of Target +// Target indicates an expected call of Target. func (mr *MockInstallationMockRecorder) Target() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Target", reflect.TypeOf((*MockInstallation)(nil).Target)) } -// WithRunningRegistry mocks base method -func (m *MockInstallation) WithRunningRegistry(arg0 logger.Logger, arg1 ui.Stage, arg2 func() error) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WithRunningRegistry", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 -} - -// WithRunningRegistry indicates an expected call of WithRunningRegistry -func (mr *MockInstallationMockRecorder) WithRunningRegistry(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WithRunningRegistry", reflect.TypeOf((*MockInstallation)(nil).WithRunningRegistry), arg0, arg1, arg2) -} - -// MockInstaller is a mock of Installer interface +// MockInstaller is a mock of Installer interface. type MockInstaller struct { ctrl *gomock.Controller recorder *MockInstallerMockRecorder } -// MockInstallerMockRecorder is the mock recorder for MockInstaller +// MockInstallerMockRecorder is the mock recorder for MockInstaller. type MockInstallerMockRecorder struct { mock *MockInstaller } -// NewMockInstaller creates a new mock instance +// NewMockInstaller creates a new mock instance. func NewMockInstaller(ctrl *gomock.Controller) *MockInstaller { mock := &MockInstaller{ctrl: ctrl} mock.recorder = &MockInstallerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockInstaller) EXPECT() *MockInstallerMockRecorder { return m.recorder } -// Cleanup mocks base method +// Cleanup mocks base method. func (m *MockInstaller) Cleanup(arg0 installation.Installation) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Cleanup", arg0) @@ -138,13 +96,13 @@ func (m *MockInstaller) Cleanup(arg0 installation.Installation) error { return ret0 } -// Cleanup indicates an expected call of Cleanup +// Cleanup indicates an expected call of Cleanup. func (mr *MockInstallerMockRecorder) Cleanup(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Cleanup", reflect.TypeOf((*MockInstaller)(nil).Cleanup), arg0) } -// Install mocks base method +// Install mocks base method. func (m *MockInstaller) Install(arg0 manifest.Manifest, arg1 ui.Stage) (installation.Installation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Install", arg0, arg1) @@ -153,36 +111,36 @@ func (m *MockInstaller) Install(arg0 manifest.Manifest, arg1 ui.Stage) (installa return ret0, ret1 } -// Install indicates an expected call of Install +// Install indicates an expected call of Install. func (mr *MockInstallerMockRecorder) Install(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Install", reflect.TypeOf((*MockInstaller)(nil).Install), arg0, arg1) } -// MockInstallerFactory is a mock of InstallerFactory interface +// MockInstallerFactory is a mock of InstallerFactory interface. type MockInstallerFactory struct { ctrl *gomock.Controller recorder *MockInstallerFactoryMockRecorder } -// MockInstallerFactoryMockRecorder is the mock recorder for MockInstallerFactory +// MockInstallerFactoryMockRecorder is the mock recorder for MockInstallerFactory. type MockInstallerFactoryMockRecorder struct { mock *MockInstallerFactory } -// NewMockInstallerFactory creates a new mock instance +// NewMockInstallerFactory creates a new mock instance. func NewMockInstallerFactory(ctrl *gomock.Controller) *MockInstallerFactory { mock := &MockInstallerFactory{ctrl: ctrl} mock.recorder = &MockInstallerFactoryMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockInstallerFactory) EXPECT() *MockInstallerFactoryMockRecorder { return m.recorder } -// NewInstaller mocks base method +// NewInstaller mocks base method. func (m *MockInstallerFactory) NewInstaller(arg0 installation.Target) installation.Installer { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewInstaller", arg0) @@ -190,36 +148,36 @@ func (m *MockInstallerFactory) NewInstaller(arg0 installation.Target) installati return ret0 } -// NewInstaller indicates an expected call of NewInstaller +// NewInstaller indicates an expected call of NewInstaller. func (mr *MockInstallerFactoryMockRecorder) NewInstaller(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewInstaller", reflect.TypeOf((*MockInstallerFactory)(nil).NewInstaller), arg0) } -// MockUninstaller is a mock of Uninstaller interface +// MockUninstaller is a mock of Uninstaller interface. type MockUninstaller struct { ctrl *gomock.Controller recorder *MockUninstallerMockRecorder } -// MockUninstallerMockRecorder is the mock recorder for MockUninstaller +// MockUninstallerMockRecorder is the mock recorder for MockUninstaller. type MockUninstallerMockRecorder struct { mock *MockUninstaller } -// NewMockUninstaller creates a new mock instance +// NewMockUninstaller creates a new mock instance. func NewMockUninstaller(ctrl *gomock.Controller) *MockUninstaller { mock := &MockUninstaller{ctrl: ctrl} mock.recorder = &MockUninstallerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockUninstaller) EXPECT() *MockUninstallerMockRecorder { return m.recorder } -// Uninstall mocks base method +// Uninstall mocks base method. func (m *MockUninstaller) Uninstall(arg0 installation.Target) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Uninstall", arg0) @@ -227,36 +185,36 @@ func (m *MockUninstaller) Uninstall(arg0 installation.Target) error { return ret0 } -// Uninstall indicates an expected call of Uninstall +// Uninstall indicates an expected call of Uninstall. func (mr *MockUninstallerMockRecorder) Uninstall(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Uninstall", reflect.TypeOf((*MockUninstaller)(nil).Uninstall), arg0) } -// MockJobResolver is a mock of JobResolver interface +// MockJobResolver is a mock of JobResolver interface. type MockJobResolver struct { ctrl *gomock.Controller recorder *MockJobResolverMockRecorder } -// MockJobResolverMockRecorder is the mock recorder for MockJobResolver +// MockJobResolverMockRecorder is the mock recorder for MockJobResolver. type MockJobResolverMockRecorder struct { mock *MockJobResolver } -// NewMockJobResolver creates a new mock instance +// NewMockJobResolver creates a new mock instance. func NewMockJobResolver(ctrl *gomock.Controller) *MockJobResolver { mock := &MockJobResolver{ctrl: ctrl} mock.recorder = &MockJobResolverMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockJobResolver) EXPECT() *MockJobResolverMockRecorder { return m.recorder } -// From mocks base method +// From mocks base method. func (m *MockJobResolver) From(arg0 manifest.Manifest) ([]job.Job, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "From", arg0) @@ -265,36 +223,36 @@ func (m *MockJobResolver) From(arg0 manifest.Manifest) ([]job.Job, error) { return ret0, ret1 } -// From indicates an expected call of From +// From indicates an expected call of From. func (mr *MockJobResolverMockRecorder) From(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "From", reflect.TypeOf((*MockJobResolver)(nil).From), arg0) } -// MockPackageCompiler is a mock of PackageCompiler interface +// MockPackageCompiler is a mock of PackageCompiler interface. type MockPackageCompiler struct { ctrl *gomock.Controller recorder *MockPackageCompilerMockRecorder } -// MockPackageCompilerMockRecorder is the mock recorder for MockPackageCompiler +// MockPackageCompilerMockRecorder is the mock recorder for MockPackageCompiler. type MockPackageCompilerMockRecorder struct { mock *MockPackageCompiler } -// NewMockPackageCompiler creates a new mock instance +// NewMockPackageCompiler creates a new mock instance. func NewMockPackageCompiler(ctrl *gomock.Controller) *MockPackageCompiler { mock := &MockPackageCompiler{ctrl: ctrl} mock.recorder = &MockPackageCompilerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockPackageCompiler) EXPECT() *MockPackageCompilerMockRecorder { return m.recorder } -// For mocks base method +// For mocks base method. func (m *MockPackageCompiler) For(arg0 []job.Job, arg1 ui.Stage) ([]installation.CompiledPackageRef, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "For", arg0, arg1) @@ -303,36 +261,36 @@ func (m *MockPackageCompiler) For(arg0 []job.Job, arg1 ui.Stage) ([]installation return ret0, ret1 } -// For indicates an expected call of For +// For indicates an expected call of For. func (mr *MockPackageCompilerMockRecorder) For(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "For", reflect.TypeOf((*MockPackageCompiler)(nil).For), arg0, arg1) } -// MockJobRenderer is a mock of JobRenderer interface +// MockJobRenderer is a mock of JobRenderer interface. type MockJobRenderer struct { ctrl *gomock.Controller recorder *MockJobRendererMockRecorder } -// MockJobRendererMockRecorder is the mock recorder for MockJobRenderer +// MockJobRendererMockRecorder is the mock recorder for MockJobRenderer. type MockJobRendererMockRecorder struct { mock *MockJobRenderer } -// NewMockJobRenderer creates a new mock instance +// NewMockJobRenderer creates a new mock instance. func NewMockJobRenderer(ctrl *gomock.Controller) *MockJobRenderer { mock := &MockJobRenderer{ctrl: ctrl} mock.recorder = &MockJobRendererMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockJobRenderer) EXPECT() *MockJobRendererMockRecorder { return m.recorder } -// RenderAndUploadFrom mocks base method +// RenderAndUploadFrom mocks base method. func (m *MockJobRenderer) RenderAndUploadFrom(arg0 manifest.Manifest, arg1 []job.Job, arg2 ui.Stage) ([]installation.RenderedJobRef, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RenderAndUploadFrom", arg0, arg1, arg2) @@ -341,7 +299,7 @@ func (m *MockJobRenderer) RenderAndUploadFrom(arg0 manifest.Manifest, arg1 []job return ret0, ret1 } -// RenderAndUploadFrom indicates an expected call of RenderAndUploadFrom +// RenderAndUploadFrom indicates an expected call of RenderAndUploadFrom. func (mr *MockJobRendererMockRecorder) RenderAndUploadFrom(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RenderAndUploadFrom", reflect.TypeOf((*MockJobRenderer)(nil).RenderAndUploadFrom), arg0, arg1, arg2) diff --git a/installation/tarball/mocks/mocks.go b/installation/tarball/mocks/mocks.go index a64326dc2..7c3679c2b 100644 --- a/installation/tarball/mocks/mocks.go +++ b/installation/tarball/mocks/mocks.go @@ -5,36 +5,37 @@ package mocks import ( + reflect "reflect" + tarball "github.com/cloudfoundry/bosh-cli/installation/tarball" ui "github.com/cloudfoundry/bosh-cli/ui" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockProvider is a mock of Provider interface +// MockProvider is a mock of Provider interface. type MockProvider struct { ctrl *gomock.Controller recorder *MockProviderMockRecorder } -// MockProviderMockRecorder is the mock recorder for MockProvider +// MockProviderMockRecorder is the mock recorder for MockProvider. type MockProviderMockRecorder struct { mock *MockProvider } -// NewMockProvider creates a new mock instance +// NewMockProvider creates a new mock instance. func NewMockProvider(ctrl *gomock.Controller) *MockProvider { mock := &MockProvider{ctrl: ctrl} mock.recorder = &MockProviderMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockProvider) EXPECT() *MockProviderMockRecorder { return m.recorder } -// Get mocks base method +// Get mocks base method. func (m *MockProvider) Get(arg0 tarball.Source, arg1 ui.Stage) (string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Get", arg0, arg1) @@ -43,7 +44,7 @@ func (m *MockProvider) Get(arg0 tarball.Source, arg1 ui.Stage) (string, error) { return ret0, ret1 } -// Get indicates an expected call of Get +// Get indicates an expected call of Get. func (mr *MockProviderMockRecorder) Get(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockProvider)(nil).Get), arg0, arg1) diff --git a/integration/create_env_test.go b/integration/create_env_test.go index c929a8422..c1263325d 100644 --- a/integration/create_env_test.go +++ b/integration/create_env_test.go @@ -43,7 +43,6 @@ import ( biinstallmanifest "github.com/cloudfoundry/bosh-cli/installation/manifest" mock_install "github.com/cloudfoundry/bosh-cli/installation/mocks" bitarball "github.com/cloudfoundry/bosh-cli/installation/tarball" - biregistry "github.com/cloudfoundry/bosh-cli/registry" birel "github.com/cloudfoundry/bosh-cli/release" boshrel "github.com/cloudfoundry/bosh-cli/release" bireljob "github.com/cloudfoundry/bosh-cli/release/job" @@ -74,8 +73,7 @@ var _ = Describe("bosh", func() { fs *fakesys.FakeFileSystem logger boshlog.Logger - registryServerManager biregistry.ServerManager - releaseManager birel.Manager + releaseManager birel.Manager mockInstaller *mock_install.MockInstaller mockInstallerFactory *mock_install.MockInstallerFactory @@ -310,7 +308,7 @@ cloud_provider: installedJob.Name = "fake-cpi-release-job-name" installedJob.Path = filepath.Join(target.JobsPath(), "fake-cpi-release-job-name") - installation := biinstall.NewInstallation(target, installedJob, installationManifest, registryServerManager) + installation := biinstall.NewInstallation(target, installedJob, installationManifest) mockInstallerFactory.EXPECT().NewInstaller(target).Return(mockInstaller).AnyTimes() @@ -792,8 +790,6 @@ cloud_provider: mockCloud = mock_cloud.NewMockCloud(mockCtrl) - registryServerManager = biregistry.NewServerManager(logger) - releaseReader = &fakerel.FakeReader{} releaseManager = biinstall.NewReleaseManager(logger) diff --git a/registry/instance_handler.go b/registry/instance_handler.go deleted file mode 100644 index d96c6baee..000000000 --- a/registry/instance_handler.go +++ /dev/null @@ -1,178 +0,0 @@ -package registry - -import ( - "encoding/base64" - "encoding/json" - "io/ioutil" - "net/http" - "regexp" - - boshlog "github.com/cloudfoundry/bosh-utils/logger" -) - -type instanceHandler struct { - username string - password string - registry Registry - logger boshlog.Logger - logTag string -} - -func newInstanceHandler( - username string, - password string, - registry Registry, - logger boshlog.Logger, -) *instanceHandler { - return &instanceHandler{ - username: username, - password: password, - registry: registry, - logger: logger, - logTag: "registryInstanceHandler", - } -} - -type SettingsResponse struct { - Settings string `json:"settings"` - Status string `json:"status"` -} - -func (h *instanceHandler) HandleFunc(w http.ResponseWriter, req *http.Request) { - h.logger.Debug(h.logTag, "Received %s %s", req.Method, req.URL.Path) - instanceID, ok := h.getInstanceID(req) - if !ok { - h.logger.Debug(h.logTag, "Instance ID not found in request:", req.Method) - h.handleNotFound(w) - return - } - - h.logger.Debug(h.logTag, "Found instance ID in request: %s", instanceID) - - switch req.Method { - case "GET": - h.HandleGet(instanceID, w, req) - return - case "PUT": - h.HandlePut(instanceID, w, req) - return - case "DELETE": - h.HandleDelete(instanceID, w, req) - return - default: - h.handleNotFound(w) - return - } -} - -func (h *instanceHandler) HandleGet(instanceID string, w http.ResponseWriter, req *http.Request) { - settingsJSON, ok := h.registry.Get(instanceID) - if !ok { - h.logger.Debug(h.logTag, "No settings for %s found", instanceID) - h.handleNotFound(w) - return - } - - h.logger.Debug(h.logTag, "Found settings for instance %s: %s", instanceID, string(settingsJSON)) - - response := SettingsResponse{ - Settings: string(settingsJSON), - Status: "ok", - } - - responseJSON, err := json.Marshal(response) - if err != nil { - h.handleBadRequest(w) - return - } - - _, err = w.Write(responseJSON) - if err != nil { - h.logger.Warn(h.logTag, "Couldn't write response: %s", err.Error()) - } - - return -} - -func (h *instanceHandler) HandlePut(instanceID string, w http.ResponseWriter, req *http.Request) { - if !h.isAuthorized(req) { - h.handleUnauthorized(w) - return - } - - reqBody, err := ioutil.ReadAll(req.Body) - if err != nil { - h.handleBadRequest(w) - return - } - - h.logger.Debug(h.logTag, "Saving settings to registry for instance %s: %s", instanceID, string(reqBody)) - - isUpdated := h.registry.Save(instanceID, reqBody) - if isUpdated { - w.WriteHeader(http.StatusOK) - return - } - - w.WriteHeader(http.StatusCreated) -} - -func (h *instanceHandler) HandleDelete(instanceID string, w http.ResponseWriter, req *http.Request) { - if !h.isAuthorized(req) { - h.handleUnauthorized(w) - return - } - - h.logger.Debug(h.logTag, "Deleting settings for instance %s", instanceID) - h.registry.Delete(instanceID) -} - -func (h *instanceHandler) handleUnauthorized(w http.ResponseWriter) { - h.logger.Debug(h.logTag, "Received unauthorized request") - w.Header().Add("WWW-Authenticate", `Basic realm="Bosh Registry"`) - w.WriteHeader(http.StatusUnauthorized) -} - -func (h *instanceHandler) getInstanceID(req *http.Request) (string, bool) { - re := regexp.MustCompile("/instances/([^/]+)/settings") - matches := re.FindStringSubmatch(req.URL.Path) - - if len(matches) == 0 { - return "", false - } - - return matches[1], true -} - -func (h *instanceHandler) isAuthorized(req *http.Request) bool { - auth := h.username + ":" + h.password - expectedAuthorizationHeader := "Basic " + base64.StdEncoding.EncodeToString([]byte(auth)) - - return expectedAuthorizationHeader == req.Header.Get("Authorization") -} - -func (h *instanceHandler) handleNotFound(w http.ResponseWriter) { - w.WriteHeader(http.StatusNotFound) - settingsJSON, err := json.Marshal(SettingsResponse{Status: "not_found"}) - if err != nil { - h.logger.Warn(h.logTag, "Failed to marshal 'not found' settings response %s", err.Error()) - return - } - _, err = w.Write(settingsJSON) - if err != nil { - h.logger.Warn(h.logTag, "Failed to write response: %s", err.Error()) - } -} - -func (h *instanceHandler) handleBadRequest(w http.ResponseWriter) { - w.WriteHeader(http.StatusBadRequest) - settingsJSON, err := json.Marshal(SettingsResponse{Status: "error"}) - if err != nil { - h.logger.Warn(h.logTag, "Failed to marshal 'bad request' settings response %s", err.Error()) - return - } - _, err = w.Write(settingsJSON) - if err != nil { - h.logger.Warn(h.logTag, "Failed to write response: %s", err.Error()) - } -} diff --git a/registry/mocks/mocks.go b/registry/mocks/mocks.go deleted file mode 100644 index e1df233fc..000000000 --- a/registry/mocks/mocks.go +++ /dev/null @@ -1,86 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/cloudfoundry/bosh-cli/registry (interfaces: Server,ServerManager) - -// Package mocks is a generated GoMock package. -package mocks - -import ( - registry "github.com/cloudfoundry/bosh-cli/registry" - gomock "github.com/golang/mock/gomock" - reflect "reflect" -) - -// MockServer is a mock of Server interface -type MockServer struct { - ctrl *gomock.Controller - recorder *MockServerMockRecorder -} - -// MockServerMockRecorder is the mock recorder for MockServer -type MockServerMockRecorder struct { - mock *MockServer -} - -// NewMockServer creates a new mock instance -func NewMockServer(ctrl *gomock.Controller) *MockServer { - mock := &MockServer{ctrl: ctrl} - mock.recorder = &MockServerMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockServer) EXPECT() *MockServerMockRecorder { - return m.recorder -} - -// Stop mocks base method -func (m *MockServer) Stop() error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Stop") - ret0, _ := ret[0].(error) - return ret0 -} - -// Stop indicates an expected call of Stop -func (mr *MockServerMockRecorder) Stop() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockServer)(nil).Stop)) -} - -// MockServerManager is a mock of ServerManager interface -type MockServerManager struct { - ctrl *gomock.Controller - recorder *MockServerManagerMockRecorder -} - -// MockServerManagerMockRecorder is the mock recorder for MockServerManager -type MockServerManagerMockRecorder struct { - mock *MockServerManager -} - -// NewMockServerManager creates a new mock instance -func NewMockServerManager(ctrl *gomock.Controller) *MockServerManager { - mock := &MockServerManager{ctrl: ctrl} - mock.recorder = &MockServerManagerMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockServerManager) EXPECT() *MockServerManagerMockRecorder { - return m.recorder -} - -// Start mocks base method -func (m *MockServerManager) Start(arg0, arg1, arg2 string, arg3 int) (registry.Server, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Start", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(registry.Server) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Start indicates an expected call of Start -func (mr *MockServerManagerMockRecorder) Start(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockServerManager)(nil).Start), arg0, arg1, arg2, arg3) -} diff --git a/registry/registry.go b/registry/registry.go deleted file mode 100644 index 0598a38b1..000000000 --- a/registry/registry.go +++ /dev/null @@ -1,30 +0,0 @@ -package registry - -type registry map[string][]byte - -type Registry interface { - Save(string, []byte) bool - Get(string) ([]byte, bool) - Delete(string) -} - -func NewRegistry() Registry { - return make(registry) -} - -func (r registry) Save(key string, value []byte) bool { - _, exists := r[key] - r[key] = value - - return exists -} - -func (r registry) Get(key string) ([]byte, bool) { - value, exists := r[key] - - return value, exists -} - -func (r registry) Delete(key string) { - delete(r, key) -} diff --git a/registry/registry_suite_test.go b/registry/registry_suite_test.go deleted file mode 100644 index f30a1c74f..000000000 --- a/registry/registry_suite_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package registry_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "testing" -) - -func TestRegistry(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Registry Suite") -} diff --git a/registry/server.go b/registry/server.go deleted file mode 100644 index 966fb9672..000000000 --- a/registry/server.go +++ /dev/null @@ -1,104 +0,0 @@ -package registry - -import ( - "fmt" - "net" - "net/http" - - bosherr "github.com/cloudfoundry/bosh-utils/errors" - boshlog "github.com/cloudfoundry/bosh-utils/logger" -) - -type ServerManager interface { - Start(string, string, string, int) (Server, error) -} - -type serverManager struct { - logger boshlog.Logger - logTag string -} - -func NewServerManager(logger boshlog.Logger) ServerManager { - return &serverManager{ - logger: logger, - logTag: "registryServer", - } -} - -// Create starts a new server on a goroutine and returns it -// The returned error is only for starting. Error while running is logged. -func (s *serverManager) Start(username string, password string, host string, port int) (Server, error) { - startedCh := make(chan error) - server := &server{ - logger: s.logger, - logTag: "registryServer", - } - go func() { - err := server.start(username, password, host, port, startedCh) - if err != nil { - s.logger.Debug(s.logTag, "Registry error occurred: %s", err.Error()) - } - }() - - // block until started - err := <-startedCh - if err != nil { - if stopErr := server.Stop(); stopErr != nil { - s.logger.Warn(s.logTag, "Failed to stop server: %s", stopErr.Error()) - } - } - return server, err -} - -type Server interface { - Stop() error -} - -type server struct { - listener net.Listener - logger boshlog.Logger - logTag string -} - -func NewServer(logger boshlog.Logger) Server { - return &server{ - logger: logger, - logTag: "registryServer", - } -} - -func (s *server) start(username string, password string, host string, port int, readyErrCh chan error) error { - s.logger.Debug(s.logTag, "Starting registry server at %s:%d", host, port) - var err error - s.listener, err = net.Listen("tcp", fmt.Sprintf("%s:%d", host, port)) - if err != nil { - readyErrCh <- bosherr.WrapError(err, "Starting registry listener") - return nil - } - - readyErrCh <- nil - - httpServer := http.Server{} - mux := http.NewServeMux() - httpServer.Handler = mux - - registry := NewRegistry() - instanceHandler := newInstanceHandler(username, password, registry, s.logger) - mux.HandleFunc("/instances/", instanceHandler.HandleFunc) - - return httpServer.Serve(s.listener) -} - -func (s *server) Stop() error { - if s.listener == nil { - return bosherr.Error("Stopping not-started registry server") - } - - s.logger.Debug(s.logTag, "Stopping registry server") - err := s.listener.Close() - if err != nil { - return bosherr.WrapError(err, "Stopping registry server") - } - - return nil -} diff --git a/registry/server_test.go b/registry/server_test.go deleted file mode 100644 index b9621f37b..000000000 --- a/registry/server_test.go +++ /dev/null @@ -1,230 +0,0 @@ -package registry_test - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "net/http" - "strings" - "time" - - . "github.com/cloudfoundry/bosh-cli/registry" - boshlog "github.com/cloudfoundry/bosh-utils/logger" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Server", func() { - var ( - server Server - registryURL string - registryPort int - incorrectAuthRegistryURL string - client helperClient - ) - - retryStartingServer := func() (Server, error) { - var err error - var server Server - logger := boshlog.NewLogger(boshlog.LevelNone) - serverFactory := NewServerManager(logger) - - attempts := 0 - for attempts < 3 { - server, err = serverFactory.Start("fake-user", "fake-password", "localhost", registryPort) - if err == nil { - return server, nil - } - - attempts++ - time.Sleep(1 * time.Second) - } - - return nil, err - } - - BeforeEach(func() { - registryPort = 6901 + GinkgoParallelNode() - registryHost := fmt.Sprintf("localhost:%d", registryPort) - registryURL = fmt.Sprintf("http://fake-user:fake-password@%s", registryHost) - - incorrectAuthRegistryURL = fmt.Sprintf("http://incorrect-user:incorrect-password@%s", registryHost) - - var err error - server, err = retryStartingServer() // wait for previous test to close socket if still open - Expect(err).ToNot(HaveOccurred()) - - transport := &http.Transport{DisableKeepAlives: true} - httpClient := http.Client{Transport: transport} - - client = newHelperClient(httpClient) - }) - - AfterEach(func() { - server.Stop() - }) - - Describe("making a request with an unknown path", func() { - It("returns 404", func() { - _, _, statusCode := client.DoPut(registryURL+"/instances/1/something-else", "fake-agent-settings") - Expect(statusCode).To(Equal(404)) - }) - }) - - Describe("PUT instances/:instance_id/settings", func() { - Context("when username and password are incorrect", func() { - It("returns 401", func() { - _, responseHeader, statusCode := client.DoPut(incorrectAuthRegistryURL+"/instances/1/settings", "fake-agent-settings") - Expect(statusCode).To(Equal(401)) - Expect(responseHeader.Get("WWW-Authenticate")).To(Equal(`Basic realm="Bosh Registry"`)) - }) - }) - - Context("when the settings do not yet exist", func() { - It("creates the settings", func() { - _, _, statusCode := client.DoPut(registryURL+"/instances/1/settings", "fake-agent-settings") - Expect(statusCode).To(Equal(201)) - - httpBody, statusCode := client.DoGet(registryURL + "/instances/1/settings") - Expect(statusCode).To(Equal(200)) - var response SettingsResponse - err := json.Unmarshal(httpBody, &response) - Expect(err).ToNot(HaveOccurred()) - Expect(response.Settings).To(Equal("fake-agent-settings")) - Expect(response.Status).To(Equal("ok")) - }) - }) - - Context("when the settings already exist", func() { - It("updates the settings", func() { - _, _, statusCode := client.DoPut(registryURL+"/instances/1/settings", "fake-agent-settings") - Expect(statusCode).To(Equal(201)) - - _, _, statusCode = client.DoPut(registryURL+"/instances/1/settings", "fake-agent-settings-updated") - Expect(statusCode).To(Equal(200)) - - httpBody, statusCode := client.DoGet(registryURL + "/instances/1/settings") - Expect(statusCode).To(Equal(200)) - - var response SettingsResponse - err := json.Unmarshal(httpBody, &response) - Expect(err).ToNot(HaveOccurred()) - Expect(response.Settings).To(Equal("fake-agent-settings-updated")) - Expect(response.Status).To(Equal("ok")) - }) - }) - }) - - Describe("DELETE instances/:instance_id/settings", func() { - Context("when username and password are incorrect", func() { - It("returns 401", func() { - responseHeader, statusCode := client.DoDelete(incorrectAuthRegistryURL + "/instances/1/settings") - Expect(statusCode).To(Equal(401)) - Expect(responseHeader.Get("WWW-Authenticate")).To(Equal(`Basic realm="Bosh Registry"`)) - }) - }) - - Context("when the settings exist", func() { - It("deletes the settings", func() { - _, _, statusCode := client.DoPut(registryURL+"/instances/1/settings", "fake-agent-settings") - Expect(statusCode).To(Equal(201)) - - _, statusCode = client.DoDelete(registryURL + "/instances/1/settings") - Expect(statusCode).To(Equal(200)) - - responseJSON, statusCode := client.DoGet(registryURL + "/instances/1/settings") - Expect(statusCode).To(Equal(404)) - var settingsResponse SettingsResponse - err := json.Unmarshal(responseJSON, &settingsResponse) - Expect(err).ToNot(HaveOccurred()) - Expect(settingsResponse.Status).To(Equal("not_found")) - }) - }) - - Context("when the settings do not exist", func() { - It("returns 200", func() { - _, statusCode := client.DoDelete(registryURL + "/instances/1/settings") - Expect(statusCode).To(Equal(200)) - - _, statusCode = client.DoGet(registryURL + "/instances/1/settings") - Expect(statusCode).To(Equal(404)) - }) - }) - }) - - Describe("GET instances/:instance_id/settings", func() { - Context("when settings do not exist", func() { - It("returns 404", func() { - _, statusCode := client.DoGet(registryURL + "/instances/1/settings") - Expect(statusCode).To(Equal(404)) - }) - }) - - Context("when settings exist", func() { - BeforeEach(func() { - _, _, statusCode := client.DoPut(registryURL+"/instances/1/settings", "fake-agent-settings") - Expect(statusCode).To(Equal(201)) - }) - - Context("when username and password are incorrect", func() { - It("does not return 401, because GETs do not require authentication", func() { - httpBody, statusCode := client.DoGet(incorrectAuthRegistryURL + "/instances/1/settings") - Expect(statusCode).To(Equal(200)) - var response SettingsResponse - err := json.Unmarshal(httpBody, &response) - Expect(err).ToNot(HaveOccurred()) - Expect(response.Settings).To(Equal("fake-agent-settings")) - Expect(response.Status).To(Equal("ok")) - }) - }) - }) - }) -}) - -type helperClient struct { - httpClient http.Client -} - -func newHelperClient(httpClient http.Client) helperClient { - return helperClient{ - httpClient: httpClient, - } -} - -func (c helperClient) DoDelete(endpoint string) (http.Header, int) { - request, err := http.NewRequest("DELETE", endpoint, strings.NewReader("")) - Expect(err).ToNot(HaveOccurred()) - httpResponse, err := c.httpClient.Do(request) - Expect(err).ToNot(HaveOccurred()) - - return httpResponse.Header, httpResponse.StatusCode -} - -func (c helperClient) DoPut(endpoint string, body string) (string, http.Header, int) { - putPayload := strings.NewReader(body) - - request, err := http.NewRequest("PUT", endpoint, putPayload) - Expect(err).ToNot(HaveOccurred()) - - httpResponse, err := c.httpClient.Do(request) - Expect(err).ToNot(HaveOccurred()) - - defer httpResponse.Body.Close() - - httpBody, err := ioutil.ReadAll(httpResponse.Body) - Expect(err).ToNot(HaveOccurred()) - - return string(httpBody), httpResponse.Header, httpResponse.StatusCode -} - -func (c helperClient) DoGet(endpoint string) ([]byte, int) { - httpResponse, err := c.httpClient.Get(endpoint) - Expect(err).ToNot(HaveOccurred()) - - defer httpResponse.Body.Close() - - httpBody, err := ioutil.ReadAll(httpResponse.Body) - Expect(err).ToNot(HaveOccurred()) - - return httpBody, httpResponse.StatusCode -} diff --git a/release/mocks/mocks.go b/release/mocks/mocks.go index f720b5fa4..573b4eee4 100644 --- a/release/mocks/mocks.go +++ b/release/mocks/mocks.go @@ -5,47 +5,48 @@ package mocks import ( + reflect "reflect" + release "github.com/cloudfoundry/bosh-cli/release" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockManager is a mock of Manager interface +// MockManager is a mock of Manager interface. type MockManager struct { ctrl *gomock.Controller recorder *MockManagerMockRecorder } -// MockManagerMockRecorder is the mock recorder for MockManager +// MockManagerMockRecorder is the mock recorder for MockManager. type MockManagerMockRecorder struct { mock *MockManager } -// NewMockManager creates a new mock instance +// NewMockManager creates a new mock instance. func NewMockManager(ctrl *gomock.Controller) *MockManager { mock := &MockManager{ctrl: ctrl} mock.recorder = &MockManagerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockManager) EXPECT() *MockManagerMockRecorder { return m.recorder } -// Add mocks base method +// Add mocks base method. func (m *MockManager) Add(arg0 release.Release) { m.ctrl.T.Helper() m.ctrl.Call(m, "Add", arg0) } -// Add indicates an expected call of Add +// Add indicates an expected call of Add. func (mr *MockManagerMockRecorder) Add(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Add", reflect.TypeOf((*MockManager)(nil).Add), arg0) } -// DeleteAll mocks base method +// DeleteAll mocks base method. func (m *MockManager) DeleteAll() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteAll") @@ -53,13 +54,13 @@ func (m *MockManager) DeleteAll() error { return ret0 } -// DeleteAll indicates an expected call of DeleteAll +// DeleteAll indicates an expected call of DeleteAll. func (mr *MockManagerMockRecorder) DeleteAll() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAll", reflect.TypeOf((*MockManager)(nil).DeleteAll)) } -// Find mocks base method +// Find mocks base method. func (m *MockManager) Find(arg0 string) (release.Release, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Find", arg0) @@ -68,13 +69,13 @@ func (m *MockManager) Find(arg0 string) (release.Release, bool) { return ret0, ret1 } -// Find indicates an expected call of Find +// Find indicates an expected call of Find. func (mr *MockManagerMockRecorder) Find(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockManager)(nil).Find), arg0) } -// List mocks base method +// List mocks base method. func (m *MockManager) List() []release.Release { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "List") @@ -82,36 +83,36 @@ func (m *MockManager) List() []release.Release { return ret0 } -// List indicates an expected call of List +// List indicates an expected call of List. func (mr *MockManagerMockRecorder) List() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockManager)(nil).List)) } -// MockExtractor is a mock of Extractor interface +// MockExtractor is a mock of Extractor interface. type MockExtractor struct { ctrl *gomock.Controller recorder *MockExtractorMockRecorder } -// MockExtractorMockRecorder is the mock recorder for MockExtractor +// MockExtractorMockRecorder is the mock recorder for MockExtractor. type MockExtractorMockRecorder struct { mock *MockExtractor } -// NewMockExtractor creates a new mock instance +// NewMockExtractor creates a new mock instance. func NewMockExtractor(ctrl *gomock.Controller) *MockExtractor { mock := &MockExtractor{ctrl: ctrl} mock.recorder = &MockExtractorMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockExtractor) EXPECT() *MockExtractorMockRecorder { return m.recorder } -// Extract mocks base method +// Extract mocks base method. func (m *MockExtractor) Extract(arg0 string) (release.Release, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Extract", arg0) @@ -120,7 +121,7 @@ func (m *MockExtractor) Extract(arg0 string) (release.Release, error) { return ret0, ret1 } -// Extract indicates an expected call of Extract +// Extract indicates an expected call of Extract. func (mr *MockExtractorMockRecorder) Extract(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Extract", reflect.TypeOf((*MockExtractor)(nil).Extract), arg0) diff --git a/state/job/mocks/mocks.go b/state/job/mocks/mocks.go index b8f8ebb3a..5b1beec9d 100644 --- a/state/job/mocks/mocks.go +++ b/state/job/mocks/mocks.go @@ -5,37 +5,38 @@ package mocks import ( + reflect "reflect" + job "github.com/cloudfoundry/bosh-cli/release/job" job0 "github.com/cloudfoundry/bosh-cli/state/job" ui "github.com/cloudfoundry/bosh-cli/ui" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockDependencyCompiler is a mock of DependencyCompiler interface +// MockDependencyCompiler is a mock of DependencyCompiler interface. type MockDependencyCompiler struct { ctrl *gomock.Controller recorder *MockDependencyCompilerMockRecorder } -// MockDependencyCompilerMockRecorder is the mock recorder for MockDependencyCompiler +// MockDependencyCompilerMockRecorder is the mock recorder for MockDependencyCompiler. type MockDependencyCompilerMockRecorder struct { mock *MockDependencyCompiler } -// NewMockDependencyCompiler creates a new mock instance +// NewMockDependencyCompiler creates a new mock instance. func NewMockDependencyCompiler(ctrl *gomock.Controller) *MockDependencyCompiler { mock := &MockDependencyCompiler{ctrl: ctrl} mock.recorder = &MockDependencyCompilerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockDependencyCompiler) EXPECT() *MockDependencyCompilerMockRecorder { return m.recorder } -// Compile mocks base method +// Compile mocks base method. func (m *MockDependencyCompiler) Compile(arg0 []job.Job, arg1 ui.Stage) ([]job0.CompiledPackageRef, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Compile", arg0, arg1) @@ -44,7 +45,7 @@ func (m *MockDependencyCompiler) Compile(arg0 []job.Job, arg1 ui.Stage) ([]job0. return ret0, ret1 } -// Compile indicates an expected call of Compile +// Compile indicates an expected call of Compile. func (mr *MockDependencyCompilerMockRecorder) Compile(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Compile", reflect.TypeOf((*MockDependencyCompiler)(nil).Compile), arg0, arg1) diff --git a/state/pkg/mocks/mocks.go b/state/pkg/mocks/mocks.go index 214a5fbbc..7eac659a5 100644 --- a/state/pkg/mocks/mocks.go +++ b/state/pkg/mocks/mocks.go @@ -5,36 +5,37 @@ package mocks import ( + reflect "reflect" + pkg "github.com/cloudfoundry/bosh-cli/release/pkg" pkg0 "github.com/cloudfoundry/bosh-cli/state/pkg" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockCompiler is a mock of Compiler interface +// MockCompiler is a mock of Compiler interface. type MockCompiler struct { ctrl *gomock.Controller recorder *MockCompilerMockRecorder } -// MockCompilerMockRecorder is the mock recorder for MockCompiler +// MockCompilerMockRecorder is the mock recorder for MockCompiler. type MockCompilerMockRecorder struct { mock *MockCompiler } -// NewMockCompiler creates a new mock instance +// NewMockCompiler creates a new mock instance. func NewMockCompiler(ctrl *gomock.Controller) *MockCompiler { mock := &MockCompiler{ctrl: ctrl} mock.recorder = &MockCompilerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockCompiler) EXPECT() *MockCompilerMockRecorder { return m.recorder } -// Compile mocks base method +// Compile mocks base method. func (m *MockCompiler) Compile(arg0 pkg.Compilable) (pkg0.CompiledPackageRecord, bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Compile", arg0) @@ -44,36 +45,36 @@ func (m *MockCompiler) Compile(arg0 pkg.Compilable) (pkg0.CompiledPackageRecord, return ret0, ret1, ret2 } -// Compile indicates an expected call of Compile +// Compile indicates an expected call of Compile. func (mr *MockCompilerMockRecorder) Compile(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Compile", reflect.TypeOf((*MockCompiler)(nil).Compile), arg0) } -// MockCompiledPackageRepo is a mock of CompiledPackageRepo interface +// MockCompiledPackageRepo is a mock of CompiledPackageRepo interface. type MockCompiledPackageRepo struct { ctrl *gomock.Controller recorder *MockCompiledPackageRepoMockRecorder } -// MockCompiledPackageRepoMockRecorder is the mock recorder for MockCompiledPackageRepo +// MockCompiledPackageRepoMockRecorder is the mock recorder for MockCompiledPackageRepo. type MockCompiledPackageRepoMockRecorder struct { mock *MockCompiledPackageRepo } -// NewMockCompiledPackageRepo creates a new mock instance +// NewMockCompiledPackageRepo creates a new mock instance. func NewMockCompiledPackageRepo(ctrl *gomock.Controller) *MockCompiledPackageRepo { mock := &MockCompiledPackageRepo{ctrl: ctrl} mock.recorder = &MockCompiledPackageRepoMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockCompiledPackageRepo) EXPECT() *MockCompiledPackageRepoMockRecorder { return m.recorder } -// Find mocks base method +// Find mocks base method. func (m *MockCompiledPackageRepo) Find(arg0 pkg.Compilable) (pkg0.CompiledPackageRecord, bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Find", arg0) @@ -83,13 +84,13 @@ func (m *MockCompiledPackageRepo) Find(arg0 pkg.Compilable) (pkg0.CompiledPackag return ret0, ret1, ret2 } -// Find indicates an expected call of Find +// Find indicates an expected call of Find. func (mr *MockCompiledPackageRepoMockRecorder) Find(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockCompiledPackageRepo)(nil).Find), arg0) } -// Save mocks base method +// Save mocks base method. func (m *MockCompiledPackageRepo) Save(arg0 pkg.Compilable, arg1 pkg0.CompiledPackageRecord) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Save", arg0, arg1) @@ -97,7 +98,7 @@ func (m *MockCompiledPackageRepo) Save(arg0 pkg.Compilable, arg1 pkg0.CompiledPa return ret0 } -// Save indicates an expected call of Save +// Save indicates an expected call of Save. func (mr *MockCompiledPackageRepoMockRecorder) Save(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockCompiledPackageRepo)(nil).Save), arg0, arg1) diff --git a/stemcell/mocks/mocks.go b/stemcell/mocks/mocks.go index 4f06f9e05..f90876062 100644 --- a/stemcell/mocks/mocks.go +++ b/stemcell/mocks/mocks.go @@ -5,36 +5,37 @@ package mocks import ( + reflect "reflect" + stemcell "github.com/cloudfoundry/bosh-cli/stemcell" ui "github.com/cloudfoundry/bosh-cli/ui" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockCloudStemcell is a mock of CloudStemcell interface +// MockCloudStemcell is a mock of CloudStemcell interface. type MockCloudStemcell struct { ctrl *gomock.Controller recorder *MockCloudStemcellMockRecorder } -// MockCloudStemcellMockRecorder is the mock recorder for MockCloudStemcell +// MockCloudStemcellMockRecorder is the mock recorder for MockCloudStemcell. type MockCloudStemcellMockRecorder struct { mock *MockCloudStemcell } -// NewMockCloudStemcell creates a new mock instance +// NewMockCloudStemcell creates a new mock instance. func NewMockCloudStemcell(ctrl *gomock.Controller) *MockCloudStemcell { mock := &MockCloudStemcell{ctrl: ctrl} mock.recorder = &MockCloudStemcellMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockCloudStemcell) EXPECT() *MockCloudStemcellMockRecorder { return m.recorder } -// CID mocks base method +// CID mocks base method. func (m *MockCloudStemcell) CID() string { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CID") @@ -42,13 +43,13 @@ func (m *MockCloudStemcell) CID() string { return ret0 } -// CID indicates an expected call of CID +// CID indicates an expected call of CID. func (mr *MockCloudStemcellMockRecorder) CID() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CID", reflect.TypeOf((*MockCloudStemcell)(nil).CID)) } -// Delete mocks base method +// Delete mocks base method. func (m *MockCloudStemcell) Delete() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delete") @@ -56,13 +57,13 @@ func (m *MockCloudStemcell) Delete() error { return ret0 } -// Delete indicates an expected call of Delete +// Delete indicates an expected call of Delete. func (mr *MockCloudStemcellMockRecorder) Delete() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockCloudStemcell)(nil).Delete)) } -// Name mocks base method +// Name mocks base method. func (m *MockCloudStemcell) Name() string { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Name") @@ -70,13 +71,13 @@ func (m *MockCloudStemcell) Name() string { return ret0 } -// Name indicates an expected call of Name +// Name indicates an expected call of Name. func (mr *MockCloudStemcellMockRecorder) Name() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockCloudStemcell)(nil).Name)) } -// PromoteAsCurrent mocks base method +// PromoteAsCurrent mocks base method. func (m *MockCloudStemcell) PromoteAsCurrent() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PromoteAsCurrent") @@ -84,13 +85,13 @@ func (m *MockCloudStemcell) PromoteAsCurrent() error { return ret0 } -// PromoteAsCurrent indicates an expected call of PromoteAsCurrent +// PromoteAsCurrent indicates an expected call of PromoteAsCurrent. func (mr *MockCloudStemcellMockRecorder) PromoteAsCurrent() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PromoteAsCurrent", reflect.TypeOf((*MockCloudStemcell)(nil).PromoteAsCurrent)) } -// Version mocks base method +// Version mocks base method. func (m *MockCloudStemcell) Version() string { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Version") @@ -98,36 +99,36 @@ func (m *MockCloudStemcell) Version() string { return ret0 } -// Version indicates an expected call of Version +// Version indicates an expected call of Version. func (mr *MockCloudStemcellMockRecorder) Version() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Version", reflect.TypeOf((*MockCloudStemcell)(nil).Version)) } -// MockManager is a mock of Manager interface +// MockManager is a mock of Manager interface. type MockManager struct { ctrl *gomock.Controller recorder *MockManagerMockRecorder } -// MockManagerMockRecorder is the mock recorder for MockManager +// MockManagerMockRecorder is the mock recorder for MockManager. type MockManagerMockRecorder struct { mock *MockManager } -// NewMockManager creates a new mock instance +// NewMockManager creates a new mock instance. func NewMockManager(ctrl *gomock.Controller) *MockManager { mock := &MockManager{ctrl: ctrl} mock.recorder = &MockManagerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockManager) EXPECT() *MockManagerMockRecorder { return m.recorder } -// DeleteUnused mocks base method +// DeleteUnused mocks base method. func (m *MockManager) DeleteUnused(arg0 ui.Stage) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteUnused", arg0) @@ -135,13 +136,13 @@ func (m *MockManager) DeleteUnused(arg0 ui.Stage) error { return ret0 } -// DeleteUnused indicates an expected call of DeleteUnused +// DeleteUnused indicates an expected call of DeleteUnused. func (mr *MockManagerMockRecorder) DeleteUnused(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteUnused", reflect.TypeOf((*MockManager)(nil).DeleteUnused), arg0) } -// FindCurrent mocks base method +// FindCurrent mocks base method. func (m *MockManager) FindCurrent() ([]stemcell.CloudStemcell, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindCurrent") @@ -150,13 +151,13 @@ func (m *MockManager) FindCurrent() ([]stemcell.CloudStemcell, error) { return ret0, ret1 } -// FindCurrent indicates an expected call of FindCurrent +// FindCurrent indicates an expected call of FindCurrent. func (mr *MockManagerMockRecorder) FindCurrent() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindCurrent", reflect.TypeOf((*MockManager)(nil).FindCurrent)) } -// FindUnused mocks base method +// FindUnused mocks base method. func (m *MockManager) FindUnused() ([]stemcell.CloudStemcell, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindUnused") @@ -165,13 +166,13 @@ func (m *MockManager) FindUnused() ([]stemcell.CloudStemcell, error) { return ret0, ret1 } -// FindUnused indicates an expected call of FindUnused +// FindUnused indicates an expected call of FindUnused. func (mr *MockManagerMockRecorder) FindUnused() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindUnused", reflect.TypeOf((*MockManager)(nil).FindUnused)) } -// Upload mocks base method +// Upload mocks base method. func (m *MockManager) Upload(arg0 stemcell.ExtractedStemcell, arg1 ui.Stage) (stemcell.CloudStemcell, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Upload", arg0, arg1) @@ -180,7 +181,7 @@ func (m *MockManager) Upload(arg0 stemcell.ExtractedStemcell, arg1 ui.Stage) (st return ret0, ret1 } -// Upload indicates an expected call of Upload +// Upload indicates an expected call of Upload. func (mr *MockManagerMockRecorder) Upload(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Upload", reflect.TypeOf((*MockManager)(nil).Upload), arg0, arg1) diff --git a/stemcell/stemcellfakes/fake_extracted_stemcell.go b/stemcell/stemcellfakes/fake_extracted_stemcell.go index 0e0d5122a..846ce1491 100644 --- a/stemcell/stemcellfakes/fake_extracted_stemcell.go +++ b/stemcell/stemcellfakes/fake_extracted_stemcell.go @@ -5,64 +5,58 @@ import ( "sync" "github.com/cloudfoundry/bosh-cli/stemcell" - biproperty "github.com/cloudfoundry/bosh-utils/property" + "github.com/cloudfoundry/bosh-utils/property" ) type FakeExtractedStemcell struct { - ManifestStub func() stemcell.Manifest - manifestMutex sync.RWMutex - manifestArgsForCall []struct{} - manifestReturns struct { - result1 stemcell.Manifest - } - manifestReturnsOnCall map[int]struct { - result1 stemcell.Manifest - } CleanupStub func() error cleanupMutex sync.RWMutex - cleanupArgsForCall []struct{} - cleanupReturns struct { + cleanupArgsForCall []struct { + } + cleanupReturns struct { result1 error } cleanupReturnsOnCall map[int]struct { result1 error } - OsAndVersionStub func() string - osAndVersionMutex sync.RWMutex - osAndVersionArgsForCall []struct{} - osAndVersionReturns struct { + EmptyImageStub func() error + emptyImageMutex sync.RWMutex + emptyImageArgsForCall []struct { + } + emptyImageReturns struct { + result1 error + } + emptyImageReturnsOnCall map[int]struct { + result1 error + } + GetExtractedPathStub func() string + getExtractedPathMutex sync.RWMutex + getExtractedPathArgsForCall []struct { + } + getExtractedPathReturns struct { result1 string } - osAndVersionReturnsOnCall map[int]struct { + getExtractedPathReturnsOnCall map[int]struct { result1 string } - SetNameStub func(string) - setNameMutex sync.RWMutex - setNameArgsForCall []struct { - arg1 string + ManifestStub func() stemcell.Manifest + manifestMutex sync.RWMutex + manifestArgsForCall []struct { } - SetVersionStub func(string) - setVersionMutex sync.RWMutex - setVersionArgsForCall []struct { - arg1 string + manifestReturns struct { + result1 stemcell.Manifest } - SetFormatStub func([]string) - setFormatMutex sync.RWMutex - setFormatArgsForCall []struct { - arg1 []string + manifestReturnsOnCall map[int]struct { + result1 stemcell.Manifest } - SetCloudPropertiesStub func(biproperty.Map) - setCloudPropertiesMutex sync.RWMutex - setCloudPropertiesArgsForCall []struct { - arg1 biproperty.Map + OsAndVersionStub func() string + osAndVersionMutex sync.RWMutex + osAndVersionArgsForCall []struct { } - GetExtractedPathStub func() string - getExtractedPathMutex sync.RWMutex - getExtractedPathArgsForCall []struct{} - getExtractedPathReturns struct { + osAndVersionReturns struct { result1 string } - getExtractedPathReturnsOnCall map[int]struct { + osAndVersionReturnsOnCall map[int]struct { result1 string } PackStub func(string) error @@ -76,19 +70,31 @@ type FakeExtractedStemcell struct { packReturnsOnCall map[int]struct { result1 error } - EmptyImageStub func() error - emptyImageMutex sync.RWMutex - emptyImageArgsForCall []struct{} - emptyImageReturns struct { - result1 error + SetCloudPropertiesStub func(property.Map) + setCloudPropertiesMutex sync.RWMutex + setCloudPropertiesArgsForCall []struct { + arg1 property.Map } - emptyImageReturnsOnCall map[int]struct { - result1 error + SetFormatStub func([]string) + setFormatMutex sync.RWMutex + setFormatArgsForCall []struct { + arg1 []string + } + SetNameStub func(string) + setNameMutex sync.RWMutex + setNameArgsForCall []struct { + arg1 string + } + SetVersionStub func(string) + setVersionMutex sync.RWMutex + setVersionArgsForCall []struct { + arg1 string } StringStub func() string stringMutex sync.RWMutex - stringArgsForCall []struct{} - stringReturns struct { + stringArgsForCall []struct { + } + stringReturns struct { result1 string } stringReturnsOnCall map[int]struct { @@ -98,59 +104,22 @@ type FakeExtractedStemcell struct { invocationsMutex sync.RWMutex } -func (fake *FakeExtractedStemcell) Manifest() stemcell.Manifest { - fake.manifestMutex.Lock() - ret, specificReturn := fake.manifestReturnsOnCall[len(fake.manifestArgsForCall)] - fake.manifestArgsForCall = append(fake.manifestArgsForCall, struct{}{}) - fake.recordInvocation("Manifest", []interface{}{}) - fake.manifestMutex.Unlock() - if fake.ManifestStub != nil { - return fake.ManifestStub() - } - if specificReturn { - return ret.result1 - } - return fake.manifestReturns.result1 -} - -func (fake *FakeExtractedStemcell) ManifestCallCount() int { - fake.manifestMutex.RLock() - defer fake.manifestMutex.RUnlock() - return len(fake.manifestArgsForCall) -} - -func (fake *FakeExtractedStemcell) ManifestReturns(result1 stemcell.Manifest) { - fake.ManifestStub = nil - fake.manifestReturns = struct { - result1 stemcell.Manifest - }{result1} -} - -func (fake *FakeExtractedStemcell) ManifestReturnsOnCall(i int, result1 stemcell.Manifest) { - fake.ManifestStub = nil - if fake.manifestReturnsOnCall == nil { - fake.manifestReturnsOnCall = make(map[int]struct { - result1 stemcell.Manifest - }) - } - fake.manifestReturnsOnCall[i] = struct { - result1 stemcell.Manifest - }{result1} -} - func (fake *FakeExtractedStemcell) Cleanup() error { fake.cleanupMutex.Lock() ret, specificReturn := fake.cleanupReturnsOnCall[len(fake.cleanupArgsForCall)] - fake.cleanupArgsForCall = append(fake.cleanupArgsForCall, struct{}{}) + fake.cleanupArgsForCall = append(fake.cleanupArgsForCall, struct { + }{}) + stub := fake.CleanupStub + fakeReturns := fake.cleanupReturns fake.recordInvocation("Cleanup", []interface{}{}) fake.cleanupMutex.Unlock() - if fake.CleanupStub != nil { - return fake.CleanupStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - return fake.cleanupReturns.result1 + return fakeReturns.result1 } func (fake *FakeExtractedStemcell) CleanupCallCount() int { @@ -159,7 +128,15 @@ func (fake *FakeExtractedStemcell) CleanupCallCount() int { return len(fake.cleanupArgsForCall) } +func (fake *FakeExtractedStemcell) CleanupCalls(stub func() error) { + fake.cleanupMutex.Lock() + defer fake.cleanupMutex.Unlock() + fake.CleanupStub = stub +} + func (fake *FakeExtractedStemcell) CleanupReturns(result1 error) { + fake.cleanupMutex.Lock() + defer fake.cleanupMutex.Unlock() fake.CleanupStub = nil fake.cleanupReturns = struct { result1 error @@ -167,6 +144,8 @@ func (fake *FakeExtractedStemcell) CleanupReturns(result1 error) { } func (fake *FakeExtractedStemcell) CleanupReturnsOnCall(i int, result1 error) { + fake.cleanupMutex.Lock() + defer fake.cleanupMutex.Unlock() fake.CleanupStub = nil if fake.cleanupReturnsOnCall == nil { fake.cleanupReturnsOnCall = make(map[int]struct { @@ -178,183 +157,214 @@ func (fake *FakeExtractedStemcell) CleanupReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeExtractedStemcell) OsAndVersion() string { - fake.osAndVersionMutex.Lock() - ret, specificReturn := fake.osAndVersionReturnsOnCall[len(fake.osAndVersionArgsForCall)] - fake.osAndVersionArgsForCall = append(fake.osAndVersionArgsForCall, struct{}{}) - fake.recordInvocation("OsAndVersion", []interface{}{}) - fake.osAndVersionMutex.Unlock() - if fake.OsAndVersionStub != nil { - return fake.OsAndVersionStub() +func (fake *FakeExtractedStemcell) EmptyImage() error { + fake.emptyImageMutex.Lock() + ret, specificReturn := fake.emptyImageReturnsOnCall[len(fake.emptyImageArgsForCall)] + fake.emptyImageArgsForCall = append(fake.emptyImageArgsForCall, struct { + }{}) + stub := fake.EmptyImageStub + fakeReturns := fake.emptyImageReturns + fake.recordInvocation("EmptyImage", []interface{}{}) + fake.emptyImageMutex.Unlock() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - return fake.osAndVersionReturns.result1 + return fakeReturns.result1 } -func (fake *FakeExtractedStemcell) OsAndVersionCallCount() int { - fake.osAndVersionMutex.RLock() - defer fake.osAndVersionMutex.RUnlock() - return len(fake.osAndVersionArgsForCall) +func (fake *FakeExtractedStemcell) EmptyImageCallCount() int { + fake.emptyImageMutex.RLock() + defer fake.emptyImageMutex.RUnlock() + return len(fake.emptyImageArgsForCall) } -func (fake *FakeExtractedStemcell) OsAndVersionReturns(result1 string) { - fake.OsAndVersionStub = nil - fake.osAndVersionReturns = struct { - result1 string +func (fake *FakeExtractedStemcell) EmptyImageCalls(stub func() error) { + fake.emptyImageMutex.Lock() + defer fake.emptyImageMutex.Unlock() + fake.EmptyImageStub = stub +} + +func (fake *FakeExtractedStemcell) EmptyImageReturns(result1 error) { + fake.emptyImageMutex.Lock() + defer fake.emptyImageMutex.Unlock() + fake.EmptyImageStub = nil + fake.emptyImageReturns = struct { + result1 error }{result1} } -func (fake *FakeExtractedStemcell) OsAndVersionReturnsOnCall(i int, result1 string) { - fake.OsAndVersionStub = nil - if fake.osAndVersionReturnsOnCall == nil { - fake.osAndVersionReturnsOnCall = make(map[int]struct { - result1 string +func (fake *FakeExtractedStemcell) EmptyImageReturnsOnCall(i int, result1 error) { + fake.emptyImageMutex.Lock() + defer fake.emptyImageMutex.Unlock() + fake.EmptyImageStub = nil + if fake.emptyImageReturnsOnCall == nil { + fake.emptyImageReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.osAndVersionReturnsOnCall[i] = struct { - result1 string + fake.emptyImageReturnsOnCall[i] = struct { + result1 error }{result1} } -func (fake *FakeExtractedStemcell) SetName(arg1 string) { - fake.setNameMutex.Lock() - fake.setNameArgsForCall = append(fake.setNameArgsForCall, struct { - arg1 string - }{arg1}) - fake.recordInvocation("SetName", []interface{}{arg1}) - fake.setNameMutex.Unlock() - if fake.SetNameStub != nil { - fake.SetNameStub(arg1) +func (fake *FakeExtractedStemcell) GetExtractedPath() string { + fake.getExtractedPathMutex.Lock() + ret, specificReturn := fake.getExtractedPathReturnsOnCall[len(fake.getExtractedPathArgsForCall)] + fake.getExtractedPathArgsForCall = append(fake.getExtractedPathArgsForCall, struct { + }{}) + stub := fake.GetExtractedPathStub + fakeReturns := fake.getExtractedPathReturns + fake.recordInvocation("GetExtractedPath", []interface{}{}) + fake.getExtractedPathMutex.Unlock() + if stub != nil { + return stub() } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 } -func (fake *FakeExtractedStemcell) SetNameCallCount() int { - fake.setNameMutex.RLock() - defer fake.setNameMutex.RUnlock() - return len(fake.setNameArgsForCall) -} - -func (fake *FakeExtractedStemcell) SetNameArgsForCall(i int) string { - fake.setNameMutex.RLock() - defer fake.setNameMutex.RUnlock() - return fake.setNameArgsForCall[i].arg1 +func (fake *FakeExtractedStemcell) GetExtractedPathCallCount() int { + fake.getExtractedPathMutex.RLock() + defer fake.getExtractedPathMutex.RUnlock() + return len(fake.getExtractedPathArgsForCall) } -func (fake *FakeExtractedStemcell) SetVersion(arg1 string) { - fake.setVersionMutex.Lock() - fake.setVersionArgsForCall = append(fake.setVersionArgsForCall, struct { - arg1 string - }{arg1}) - fake.recordInvocation("SetVersion", []interface{}{arg1}) - fake.setVersionMutex.Unlock() - if fake.SetVersionStub != nil { - fake.SetVersionStub(arg1) - } +func (fake *FakeExtractedStemcell) GetExtractedPathCalls(stub func() string) { + fake.getExtractedPathMutex.Lock() + defer fake.getExtractedPathMutex.Unlock() + fake.GetExtractedPathStub = stub } -func (fake *FakeExtractedStemcell) SetVersionCallCount() int { - fake.setVersionMutex.RLock() - defer fake.setVersionMutex.RUnlock() - return len(fake.setVersionArgsForCall) +func (fake *FakeExtractedStemcell) GetExtractedPathReturns(result1 string) { + fake.getExtractedPathMutex.Lock() + defer fake.getExtractedPathMutex.Unlock() + fake.GetExtractedPathStub = nil + fake.getExtractedPathReturns = struct { + result1 string + }{result1} } -func (fake *FakeExtractedStemcell) SetVersionArgsForCall(i int) string { - fake.setVersionMutex.RLock() - defer fake.setVersionMutex.RUnlock() - return fake.setVersionArgsForCall[i].arg1 +func (fake *FakeExtractedStemcell) GetExtractedPathReturnsOnCall(i int, result1 string) { + fake.getExtractedPathMutex.Lock() + defer fake.getExtractedPathMutex.Unlock() + fake.GetExtractedPathStub = nil + if fake.getExtractedPathReturnsOnCall == nil { + fake.getExtractedPathReturnsOnCall = make(map[int]struct { + result1 string + }) + } + fake.getExtractedPathReturnsOnCall[i] = struct { + result1 string + }{result1} } -func (fake *FakeExtractedStemcell) SetFormat(arg1 []string) { - var arg1Copy []string - if arg1 != nil { - arg1Copy = make([]string, len(arg1)) - copy(arg1Copy, arg1) +func (fake *FakeExtractedStemcell) Manifest() stemcell.Manifest { + fake.manifestMutex.Lock() + ret, specificReturn := fake.manifestReturnsOnCall[len(fake.manifestArgsForCall)] + fake.manifestArgsForCall = append(fake.manifestArgsForCall, struct { + }{}) + stub := fake.ManifestStub + fakeReturns := fake.manifestReturns + fake.recordInvocation("Manifest", []interface{}{}) + fake.manifestMutex.Unlock() + if stub != nil { + return stub() } - fake.setFormatMutex.Lock() - fake.setFormatArgsForCall = append(fake.setFormatArgsForCall, struct { - arg1 []string - }{arg1Copy}) - fake.recordInvocation("SetFormat", []interface{}{arg1Copy}) - fake.setFormatMutex.Unlock() - if fake.SetFormatStub != nil { - fake.SetFormatStub(arg1) + if specificReturn { + return ret.result1 } + return fakeReturns.result1 } -func (fake *FakeExtractedStemcell) SetFormatCallCount() int { - fake.setFormatMutex.RLock() - defer fake.setFormatMutex.RUnlock() - return len(fake.setFormatArgsForCall) -} - -func (fake *FakeExtractedStemcell) SetFormatArgsForCall(i int) []string { - fake.setFormatMutex.RLock() - defer fake.setFormatMutex.RUnlock() - return fake.setFormatArgsForCall[i].arg1 +func (fake *FakeExtractedStemcell) ManifestCallCount() int { + fake.manifestMutex.RLock() + defer fake.manifestMutex.RUnlock() + return len(fake.manifestArgsForCall) } -func (fake *FakeExtractedStemcell) SetCloudProperties(arg1 biproperty.Map) { - fake.setCloudPropertiesMutex.Lock() - fake.setCloudPropertiesArgsForCall = append(fake.setCloudPropertiesArgsForCall, struct { - arg1 biproperty.Map - }{arg1}) - fake.recordInvocation("SetCloudProperties", []interface{}{arg1}) - fake.setCloudPropertiesMutex.Unlock() - if fake.SetCloudPropertiesStub != nil { - fake.SetCloudPropertiesStub(arg1) - } +func (fake *FakeExtractedStemcell) ManifestCalls(stub func() stemcell.Manifest) { + fake.manifestMutex.Lock() + defer fake.manifestMutex.Unlock() + fake.ManifestStub = stub } -func (fake *FakeExtractedStemcell) SetCloudPropertiesCallCount() int { - fake.setCloudPropertiesMutex.RLock() - defer fake.setCloudPropertiesMutex.RUnlock() - return len(fake.setCloudPropertiesArgsForCall) +func (fake *FakeExtractedStemcell) ManifestReturns(result1 stemcell.Manifest) { + fake.manifestMutex.Lock() + defer fake.manifestMutex.Unlock() + fake.ManifestStub = nil + fake.manifestReturns = struct { + result1 stemcell.Manifest + }{result1} } -func (fake *FakeExtractedStemcell) SetCloudPropertiesArgsForCall(i int) biproperty.Map { - fake.setCloudPropertiesMutex.RLock() - defer fake.setCloudPropertiesMutex.RUnlock() - return fake.setCloudPropertiesArgsForCall[i].arg1 +func (fake *FakeExtractedStemcell) ManifestReturnsOnCall(i int, result1 stemcell.Manifest) { + fake.manifestMutex.Lock() + defer fake.manifestMutex.Unlock() + fake.ManifestStub = nil + if fake.manifestReturnsOnCall == nil { + fake.manifestReturnsOnCall = make(map[int]struct { + result1 stemcell.Manifest + }) + } + fake.manifestReturnsOnCall[i] = struct { + result1 stemcell.Manifest + }{result1} } -func (fake *FakeExtractedStemcell) GetExtractedPath() string { - fake.getExtractedPathMutex.Lock() - ret, specificReturn := fake.getExtractedPathReturnsOnCall[len(fake.getExtractedPathArgsForCall)] - fake.getExtractedPathArgsForCall = append(fake.getExtractedPathArgsForCall, struct{}{}) - fake.recordInvocation("GetExtractedPath", []interface{}{}) - fake.getExtractedPathMutex.Unlock() - if fake.GetExtractedPathStub != nil { - return fake.GetExtractedPathStub() +func (fake *FakeExtractedStemcell) OsAndVersion() string { + fake.osAndVersionMutex.Lock() + ret, specificReturn := fake.osAndVersionReturnsOnCall[len(fake.osAndVersionArgsForCall)] + fake.osAndVersionArgsForCall = append(fake.osAndVersionArgsForCall, struct { + }{}) + stub := fake.OsAndVersionStub + fakeReturns := fake.osAndVersionReturns + fake.recordInvocation("OsAndVersion", []interface{}{}) + fake.osAndVersionMutex.Unlock() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - return fake.getExtractedPathReturns.result1 + return fakeReturns.result1 } -func (fake *FakeExtractedStemcell) GetExtractedPathCallCount() int { - fake.getExtractedPathMutex.RLock() - defer fake.getExtractedPathMutex.RUnlock() - return len(fake.getExtractedPathArgsForCall) +func (fake *FakeExtractedStemcell) OsAndVersionCallCount() int { + fake.osAndVersionMutex.RLock() + defer fake.osAndVersionMutex.RUnlock() + return len(fake.osAndVersionArgsForCall) } -func (fake *FakeExtractedStemcell) GetExtractedPathReturns(result1 string) { - fake.GetExtractedPathStub = nil - fake.getExtractedPathReturns = struct { +func (fake *FakeExtractedStemcell) OsAndVersionCalls(stub func() string) { + fake.osAndVersionMutex.Lock() + defer fake.osAndVersionMutex.Unlock() + fake.OsAndVersionStub = stub +} + +func (fake *FakeExtractedStemcell) OsAndVersionReturns(result1 string) { + fake.osAndVersionMutex.Lock() + defer fake.osAndVersionMutex.Unlock() + fake.OsAndVersionStub = nil + fake.osAndVersionReturns = struct { result1 string }{result1} } -func (fake *FakeExtractedStemcell) GetExtractedPathReturnsOnCall(i int, result1 string) { - fake.GetExtractedPathStub = nil - if fake.getExtractedPathReturnsOnCall == nil { - fake.getExtractedPathReturnsOnCall = make(map[int]struct { +func (fake *FakeExtractedStemcell) OsAndVersionReturnsOnCall(i int, result1 string) { + fake.osAndVersionMutex.Lock() + defer fake.osAndVersionMutex.Unlock() + fake.OsAndVersionStub = nil + if fake.osAndVersionReturnsOnCall == nil { + fake.osAndVersionReturnsOnCall = make(map[int]struct { result1 string }) } - fake.getExtractedPathReturnsOnCall[i] = struct { + fake.osAndVersionReturnsOnCall[i] = struct { result1 string }{result1} } @@ -365,15 +375,17 @@ func (fake *FakeExtractedStemcell) Pack(arg1 string) error { fake.packArgsForCall = append(fake.packArgsForCall, struct { arg1 string }{arg1}) + stub := fake.PackStub + fakeReturns := fake.packReturns fake.recordInvocation("Pack", []interface{}{arg1}) fake.packMutex.Unlock() - if fake.PackStub != nil { - return fake.PackStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - return fake.packReturns.result1 + return fakeReturns.result1 } func (fake *FakeExtractedStemcell) PackCallCount() int { @@ -382,13 +394,22 @@ func (fake *FakeExtractedStemcell) PackCallCount() int { return len(fake.packArgsForCall) } +func (fake *FakeExtractedStemcell) PackCalls(stub func(string) error) { + fake.packMutex.Lock() + defer fake.packMutex.Unlock() + fake.PackStub = stub +} + func (fake *FakeExtractedStemcell) PackArgsForCall(i int) string { fake.packMutex.RLock() defer fake.packMutex.RUnlock() - return fake.packArgsForCall[i].arg1 + argsForCall := fake.packArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeExtractedStemcell) PackReturns(result1 error) { + fake.packMutex.Lock() + defer fake.packMutex.Unlock() fake.PackStub = nil fake.packReturns = struct { result1 error @@ -396,6 +417,8 @@ func (fake *FakeExtractedStemcell) PackReturns(result1 error) { } func (fake *FakeExtractedStemcell) PackReturnsOnCall(i int, result1 error) { + fake.packMutex.Lock() + defer fake.packMutex.Unlock() fake.PackStub = nil if fake.packReturnsOnCall == nil { fake.packReturnsOnCall = make(map[int]struct { @@ -407,59 +430,155 @@ func (fake *FakeExtractedStemcell) PackReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeExtractedStemcell) EmptyImage() error { - fake.emptyImageMutex.Lock() - ret, specificReturn := fake.emptyImageReturnsOnCall[len(fake.emptyImageArgsForCall)] - fake.emptyImageArgsForCall = append(fake.emptyImageArgsForCall, struct{}{}) - fake.recordInvocation("EmptyImage", []interface{}{}) - fake.emptyImageMutex.Unlock() - if fake.EmptyImageStub != nil { - return fake.EmptyImageStub() +func (fake *FakeExtractedStemcell) SetCloudProperties(arg1 property.Map) { + fake.setCloudPropertiesMutex.Lock() + fake.setCloudPropertiesArgsForCall = append(fake.setCloudPropertiesArgsForCall, struct { + arg1 property.Map + }{arg1}) + stub := fake.SetCloudPropertiesStub + fake.recordInvocation("SetCloudProperties", []interface{}{arg1}) + fake.setCloudPropertiesMutex.Unlock() + if stub != nil { + fake.SetCloudPropertiesStub(arg1) } - if specificReturn { - return ret.result1 +} + +func (fake *FakeExtractedStemcell) SetCloudPropertiesCallCount() int { + fake.setCloudPropertiesMutex.RLock() + defer fake.setCloudPropertiesMutex.RUnlock() + return len(fake.setCloudPropertiesArgsForCall) +} + +func (fake *FakeExtractedStemcell) SetCloudPropertiesCalls(stub func(property.Map)) { + fake.setCloudPropertiesMutex.Lock() + defer fake.setCloudPropertiesMutex.Unlock() + fake.SetCloudPropertiesStub = stub +} + +func (fake *FakeExtractedStemcell) SetCloudPropertiesArgsForCall(i int) property.Map { + fake.setCloudPropertiesMutex.RLock() + defer fake.setCloudPropertiesMutex.RUnlock() + argsForCall := fake.setCloudPropertiesArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExtractedStemcell) SetFormat(arg1 []string) { + var arg1Copy []string + if arg1 != nil { + arg1Copy = make([]string, len(arg1)) + copy(arg1Copy, arg1) + } + fake.setFormatMutex.Lock() + fake.setFormatArgsForCall = append(fake.setFormatArgsForCall, struct { + arg1 []string + }{arg1Copy}) + stub := fake.SetFormatStub + fake.recordInvocation("SetFormat", []interface{}{arg1Copy}) + fake.setFormatMutex.Unlock() + if stub != nil { + fake.SetFormatStub(arg1) } - return fake.emptyImageReturns.result1 } -func (fake *FakeExtractedStemcell) EmptyImageCallCount() int { - fake.emptyImageMutex.RLock() - defer fake.emptyImageMutex.RUnlock() - return len(fake.emptyImageArgsForCall) +func (fake *FakeExtractedStemcell) SetFormatCallCount() int { + fake.setFormatMutex.RLock() + defer fake.setFormatMutex.RUnlock() + return len(fake.setFormatArgsForCall) } -func (fake *FakeExtractedStemcell) EmptyImageReturns(result1 error) { - fake.EmptyImageStub = nil - fake.emptyImageReturns = struct { - result1 error - }{result1} +func (fake *FakeExtractedStemcell) SetFormatCalls(stub func([]string)) { + fake.setFormatMutex.Lock() + defer fake.setFormatMutex.Unlock() + fake.SetFormatStub = stub } -func (fake *FakeExtractedStemcell) EmptyImageReturnsOnCall(i int, result1 error) { - fake.EmptyImageStub = nil - if fake.emptyImageReturnsOnCall == nil { - fake.emptyImageReturnsOnCall = make(map[int]struct { - result1 error - }) +func (fake *FakeExtractedStemcell) SetFormatArgsForCall(i int) []string { + fake.setFormatMutex.RLock() + defer fake.setFormatMutex.RUnlock() + argsForCall := fake.setFormatArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExtractedStemcell) SetName(arg1 string) { + fake.setNameMutex.Lock() + fake.setNameArgsForCall = append(fake.setNameArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.SetNameStub + fake.recordInvocation("SetName", []interface{}{arg1}) + fake.setNameMutex.Unlock() + if stub != nil { + fake.SetNameStub(arg1) + } +} + +func (fake *FakeExtractedStemcell) SetNameCallCount() int { + fake.setNameMutex.RLock() + defer fake.setNameMutex.RUnlock() + return len(fake.setNameArgsForCall) +} + +func (fake *FakeExtractedStemcell) SetNameCalls(stub func(string)) { + fake.setNameMutex.Lock() + defer fake.setNameMutex.Unlock() + fake.SetNameStub = stub +} + +func (fake *FakeExtractedStemcell) SetNameArgsForCall(i int) string { + fake.setNameMutex.RLock() + defer fake.setNameMutex.RUnlock() + argsForCall := fake.setNameArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExtractedStemcell) SetVersion(arg1 string) { + fake.setVersionMutex.Lock() + fake.setVersionArgsForCall = append(fake.setVersionArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.SetVersionStub + fake.recordInvocation("SetVersion", []interface{}{arg1}) + fake.setVersionMutex.Unlock() + if stub != nil { + fake.SetVersionStub(arg1) } - fake.emptyImageReturnsOnCall[i] = struct { - result1 error - }{result1} +} + +func (fake *FakeExtractedStemcell) SetVersionCallCount() int { + fake.setVersionMutex.RLock() + defer fake.setVersionMutex.RUnlock() + return len(fake.setVersionArgsForCall) +} + +func (fake *FakeExtractedStemcell) SetVersionCalls(stub func(string)) { + fake.setVersionMutex.Lock() + defer fake.setVersionMutex.Unlock() + fake.SetVersionStub = stub +} + +func (fake *FakeExtractedStemcell) SetVersionArgsForCall(i int) string { + fake.setVersionMutex.RLock() + defer fake.setVersionMutex.RUnlock() + argsForCall := fake.setVersionArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeExtractedStemcell) String() string { fake.stringMutex.Lock() ret, specificReturn := fake.stringReturnsOnCall[len(fake.stringArgsForCall)] - fake.stringArgsForCall = append(fake.stringArgsForCall, struct{}{}) + fake.stringArgsForCall = append(fake.stringArgsForCall, struct { + }{}) + stub := fake.StringStub + fakeReturns := fake.stringReturns fake.recordInvocation("String", []interface{}{}) fake.stringMutex.Unlock() - if fake.StringStub != nil { - return fake.StringStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - return fake.stringReturns.result1 + return fakeReturns.result1 } func (fake *FakeExtractedStemcell) StringCallCount() int { @@ -468,7 +587,15 @@ func (fake *FakeExtractedStemcell) StringCallCount() int { return len(fake.stringArgsForCall) } +func (fake *FakeExtractedStemcell) StringCalls(stub func() string) { + fake.stringMutex.Lock() + defer fake.stringMutex.Unlock() + fake.StringStub = stub +} + func (fake *FakeExtractedStemcell) StringReturns(result1 string) { + fake.stringMutex.Lock() + defer fake.stringMutex.Unlock() fake.StringStub = nil fake.stringReturns = struct { result1 string @@ -476,6 +603,8 @@ func (fake *FakeExtractedStemcell) StringReturns(result1 string) { } func (fake *FakeExtractedStemcell) StringReturnsOnCall(i int, result1 string) { + fake.stringMutex.Lock() + defer fake.stringMutex.Unlock() fake.StringStub = nil if fake.stringReturnsOnCall == nil { fake.stringReturnsOnCall = make(map[int]struct { @@ -490,29 +619,33 @@ func (fake *FakeExtractedStemcell) StringReturnsOnCall(i int, result1 string) { func (fake *FakeExtractedStemcell) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.manifestMutex.RLock() - defer fake.manifestMutex.RUnlock() fake.cleanupMutex.RLock() defer fake.cleanupMutex.RUnlock() + fake.emptyImageMutex.RLock() + defer fake.emptyImageMutex.RUnlock() + fake.getExtractedPathMutex.RLock() + defer fake.getExtractedPathMutex.RUnlock() + fake.manifestMutex.RLock() + defer fake.manifestMutex.RUnlock() fake.osAndVersionMutex.RLock() defer fake.osAndVersionMutex.RUnlock() + fake.packMutex.RLock() + defer fake.packMutex.RUnlock() + fake.setCloudPropertiesMutex.RLock() + defer fake.setCloudPropertiesMutex.RUnlock() + fake.setFormatMutex.RLock() + defer fake.setFormatMutex.RUnlock() fake.setNameMutex.RLock() defer fake.setNameMutex.RUnlock() fake.setVersionMutex.RLock() defer fake.setVersionMutex.RUnlock() - fake.setFormatMutex.RLock() - defer fake.setFormatMutex.RUnlock() - fake.setCloudPropertiesMutex.RLock() - defer fake.setCloudPropertiesMutex.RUnlock() - fake.getExtractedPathMutex.RLock() - defer fake.getExtractedPathMutex.RUnlock() - fake.packMutex.RLock() - defer fake.packMutex.RUnlock() - fake.emptyImageMutex.RLock() - defer fake.emptyImageMutex.RUnlock() fake.stringMutex.RLock() defer fake.stringMutex.RUnlock() - return fake.invocations + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeExtractedStemcell) recordInvocation(key string, args []interface{}) { diff --git a/templatescompiler/mocks/mocks.go b/templatescompiler/mocks/mocks.go index b77a441b8..4d3f1156b 100644 --- a/templatescompiler/mocks/mocks.go +++ b/templatescompiler/mocks/mocks.go @@ -5,37 +5,38 @@ package mocks import ( + reflect "reflect" + job "github.com/cloudfoundry/bosh-cli/release/job" templatescompiler "github.com/cloudfoundry/bosh-cli/templatescompiler" property "github.com/cloudfoundry/bosh-utils/property" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockJobRenderer is a mock of JobRenderer interface +// MockJobRenderer is a mock of JobRenderer interface. type MockJobRenderer struct { ctrl *gomock.Controller recorder *MockJobRendererMockRecorder } -// MockJobRendererMockRecorder is the mock recorder for MockJobRenderer +// MockJobRendererMockRecorder is the mock recorder for MockJobRenderer. type MockJobRendererMockRecorder struct { mock *MockJobRenderer } -// NewMockJobRenderer creates a new mock instance +// NewMockJobRenderer creates a new mock instance. func NewMockJobRenderer(ctrl *gomock.Controller) *MockJobRenderer { mock := &MockJobRenderer{ctrl: ctrl} mock.recorder = &MockJobRendererMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockJobRenderer) EXPECT() *MockJobRendererMockRecorder { return m.recorder } -// Render mocks base method +// Render mocks base method. func (m *MockJobRenderer) Render(arg0 job.Job, arg1 *property.Map, arg2, arg3 property.Map, arg4, arg5 string) (templatescompiler.RenderedJob, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Render", arg0, arg1, arg2, arg3, arg4, arg5) @@ -44,36 +45,36 @@ func (m *MockJobRenderer) Render(arg0 job.Job, arg1 *property.Map, arg2, arg3 pr return ret0, ret1 } -// Render indicates an expected call of Render +// Render indicates an expected call of Render. func (mr *MockJobRendererMockRecorder) Render(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Render", reflect.TypeOf((*MockJobRenderer)(nil).Render), arg0, arg1, arg2, arg3, arg4, arg5) } -// MockJobListRenderer is a mock of JobListRenderer interface +// MockJobListRenderer is a mock of JobListRenderer interface. type MockJobListRenderer struct { ctrl *gomock.Controller recorder *MockJobListRendererMockRecorder } -// MockJobListRendererMockRecorder is the mock recorder for MockJobListRenderer +// MockJobListRendererMockRecorder is the mock recorder for MockJobListRenderer. type MockJobListRendererMockRecorder struct { mock *MockJobListRenderer } -// NewMockJobListRenderer creates a new mock instance +// NewMockJobListRenderer creates a new mock instance. func NewMockJobListRenderer(ctrl *gomock.Controller) *MockJobListRenderer { mock := &MockJobListRenderer{ctrl: ctrl} mock.recorder = &MockJobListRendererMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockJobListRenderer) EXPECT() *MockJobListRendererMockRecorder { return m.recorder } -// Render mocks base method +// Render mocks base method. func (m *MockJobListRenderer) Render(arg0 []job.Job, arg1 map[string]*property.Map, arg2, arg3 property.Map, arg4, arg5 string) (templatescompiler.RenderedJobList, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Render", arg0, arg1, arg2, arg3, arg4, arg5) @@ -82,36 +83,36 @@ func (m *MockJobListRenderer) Render(arg0 []job.Job, arg1 map[string]*property.M return ret0, ret1 } -// Render indicates an expected call of Render +// Render indicates an expected call of Render. func (mr *MockJobListRendererMockRecorder) Render(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Render", reflect.TypeOf((*MockJobListRenderer)(nil).Render), arg0, arg1, arg2, arg3, arg4, arg5) } -// MockRenderedJob is a mock of RenderedJob interface +// MockRenderedJob is a mock of RenderedJob interface. type MockRenderedJob struct { ctrl *gomock.Controller recorder *MockRenderedJobMockRecorder } -// MockRenderedJobMockRecorder is the mock recorder for MockRenderedJob +// MockRenderedJobMockRecorder is the mock recorder for MockRenderedJob. type MockRenderedJobMockRecorder struct { mock *MockRenderedJob } -// NewMockRenderedJob creates a new mock instance +// NewMockRenderedJob creates a new mock instance. func NewMockRenderedJob(ctrl *gomock.Controller) *MockRenderedJob { mock := &MockRenderedJob{ctrl: ctrl} mock.recorder = &MockRenderedJobMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockRenderedJob) EXPECT() *MockRenderedJobMockRecorder { return m.recorder } -// Delete mocks base method +// Delete mocks base method. func (m *MockRenderedJob) Delete() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delete") @@ -119,25 +120,25 @@ func (m *MockRenderedJob) Delete() error { return ret0 } -// Delete indicates an expected call of Delete +// Delete indicates an expected call of Delete. func (mr *MockRenderedJobMockRecorder) Delete() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRenderedJob)(nil).Delete)) } -// DeleteSilently mocks base method +// DeleteSilently mocks base method. func (m *MockRenderedJob) DeleteSilently() { m.ctrl.T.Helper() m.ctrl.Call(m, "DeleteSilently") } -// DeleteSilently indicates an expected call of DeleteSilently +// DeleteSilently indicates an expected call of DeleteSilently. func (mr *MockRenderedJobMockRecorder) DeleteSilently() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSilently", reflect.TypeOf((*MockRenderedJob)(nil).DeleteSilently)) } -// Job mocks base method +// Job mocks base method. func (m *MockRenderedJob) Job() job.Job { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Job") @@ -145,13 +146,13 @@ func (m *MockRenderedJob) Job() job.Job { return ret0 } -// Job indicates an expected call of Job +// Job indicates an expected call of Job. func (mr *MockRenderedJobMockRecorder) Job() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Job", reflect.TypeOf((*MockRenderedJob)(nil).Job)) } -// Path mocks base method +// Path mocks base method. func (m *MockRenderedJob) Path() string { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Path") @@ -159,48 +160,48 @@ func (m *MockRenderedJob) Path() string { return ret0 } -// Path indicates an expected call of Path +// Path indicates an expected call of Path. func (mr *MockRenderedJobMockRecorder) Path() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Path", reflect.TypeOf((*MockRenderedJob)(nil).Path)) } -// MockRenderedJobList is a mock of RenderedJobList interface +// MockRenderedJobList is a mock of RenderedJobList interface. type MockRenderedJobList struct { ctrl *gomock.Controller recorder *MockRenderedJobListMockRecorder } -// MockRenderedJobListMockRecorder is the mock recorder for MockRenderedJobList +// MockRenderedJobListMockRecorder is the mock recorder for MockRenderedJobList. type MockRenderedJobListMockRecorder struct { mock *MockRenderedJobList } -// NewMockRenderedJobList creates a new mock instance +// NewMockRenderedJobList creates a new mock instance. func NewMockRenderedJobList(ctrl *gomock.Controller) *MockRenderedJobList { mock := &MockRenderedJobList{ctrl: ctrl} mock.recorder = &MockRenderedJobListMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockRenderedJobList) EXPECT() *MockRenderedJobListMockRecorder { return m.recorder } -// Add mocks base method +// Add mocks base method. func (m *MockRenderedJobList) Add(arg0 templatescompiler.RenderedJob) { m.ctrl.T.Helper() m.ctrl.Call(m, "Add", arg0) } -// Add indicates an expected call of Add +// Add indicates an expected call of Add. func (mr *MockRenderedJobListMockRecorder) Add(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Add", reflect.TypeOf((*MockRenderedJobList)(nil).Add), arg0) } -// All mocks base method +// All mocks base method. func (m *MockRenderedJobList) All() []templatescompiler.RenderedJob { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "All") @@ -208,13 +209,13 @@ func (m *MockRenderedJobList) All() []templatescompiler.RenderedJob { return ret0 } -// All indicates an expected call of All +// All indicates an expected call of All. func (mr *MockRenderedJobListMockRecorder) All() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "All", reflect.TypeOf((*MockRenderedJobList)(nil).All)) } -// Delete mocks base method +// Delete mocks base method. func (m *MockRenderedJobList) Delete() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delete") @@ -222,48 +223,48 @@ func (m *MockRenderedJobList) Delete() error { return ret0 } -// Delete indicates an expected call of Delete +// Delete indicates an expected call of Delete. func (mr *MockRenderedJobListMockRecorder) Delete() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRenderedJobList)(nil).Delete)) } -// DeleteSilently mocks base method +// DeleteSilently mocks base method. func (m *MockRenderedJobList) DeleteSilently() { m.ctrl.T.Helper() m.ctrl.Call(m, "DeleteSilently") } -// DeleteSilently indicates an expected call of DeleteSilently +// DeleteSilently indicates an expected call of DeleteSilently. func (mr *MockRenderedJobListMockRecorder) DeleteSilently() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSilently", reflect.TypeOf((*MockRenderedJobList)(nil).DeleteSilently)) } -// MockRenderedJobListArchive is a mock of RenderedJobListArchive interface +// MockRenderedJobListArchive is a mock of RenderedJobListArchive interface. type MockRenderedJobListArchive struct { ctrl *gomock.Controller recorder *MockRenderedJobListArchiveMockRecorder } -// MockRenderedJobListArchiveMockRecorder is the mock recorder for MockRenderedJobListArchive +// MockRenderedJobListArchiveMockRecorder is the mock recorder for MockRenderedJobListArchive. type MockRenderedJobListArchiveMockRecorder struct { mock *MockRenderedJobListArchive } -// NewMockRenderedJobListArchive creates a new mock instance +// NewMockRenderedJobListArchive creates a new mock instance. func NewMockRenderedJobListArchive(ctrl *gomock.Controller) *MockRenderedJobListArchive { mock := &MockRenderedJobListArchive{ctrl: ctrl} mock.recorder = &MockRenderedJobListArchiveMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockRenderedJobListArchive) EXPECT() *MockRenderedJobListArchiveMockRecorder { return m.recorder } -// Delete mocks base method +// Delete mocks base method. func (m *MockRenderedJobListArchive) Delete() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delete") @@ -271,25 +272,25 @@ func (m *MockRenderedJobListArchive) Delete() error { return ret0 } -// Delete indicates an expected call of Delete +// Delete indicates an expected call of Delete. func (mr *MockRenderedJobListArchiveMockRecorder) Delete() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRenderedJobListArchive)(nil).Delete)) } -// DeleteSilently mocks base method +// DeleteSilently mocks base method. func (m *MockRenderedJobListArchive) DeleteSilently() { m.ctrl.T.Helper() m.ctrl.Call(m, "DeleteSilently") } -// DeleteSilently indicates an expected call of DeleteSilently +// DeleteSilently indicates an expected call of DeleteSilently. func (mr *MockRenderedJobListArchiveMockRecorder) DeleteSilently() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSilently", reflect.TypeOf((*MockRenderedJobListArchive)(nil).DeleteSilently)) } -// List mocks base method +// List mocks base method. func (m *MockRenderedJobListArchive) List() templatescompiler.RenderedJobList { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "List") @@ -297,13 +298,13 @@ func (m *MockRenderedJobListArchive) List() templatescompiler.RenderedJobList { return ret0 } -// List indicates an expected call of List +// List indicates an expected call of List. func (mr *MockRenderedJobListArchiveMockRecorder) List() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockRenderedJobListArchive)(nil).List)) } -// Path mocks base method +// Path mocks base method. func (m *MockRenderedJobListArchive) Path() string { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Path") @@ -311,13 +312,13 @@ func (m *MockRenderedJobListArchive) Path() string { return ret0 } -// Path indicates an expected call of Path +// Path indicates an expected call of Path. func (mr *MockRenderedJobListArchiveMockRecorder) Path() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Path", reflect.TypeOf((*MockRenderedJobListArchive)(nil).Path)) } -// SHA1 mocks base method +// SHA1 mocks base method. func (m *MockRenderedJobListArchive) SHA1() string { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SHA1") @@ -325,36 +326,36 @@ func (m *MockRenderedJobListArchive) SHA1() string { return ret0 } -// SHA1 indicates an expected call of SHA1 +// SHA1 indicates an expected call of SHA1. func (mr *MockRenderedJobListArchiveMockRecorder) SHA1() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SHA1", reflect.TypeOf((*MockRenderedJobListArchive)(nil).SHA1)) } -// MockRenderedJobListCompressor is a mock of RenderedJobListCompressor interface +// MockRenderedJobListCompressor is a mock of RenderedJobListCompressor interface. type MockRenderedJobListCompressor struct { ctrl *gomock.Controller recorder *MockRenderedJobListCompressorMockRecorder } -// MockRenderedJobListCompressorMockRecorder is the mock recorder for MockRenderedJobListCompressor +// MockRenderedJobListCompressorMockRecorder is the mock recorder for MockRenderedJobListCompressor. type MockRenderedJobListCompressorMockRecorder struct { mock *MockRenderedJobListCompressor } -// NewMockRenderedJobListCompressor creates a new mock instance +// NewMockRenderedJobListCompressor creates a new mock instance. func NewMockRenderedJobListCompressor(ctrl *gomock.Controller) *MockRenderedJobListCompressor { mock := &MockRenderedJobListCompressor{ctrl: ctrl} mock.recorder = &MockRenderedJobListCompressorMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockRenderedJobListCompressor) EXPECT() *MockRenderedJobListCompressorMockRecorder { return m.recorder } -// Compress mocks base method +// Compress mocks base method. func (m *MockRenderedJobListCompressor) Compress(arg0 templatescompiler.RenderedJobList) (templatescompiler.RenderedJobListArchive, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Compress", arg0) @@ -363,7 +364,7 @@ func (m *MockRenderedJobListCompressor) Compress(arg0 templatescompiler.Rendered return ret0, ret1 } -// Compress indicates an expected call of Compress +// Compress indicates an expected call of Compress. func (mr *MockRenderedJobListCompressorMockRecorder) Compress(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Compress", reflect.TypeOf((*MockRenderedJobListCompressor)(nil).Compress), arg0) diff --git a/test_support/mocks/mocks.go b/test_support/mocks/mocks.go index aaa5a0fb4..41d07fa77 100644 --- a/test_support/mocks/mocks.go +++ b/test_support/mocks/mocks.go @@ -5,40 +5,41 @@ package mocks import ( - gomock "github.com/golang/mock/gomock" reflect "reflect" + + gomock "github.com/golang/mock/gomock" ) -// MockSpy is a mock of Spy interface +// MockSpy is a mock of Spy interface. type MockSpy struct { ctrl *gomock.Controller recorder *MockSpyMockRecorder } -// MockSpyMockRecorder is the mock recorder for MockSpy +// MockSpyMockRecorder is the mock recorder for MockSpy. type MockSpyMockRecorder struct { mock *MockSpy } -// NewMockSpy creates a new mock instance +// NewMockSpy creates a new mock instance. func NewMockSpy(ctrl *gomock.Controller) *MockSpy { mock := &MockSpy{ctrl: ctrl} mock.recorder = &MockSpyMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockSpy) EXPECT() *MockSpyMockRecorder { return m.recorder } -// Record mocks base method +// Record mocks base method. func (m *MockSpy) Record() { m.ctrl.T.Helper() m.ctrl.Call(m, "Record") } -// Record indicates an expected call of Record +// Record indicates an expected call of Record. func (mr *MockSpyMockRecorder) Record() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Record", reflect.TypeOf((*MockSpy)(nil).Record)) diff --git a/tools/tools.go b/tools/tools.go index 690d6ec75..37f09a2cd 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -1,10 +1,12 @@ +//go:build tools // +build tools package tools import ( - _ "github.com/onsi/ginkgo/ginkgo" // comment to make golint happy - _ "github.com/maxbrunsfeld/counterfeiter/v6" // comment to make golint happy + _ "github.com/golang/mock/mockgen/model" // comment to make golint happy + _ "github.com/maxbrunsfeld/counterfeiter/v6" // comment to make golint happy + _ "github.com/onsi/ginkgo/ginkgo" // comment to make golint happy ) // This file imports packages that are used when running go generate, or used diff --git a/ui/task/taskfakes/fake_reporter.go b/ui/task/taskfakes/fake_reporter.go index 49fd521ab..30ade9666 100644 --- a/ui/task/taskfakes/fake_reporter.go +++ b/ui/task/taskfakes/fake_reporter.go @@ -8,11 +8,6 @@ import ( ) type FakeReporter struct { - TaskStartedStub func(int) - taskStartedMutex sync.RWMutex - taskStartedArgsForCall []struct { - arg1 int - } TaskFinishedStub func(int, string) taskFinishedMutex sync.RWMutex taskFinishedArgsForCall []struct { @@ -25,32 +20,13 @@ type FakeReporter struct { arg1 int arg2 []byte } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *FakeReporter) TaskStarted(arg1 int) { - fake.taskStartedMutex.Lock() - fake.taskStartedArgsForCall = append(fake.taskStartedArgsForCall, struct { + TaskStartedStub func(int) + taskStartedMutex sync.RWMutex + taskStartedArgsForCall []struct { arg1 int - }{arg1}) - fake.recordInvocation("TaskStarted", []interface{}{arg1}) - fake.taskStartedMutex.Unlock() - if fake.TaskStartedStub != nil { - fake.TaskStartedStub(arg1) } -} - -func (fake *FakeReporter) TaskStartedCallCount() int { - fake.taskStartedMutex.RLock() - defer fake.taskStartedMutex.RUnlock() - return len(fake.taskStartedArgsForCall) -} - -func (fake *FakeReporter) TaskStartedArgsForCall(i int) int { - fake.taskStartedMutex.RLock() - defer fake.taskStartedMutex.RUnlock() - return fake.taskStartedArgsForCall[i].arg1 + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex } func (fake *FakeReporter) TaskFinished(arg1 int, arg2 string) { @@ -59,9 +35,10 @@ func (fake *FakeReporter) TaskFinished(arg1 int, arg2 string) { arg1 int arg2 string }{arg1, arg2}) + stub := fake.TaskFinishedStub fake.recordInvocation("TaskFinished", []interface{}{arg1, arg2}) fake.taskFinishedMutex.Unlock() - if fake.TaskFinishedStub != nil { + if stub != nil { fake.TaskFinishedStub(arg1, arg2) } } @@ -72,10 +49,17 @@ func (fake *FakeReporter) TaskFinishedCallCount() int { return len(fake.taskFinishedArgsForCall) } +func (fake *FakeReporter) TaskFinishedCalls(stub func(int, string)) { + fake.taskFinishedMutex.Lock() + defer fake.taskFinishedMutex.Unlock() + fake.TaskFinishedStub = stub +} + func (fake *FakeReporter) TaskFinishedArgsForCall(i int) (int, string) { fake.taskFinishedMutex.RLock() defer fake.taskFinishedMutex.RUnlock() - return fake.taskFinishedArgsForCall[i].arg1, fake.taskFinishedArgsForCall[i].arg2 + argsForCall := fake.taskFinishedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeReporter) TaskOutputChunk(arg1 int, arg2 []byte) { @@ -89,9 +73,10 @@ func (fake *FakeReporter) TaskOutputChunk(arg1 int, arg2 []byte) { arg1 int arg2 []byte }{arg1, arg2Copy}) + stub := fake.TaskOutputChunkStub fake.recordInvocation("TaskOutputChunk", []interface{}{arg1, arg2Copy}) fake.taskOutputChunkMutex.Unlock() - if fake.TaskOutputChunkStub != nil { + if stub != nil { fake.TaskOutputChunkStub(arg1, arg2) } } @@ -102,22 +87,65 @@ func (fake *FakeReporter) TaskOutputChunkCallCount() int { return len(fake.taskOutputChunkArgsForCall) } +func (fake *FakeReporter) TaskOutputChunkCalls(stub func(int, []byte)) { + fake.taskOutputChunkMutex.Lock() + defer fake.taskOutputChunkMutex.Unlock() + fake.TaskOutputChunkStub = stub +} + func (fake *FakeReporter) TaskOutputChunkArgsForCall(i int) (int, []byte) { fake.taskOutputChunkMutex.RLock() defer fake.taskOutputChunkMutex.RUnlock() - return fake.taskOutputChunkArgsForCall[i].arg1, fake.taskOutputChunkArgsForCall[i].arg2 + argsForCall := fake.taskOutputChunkArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeReporter) TaskStarted(arg1 int) { + fake.taskStartedMutex.Lock() + fake.taskStartedArgsForCall = append(fake.taskStartedArgsForCall, struct { + arg1 int + }{arg1}) + stub := fake.TaskStartedStub + fake.recordInvocation("TaskStarted", []interface{}{arg1}) + fake.taskStartedMutex.Unlock() + if stub != nil { + fake.TaskStartedStub(arg1) + } +} + +func (fake *FakeReporter) TaskStartedCallCount() int { + fake.taskStartedMutex.RLock() + defer fake.taskStartedMutex.RUnlock() + return len(fake.taskStartedArgsForCall) +} + +func (fake *FakeReporter) TaskStartedCalls(stub func(int)) { + fake.taskStartedMutex.Lock() + defer fake.taskStartedMutex.Unlock() + fake.TaskStartedStub = stub +} + +func (fake *FakeReporter) TaskStartedArgsForCall(i int) int { + fake.taskStartedMutex.RLock() + defer fake.taskStartedMutex.RUnlock() + argsForCall := fake.taskStartedArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeReporter) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.taskStartedMutex.RLock() - defer fake.taskStartedMutex.RUnlock() fake.taskFinishedMutex.RLock() defer fake.taskFinishedMutex.RUnlock() fake.taskOutputChunkMutex.RLock() defer fake.taskOutputChunkMutex.RUnlock() - return fake.invocations + fake.taskStartedMutex.RLock() + defer fake.taskStartedMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeReporter) recordInvocation(key string, args []interface{}) { diff --git a/vendor/github.com/golang/mock/mockgen/model/model.go b/vendor/github.com/golang/mock/mockgen/model/model.go new file mode 100644 index 000000000..2c6a62ceb --- /dev/null +++ b/vendor/github.com/golang/mock/mockgen/model/model.go @@ -0,0 +1,495 @@ +// Copyright 2012 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package model contains the data model necessary for generating mock implementations. +package model + +import ( + "encoding/gob" + "fmt" + "io" + "reflect" + "strings" +) + +// pkgPath is the importable path for package model +const pkgPath = "github.com/golang/mock/mockgen/model" + +// Package is a Go package. It may be a subset. +type Package struct { + Name string + PkgPath string + Interfaces []*Interface + DotImports []string +} + +// Print writes the package name and its exported interfaces. +func (pkg *Package) Print(w io.Writer) { + _, _ = fmt.Fprintf(w, "package %s\n", pkg.Name) + for _, intf := range pkg.Interfaces { + intf.Print(w) + } +} + +// Imports returns the imports needed by the Package as a set of import paths. +func (pkg *Package) Imports() map[string]bool { + im := make(map[string]bool) + for _, intf := range pkg.Interfaces { + intf.addImports(im) + } + return im +} + +// Interface is a Go interface. +type Interface struct { + Name string + Methods []*Method +} + +// Print writes the interface name and its methods. +func (intf *Interface) Print(w io.Writer) { + _, _ = fmt.Fprintf(w, "interface %s\n", intf.Name) + for _, m := range intf.Methods { + m.Print(w) + } +} + +func (intf *Interface) addImports(im map[string]bool) { + for _, m := range intf.Methods { + m.addImports(im) + } +} + +// AddMethod adds a new method, de-duplicating by method name. +func (intf *Interface) AddMethod(m *Method) { + for _, me := range intf.Methods { + if me.Name == m.Name { + return + } + } + intf.Methods = append(intf.Methods, m) +} + +// Method is a single method of an interface. +type Method struct { + Name string + In, Out []*Parameter + Variadic *Parameter // may be nil +} + +// Print writes the method name and its signature. +func (m *Method) Print(w io.Writer) { + _, _ = fmt.Fprintf(w, " - method %s\n", m.Name) + if len(m.In) > 0 { + _, _ = fmt.Fprintf(w, " in:\n") + for _, p := range m.In { + p.Print(w) + } + } + if m.Variadic != nil { + _, _ = fmt.Fprintf(w, " ...:\n") + m.Variadic.Print(w) + } + if len(m.Out) > 0 { + _, _ = fmt.Fprintf(w, " out:\n") + for _, p := range m.Out { + p.Print(w) + } + } +} + +func (m *Method) addImports(im map[string]bool) { + for _, p := range m.In { + p.Type.addImports(im) + } + if m.Variadic != nil { + m.Variadic.Type.addImports(im) + } + for _, p := range m.Out { + p.Type.addImports(im) + } +} + +// Parameter is an argument or return parameter of a method. +type Parameter struct { + Name string // may be empty + Type Type +} + +// Print writes a method parameter. +func (p *Parameter) Print(w io.Writer) { + n := p.Name + if n == "" { + n = `""` + } + _, _ = fmt.Fprintf(w, " - %v: %v\n", n, p.Type.String(nil, "")) +} + +// Type is a Go type. +type Type interface { + String(pm map[string]string, pkgOverride string) string + addImports(im map[string]bool) +} + +func init() { + gob.Register(&ArrayType{}) + gob.Register(&ChanType{}) + gob.Register(&FuncType{}) + gob.Register(&MapType{}) + gob.Register(&NamedType{}) + gob.Register(&PointerType{}) + + // Call gob.RegisterName to make sure it has the consistent name registered + // for both gob decoder and encoder. + // + // For a non-pointer type, gob.Register will try to get package full path by + // calling rt.PkgPath() for a name to register. If your project has vendor + // directory, it is possible that PkgPath will get a path like this: + // ../../../vendor/github.com/golang/mock/mockgen/model + gob.RegisterName(pkgPath+".PredeclaredType", PredeclaredType("")) +} + +// ArrayType is an array or slice type. +type ArrayType struct { + Len int // -1 for slices, >= 0 for arrays + Type Type +} + +func (at *ArrayType) String(pm map[string]string, pkgOverride string) string { + s := "[]" + if at.Len > -1 { + s = fmt.Sprintf("[%d]", at.Len) + } + return s + at.Type.String(pm, pkgOverride) +} + +func (at *ArrayType) addImports(im map[string]bool) { at.Type.addImports(im) } + +// ChanType is a channel type. +type ChanType struct { + Dir ChanDir // 0, 1 or 2 + Type Type +} + +func (ct *ChanType) String(pm map[string]string, pkgOverride string) string { + s := ct.Type.String(pm, pkgOverride) + if ct.Dir == RecvDir { + return "<-chan " + s + } + if ct.Dir == SendDir { + return "chan<- " + s + } + return "chan " + s +} + +func (ct *ChanType) addImports(im map[string]bool) { ct.Type.addImports(im) } + +// ChanDir is a channel direction. +type ChanDir int + +// Constants for channel directions. +const ( + RecvDir ChanDir = 1 + SendDir ChanDir = 2 +) + +// FuncType is a function type. +type FuncType struct { + In, Out []*Parameter + Variadic *Parameter // may be nil +} + +func (ft *FuncType) String(pm map[string]string, pkgOverride string) string { + args := make([]string, len(ft.In)) + for i, p := range ft.In { + args[i] = p.Type.String(pm, pkgOverride) + } + if ft.Variadic != nil { + args = append(args, "..."+ft.Variadic.Type.String(pm, pkgOverride)) + } + rets := make([]string, len(ft.Out)) + for i, p := range ft.Out { + rets[i] = p.Type.String(pm, pkgOverride) + } + retString := strings.Join(rets, ", ") + if nOut := len(ft.Out); nOut == 1 { + retString = " " + retString + } else if nOut > 1 { + retString = " (" + retString + ")" + } + return "func(" + strings.Join(args, ", ") + ")" + retString +} + +func (ft *FuncType) addImports(im map[string]bool) { + for _, p := range ft.In { + p.Type.addImports(im) + } + if ft.Variadic != nil { + ft.Variadic.Type.addImports(im) + } + for _, p := range ft.Out { + p.Type.addImports(im) + } +} + +// MapType is a map type. +type MapType struct { + Key, Value Type +} + +func (mt *MapType) String(pm map[string]string, pkgOverride string) string { + return "map[" + mt.Key.String(pm, pkgOverride) + "]" + mt.Value.String(pm, pkgOverride) +} + +func (mt *MapType) addImports(im map[string]bool) { + mt.Key.addImports(im) + mt.Value.addImports(im) +} + +// NamedType is an exported type in a package. +type NamedType struct { + Package string // may be empty + Type string +} + +func (nt *NamedType) String(pm map[string]string, pkgOverride string) string { + if pkgOverride == nt.Package { + return nt.Type + } + prefix := pm[nt.Package] + if prefix != "" { + return prefix + "." + nt.Type + } + + return nt.Type +} + +func (nt *NamedType) addImports(im map[string]bool) { + if nt.Package != "" { + im[nt.Package] = true + } +} + +// PointerType is a pointer to another type. +type PointerType struct { + Type Type +} + +func (pt *PointerType) String(pm map[string]string, pkgOverride string) string { + return "*" + pt.Type.String(pm, pkgOverride) +} +func (pt *PointerType) addImports(im map[string]bool) { pt.Type.addImports(im) } + +// PredeclaredType is a predeclared type such as "int". +type PredeclaredType string + +func (pt PredeclaredType) String(map[string]string, string) string { return string(pt) } +func (pt PredeclaredType) addImports(map[string]bool) {} + +// The following code is intended to be called by the program generated by ../reflect.go. + +// InterfaceFromInterfaceType returns a pointer to an interface for the +// given reflection interface type. +func InterfaceFromInterfaceType(it reflect.Type) (*Interface, error) { + if it.Kind() != reflect.Interface { + return nil, fmt.Errorf("%v is not an interface", it) + } + intf := &Interface{} + + for i := 0; i < it.NumMethod(); i++ { + mt := it.Method(i) + // TODO: need to skip unexported methods? or just raise an error? + m := &Method{ + Name: mt.Name, + } + + var err error + m.In, m.Variadic, m.Out, err = funcArgsFromType(mt.Type) + if err != nil { + return nil, err + } + + intf.AddMethod(m) + } + + return intf, nil +} + +// t's Kind must be a reflect.Func. +func funcArgsFromType(t reflect.Type) (in []*Parameter, variadic *Parameter, out []*Parameter, err error) { + nin := t.NumIn() + if t.IsVariadic() { + nin-- + } + var p *Parameter + for i := 0; i < nin; i++ { + p, err = parameterFromType(t.In(i)) + if err != nil { + return + } + in = append(in, p) + } + if t.IsVariadic() { + p, err = parameterFromType(t.In(nin).Elem()) + if err != nil { + return + } + variadic = p + } + for i := 0; i < t.NumOut(); i++ { + p, err = parameterFromType(t.Out(i)) + if err != nil { + return + } + out = append(out, p) + } + return +} + +func parameterFromType(t reflect.Type) (*Parameter, error) { + tt, err := typeFromType(t) + if err != nil { + return nil, err + } + return &Parameter{Type: tt}, nil +} + +var errorType = reflect.TypeOf((*error)(nil)).Elem() + +var byteType = reflect.TypeOf(byte(0)) + +func typeFromType(t reflect.Type) (Type, error) { + // Hack workaround for https://golang.org/issue/3853. + // This explicit check should not be necessary. + if t == byteType { + return PredeclaredType("byte"), nil + } + + if imp := t.PkgPath(); imp != "" { + return &NamedType{ + Package: impPath(imp), + Type: t.Name(), + }, nil + } + + // only unnamed or predeclared types after here + + // Lots of types have element types. Let's do the parsing and error checking for all of them. + var elemType Type + switch t.Kind() { + case reflect.Array, reflect.Chan, reflect.Map, reflect.Ptr, reflect.Slice: + var err error + elemType, err = typeFromType(t.Elem()) + if err != nil { + return nil, err + } + } + + switch t.Kind() { + case reflect.Array: + return &ArrayType{ + Len: t.Len(), + Type: elemType, + }, nil + case reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, + reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128, reflect.String: + return PredeclaredType(t.Kind().String()), nil + case reflect.Chan: + var dir ChanDir + switch t.ChanDir() { + case reflect.RecvDir: + dir = RecvDir + case reflect.SendDir: + dir = SendDir + } + return &ChanType{ + Dir: dir, + Type: elemType, + }, nil + case reflect.Func: + in, variadic, out, err := funcArgsFromType(t) + if err != nil { + return nil, err + } + return &FuncType{ + In: in, + Out: out, + Variadic: variadic, + }, nil + case reflect.Interface: + // Two special interfaces. + if t.NumMethod() == 0 { + return PredeclaredType("interface{}"), nil + } + if t == errorType { + return PredeclaredType("error"), nil + } + case reflect.Map: + kt, err := typeFromType(t.Key()) + if err != nil { + return nil, err + } + return &MapType{ + Key: kt, + Value: elemType, + }, nil + case reflect.Ptr: + return &PointerType{ + Type: elemType, + }, nil + case reflect.Slice: + return &ArrayType{ + Len: -1, + Type: elemType, + }, nil + case reflect.Struct: + if t.NumField() == 0 { + return PredeclaredType("struct{}"), nil + } + } + + // TODO: Struct, UnsafePointer + return nil, fmt.Errorf("can't yet turn %v (%v) into a model.Type", t, t.Kind()) +} + +// impPath sanitizes the package path returned by `PkgPath` method of a reflect Type so that +// it is importable. PkgPath might return a path that includes "vendor". These paths do not +// compile, so we need to remove everything up to and including "/vendor/". +// See https://github.com/golang/go/issues/12019. +func impPath(imp string) string { + if strings.HasPrefix(imp, "vendor/") { + imp = "/" + imp + } + if i := strings.LastIndex(imp, "/vendor/"); i != -1 { + imp = imp[i+len("/vendor/"):] + } + return imp +} + +// ErrorInterface represent built-in error interface. +var ErrorInterface = Interface{ + Name: "error", + Methods: []*Method{ + { + Name: "Error", + Out: []*Parameter{ + { + Name: "", + Type: PredeclaredType("string"), + }, + }, + }, + }, +} diff --git a/vendor/modules.txt b/vendor/modules.txt index f87642601..71b738b12 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -166,6 +166,7 @@ github.com/golang/groupcache/lru # github.com/golang/mock v1.6.0 ## explicit; go 1.11 github.com/golang/mock/gomock +github.com/golang/mock/mockgen/model # github.com/golang/protobuf v1.5.2 ## explicit; go 1.9 github.com/golang/protobuf/proto