Stop using CurrentContextEntryPoint in remote pkg
Note this commit doesn't refactor remote package, it is only created to shift from using CurrentContextEntryPoint function, which would in turn allow us to refactor config package and get rid of cluster types in airship config. Relates-To: #349 Relates-To: #246 Relates-To: #265 Change-Id: I1c941c8ade3497b9911fb126465aa85c25567431
This commit is contained in:
parent
1eba48d8cd
commit
2b30dd0d71
@ -21,6 +21,8 @@ import (
|
|||||||
"opendev.org/airship/airshipctl/pkg/config"
|
"opendev.org/airship/airshipctl/pkg/config"
|
||||||
"opendev.org/airship/airshipctl/pkg/document"
|
"opendev.org/airship/airshipctl/pkg/document"
|
||||||
"opendev.org/airship/airshipctl/pkg/log"
|
"opendev.org/airship/airshipctl/pkg/log"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/phase"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/phase/ifc"
|
||||||
"opendev.org/airship/airshipctl/pkg/remote/power"
|
"opendev.org/airship/airshipctl/pkg/remote/power"
|
||||||
"opendev.org/airship/airshipctl/pkg/remote/redfish"
|
"opendev.org/airship/airshipctl/pkg/remote/redfish"
|
||||||
redfishdell "opendev.org/airship/airshipctl/pkg/remote/redfish/vendors/dell"
|
redfishdell "opendev.org/airship/airshipctl/pkg/remote/redfish/vendors/dell"
|
||||||
@ -115,7 +117,7 @@ func ByName(name string) HostSelector {
|
|||||||
|
|
||||||
// NewManager provides a manager that exposes the capability to perform remote direct functionality and other
|
// NewManager provides a manager that exposes the capability to perform remote direct functionality and other
|
||||||
// out-of-band management on multiple hosts.
|
// out-of-band management on multiple hosts.
|
||||||
func NewManager(cfg *config.Config, phase string, hosts ...HostSelector) (*Manager, error) {
|
func NewManager(cfg *config.Config, phaseName string, hosts ...HostSelector) (*Manager, error) {
|
||||||
managementCfg, err := cfg.CurrentContextManagementConfig()
|
managementCfg, err := cfg.CurrentContextManagementConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -125,12 +127,18 @@ func NewManager(cfg *config.Config, phase string, hosts ...HostSelector) (*Manag
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
entrypoint, err := cfg.CurrentContextEntryPoint(phase)
|
helper, err := phase.NewHelper(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
docBundle, err := document.NewBundleByPath(entrypoint)
|
phaseClient := phase.NewClient(helper)
|
||||||
|
phase, err := phaseClient.PhaseByID(ifc.ID{Name: phaseName})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
docBundle, err := document.NewBundleByPath(phase.DocumentRoot())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,8 @@ func withTestDataPath(path string) Configuration {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("Unable to initialize management tests. Current Context error %q", err))
|
panic(fmt.Sprintf("Unable to initialize management tests. Current Context error %q", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest.TargetPath = fmt.Sprintf("testdata/%s", path)
|
manifest.TargetPath = fmt.Sprintf("testdata/%s", path)
|
||||||
|
manifest.MetadataPath = "metadata.yaml"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +108,9 @@ func TestNewManagerMultipleSelectorsNoMatch(t *testing.T) {
|
|||||||
|
|
||||||
manager, err := NewManager(settings, config.BootstrapPhase, ByName("master-2"),
|
manager, err := NewManager(settings, config.BootstrapPhase, ByName("master-2"),
|
||||||
ByLabel(document.EphemeralHostSelector))
|
ByLabel(document.EphemeralHostSelector))
|
||||||
|
|
||||||
|
// Must return ErrNoHostsFound here, without check for specific error, test can panic
|
||||||
|
require.Equal(t, ErrNoHostsFound{}, err)
|
||||||
require.Equal(t, 0, len(manager.Hosts))
|
require.Equal(t, 0, len(manager.Hosts))
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
}
|
}
|
||||||
|
@ -19,17 +19,25 @@ import (
|
|||||||
"opendev.org/airship/airshipctl/pkg/config"
|
"opendev.org/airship/airshipctl/pkg/config"
|
||||||
"opendev.org/airship/airshipctl/pkg/document"
|
"opendev.org/airship/airshipctl/pkg/document"
|
||||||
"opendev.org/airship/airshipctl/pkg/log"
|
"opendev.org/airship/airshipctl/pkg/log"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/phase"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/phase/ifc"
|
||||||
"opendev.org/airship/airshipctl/pkg/remote/power"
|
"opendev.org/airship/airshipctl/pkg/remote/power"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DoRemoteDirect bootstraps the ephemeral node.
|
// DoRemoteDirect bootstraps the ephemeral node.
|
||||||
func (b baremetalHost) DoRemoteDirect(cfg *config.Config) error {
|
func (b baremetalHost) DoRemoteDirect(cfg *config.Config) error {
|
||||||
root, err := cfg.CurrentContextEntryPoint(config.BootstrapPhase)
|
helper, err := phase.NewHelper(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
docBundle, err := document.NewBundleByPath(root)
|
phaseClient := phase.NewClient(helper)
|
||||||
|
phase, err := phaseClient.PhaseByID(ifc.ID{Name: config.BootstrapPhase})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
docBundle, err := document.NewBundleByPath(phase.DocumentRoot())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
resources:
|
resources:
|
||||||
- baremetal.yaml
|
- baremetal.yaml
|
||||||
- remote_direct_configuration.yaml
|
- remote_direct_configuration.yaml
|
||||||
|
- phase.yaml
|
||||||
|
12
pkg/remote/testdata/base/manifests/site/test-site/ephemeral/bootstrap/phase.yaml
vendored
Normal file
12
pkg/remote/testdata/base/manifests/site/test-site/ephemeral/bootstrap/phase.yaml
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
kind: Phase
|
||||||
|
metadata:
|
||||||
|
name: bootstrap
|
||||||
|
clusterName: ephemeral-cluster
|
||||||
|
config:
|
||||||
|
executorRef:
|
||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
kind: KubernetesApply
|
||||||
|
name: kubernetes-apply
|
||||||
|
documentEntryPoint: manifests/site/test-site/ephemeral/bootstrap
|
2
pkg/remote/testdata/base/metadata.yaml
vendored
Normal file
2
pkg/remote/testdata/base/metadata.yaml
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
phase:
|
||||||
|
path: manifests/site/test-site/ephemeral/bootstrap
|
2
pkg/remote/testdata/emptyurl/metadata.yaml
vendored
Normal file
2
pkg/remote/testdata/emptyurl/metadata.yaml
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
phase:
|
||||||
|
path: emptyurl/manifests/site/test-site/ephemeral/bootstrap
|
@ -1,3 +1,4 @@
|
|||||||
resources:
|
resources:
|
||||||
- baremetal.yaml
|
- baremetal.yaml
|
||||||
- remote_direct_configuration.yaml
|
- remote_direct_configuration.yaml
|
||||||
|
- phase.yaml
|
||||||
|
12
pkg/remote/testdata/noisourl/manifests/site/test-site/ephemeral/bootstrap/phase.yaml
vendored
Normal file
12
pkg/remote/testdata/noisourl/manifests/site/test-site/ephemeral/bootstrap/phase.yaml
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
kind: Phase
|
||||||
|
metadata:
|
||||||
|
name: bootstrap
|
||||||
|
clusterName: ephemeral-cluster
|
||||||
|
config:
|
||||||
|
executorRef:
|
||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
kind: KubernetesApply
|
||||||
|
name: kubernetes-apply
|
||||||
|
documentEntryPoint: manifests/site/test-site/ephemeral/bootstrap
|
2
pkg/remote/testdata/noisourl/metadata.yaml
vendored
Normal file
2
pkg/remote/testdata/noisourl/metadata.yaml
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
phase:
|
||||||
|
path: manifests/site/test-site/ephemeral/bootstrap
|
@ -1,2 +1,3 @@
|
|||||||
resources:
|
resources:
|
||||||
- baremetal.yaml
|
- baremetal.yaml
|
||||||
|
- phase.yaml
|
||||||
|
12
pkg/remote/testdata/noremote/manifests/site/test-site/ephemeral/bootstrap/phase.yaml
vendored
Normal file
12
pkg/remote/testdata/noremote/manifests/site/test-site/ephemeral/bootstrap/phase.yaml
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
kind: Phase
|
||||||
|
metadata:
|
||||||
|
name: bootstrap
|
||||||
|
clusterName: ephemeral-cluster
|
||||||
|
config:
|
||||||
|
executorRef:
|
||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
kind: KubernetesApply
|
||||||
|
name: kubernetes-apply
|
||||||
|
documentEntryPoint: manifests/site/test-site/ephemeral/bootstrap
|
2
pkg/remote/testdata/noremote/metadata.yaml
vendored
Normal file
2
pkg/remote/testdata/noremote/metadata.yaml
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
phase:
|
||||||
|
path: manifests/site/test-site/ephemeral/bootstrap
|
Loading…
Reference in New Issue
Block a user