Integrate ManifestMetadata with phase executors
With this commit executors will not rely on hardcoded path to build bundle with phase information Change-Id: I6b8826929cb5a4b95a5c4d30f23fad3a3af52555 Relates-To: #259
This commit is contained in:
parent
66fc562667
commit
dfb74fb878
@ -23,7 +23,7 @@ import (
|
||||
|
||||
// Executor interface should be implemented by each runner
|
||||
type Executor interface {
|
||||
Run(dryrun, debug bool) error
|
||||
Run(dryrun, debug, wait bool) error
|
||||
Render(io.Writer) error
|
||||
Validate() error
|
||||
Wait() error
|
||||
|
@ -15,6 +15,7 @@
|
||||
package phase
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@ -26,12 +27,6 @@ import (
|
||||
"opendev.org/airship/airshipctl/pkg/phase/ifc"
|
||||
)
|
||||
|
||||
const (
|
||||
// PhaseDirName directory for bundle with phases
|
||||
// TODO (dukov) Remove this once repository metadata is ready
|
||||
PhaseDirName = "phases"
|
||||
)
|
||||
|
||||
var (
|
||||
// ExecutorRegistry contins registered runner factories
|
||||
ExecutorRegistry = make(map[schema.GroupVersionKind]ifc.ExecutorFactory)
|
||||
@ -48,7 +43,12 @@ func (p *Cmd) getBundle() (document.Bundle, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return document.NewBundleByPath(filepath.Join(ccm.TargetPath, ccm.SubPath, PhaseDirName))
|
||||
fmt.Printf("Target path is: %s", filepath.Join(ccm.TargetPath))
|
||||
meta, err := p.Config.CurrentContextManifestMetadata()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return document.NewBundleByPath(filepath.Join(ccm.TargetPath, meta.PhaseMeta.Path))
|
||||
}
|
||||
|
||||
// GetPhase returns particular phase object identified by name
|
||||
@ -126,7 +126,7 @@ func (p *Cmd) Exec(name string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
return executor.Run(p.DryRun, p.Debug)
|
||||
return executor.Run(p.DryRun, p.Debug, true)
|
||||
}
|
||||
|
||||
// Plan shows available phase names
|
||||
|
@ -71,6 +71,7 @@ func TestPhasePlan(t *testing.T) {
|
||||
m, err := s.Config.CurrentContextManifest()
|
||||
require.NoError(t, err)
|
||||
m.SubPath = "no_plan_site"
|
||||
m.MetadataPath = "no_plan_site/metadata.yaml"
|
||||
return s
|
||||
},
|
||||
expectedErr: document.ErrDocNotFound{
|
||||
|
3
pkg/phase/testdata/airshipconfig.yaml
vendored
3
pkg/phase/testdata/airshipconfig.yaml
vendored
@ -27,6 +27,8 @@ kind: Config
|
||||
manifests:
|
||||
dummy_manifest:
|
||||
primaryRepositoryName: primary
|
||||
targetPath: testdata
|
||||
metadataPath: valid_site/metadata.yaml
|
||||
repositories:
|
||||
primary:
|
||||
auth:
|
||||
@ -39,6 +41,5 @@ manifests:
|
||||
tag: v1.0.1
|
||||
url: http://dummy.url.com/primary.git
|
||||
subPath: valid_site
|
||||
targetPath: testdata
|
||||
users:
|
||||
dummy_user: {}
|
4
pkg/phase/testdata/no_plan_site/metadata.yaml
vendored
Normal file
4
pkg/phase/testdata/no_plan_site/metadata.yaml
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
inventory:
|
||||
path: "manifests/site/inventory"
|
||||
phase:
|
||||
path: "no_plan_site/phases"
|
4
pkg/phase/testdata/valid_site/metadata.yaml
vendored
Normal file
4
pkg/phase/testdata/valid_site/metadata.yaml
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
inventory:
|
||||
path: "manifests/site/inventory"
|
||||
phase:
|
||||
path: "valid_site/phases"
|
Loading…
Reference in New Issue
Block a user