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:
Kostiantyn Kalynovskyi 2020-07-15 18:34:20 -05:00 committed by Kostyantyn Kalynovskyi
parent 66fc562667
commit dfb74fb878
6 changed files with 20 additions and 10 deletions

View File

@ -23,7 +23,7 @@ import (
// Executor interface should be implemented by each runner // Executor interface should be implemented by each runner
type Executor interface { type Executor interface {
Run(dryrun, debug bool) error Run(dryrun, debug, wait bool) error
Render(io.Writer) error Render(io.Writer) error
Validate() error Validate() error
Wait() error Wait() error

View File

@ -15,6 +15,7 @@
package phase package phase
import ( import (
"fmt"
"path/filepath" "path/filepath"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -26,12 +27,6 @@ import (
"opendev.org/airship/airshipctl/pkg/phase/ifc" "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 ( var (
// ExecutorRegistry contins registered runner factories // ExecutorRegistry contins registered runner factories
ExecutorRegistry = make(map[schema.GroupVersionKind]ifc.ExecutorFactory) ExecutorRegistry = make(map[schema.GroupVersionKind]ifc.ExecutorFactory)
@ -48,7 +43,12 @@ func (p *Cmd) getBundle() (document.Bundle, error) {
if err != nil { if err != nil {
return nil, err 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 // GetPhase returns particular phase object identified by name
@ -126,7 +126,7 @@ func (p *Cmd) Exec(name string) error {
return err return err
} }
return executor.Run(p.DryRun, p.Debug) return executor.Run(p.DryRun, p.Debug, true)
} }
// Plan shows available phase names // Plan shows available phase names

View File

@ -71,6 +71,7 @@ func TestPhasePlan(t *testing.T) {
m, err := s.Config.CurrentContextManifest() m, err := s.Config.CurrentContextManifest()
require.NoError(t, err) require.NoError(t, err)
m.SubPath = "no_plan_site" m.SubPath = "no_plan_site"
m.MetadataPath = "no_plan_site/metadata.yaml"
return s return s
}, },
expectedErr: document.ErrDocNotFound{ expectedErr: document.ErrDocNotFound{

View File

@ -27,6 +27,8 @@ kind: Config
manifests: manifests:
dummy_manifest: dummy_manifest:
primaryRepositoryName: primary primaryRepositoryName: primary
targetPath: testdata
metadataPath: valid_site/metadata.yaml
repositories: repositories:
primary: primary:
auth: auth:
@ -39,6 +41,5 @@ manifests:
tag: v1.0.1 tag: v1.0.1
url: http://dummy.url.com/primary.git url: http://dummy.url.com/primary.git
subPath: valid_site subPath: valid_site
targetPath: testdata
users: users:
dummy_user: {} dummy_user: {}

View File

@ -0,0 +1,4 @@
inventory:
path: "manifests/site/inventory"
phase:
path: "no_plan_site/phases"

View File

@ -0,0 +1,4 @@
inventory:
path: "manifests/site/inventory"
phase:
path: "valid_site/phases"