Merge "Change default manifest target path"
This commit is contained in:
commit
1f52d46374
@ -15,18 +15,34 @@
|
||||
package document
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"opendev.org/airship/airshipctl/pkg/config"
|
||||
"opendev.org/airship/airshipctl/pkg/document/pull"
|
||||
)
|
||||
|
||||
const (
|
||||
long = `
|
||||
The remote manifests repositories as well as the target path where
|
||||
the repositories will be cloned are defined in the airship config file.
|
||||
|
||||
By default the airship config file is initialized with the
|
||||
repository "https://opendev.org/airship/treasuremap" as a source of
|
||||
manifests and with the manifests target path "%s".
|
||||
`
|
||||
)
|
||||
|
||||
// NewPullCommand creates a new command for pulling airship document repositories
|
||||
func NewPullCommand(cfgFactory config.Factory) *cobra.Command {
|
||||
var noCheckout bool
|
||||
documentPullCmd := &cobra.Command{
|
||||
Use: "pull",
|
||||
Short: "Pulls documents from remote git repository",
|
||||
Long: fmt.Sprintf(long[1:], filepath.Join(
|
||||
config.HomeEnvVar, config.AirshipConfigDir, config.AirshipDefaultManifest)),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return pull.Pull(cfgFactory, noCheckout)
|
||||
},
|
||||
|
@ -1,4 +1,9 @@
|
||||
Pulls documents from remote git repository
|
||||
The remote manifests repositories as well as the target path where
|
||||
the repositories will be cloned are defined in the airship config file.
|
||||
|
||||
By default the airship config file is initialized with the
|
||||
repository "https://opendev.org/airship/treasuremap" as a source of
|
||||
manifests and with the manifests target path "$HOME/.airship/default".
|
||||
|
||||
Usage:
|
||||
pull [flags]
|
||||
|
@ -4,7 +4,12 @@ Pulls documents from remote git repository
|
||||
|
||||
### Synopsis
|
||||
|
||||
Pulls documents from remote git repository
|
||||
The remote manifests repositories as well as the target path where
|
||||
the repositories will be cloned are defined in the airship config file.
|
||||
|
||||
By default the airship config file is initialized with the
|
||||
repository "https://opendev.org/airship/treasuremap" as a source of
|
||||
manifests and with the manifests target path "$HOME/.airship/default".
|
||||
|
||||
```
|
||||
airshipctl document pull [flags]
|
||||
|
@ -65,7 +65,7 @@ func (o *statusOptions) GetStatusMapDocs() (*StatusMap, []document.Document, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
docBundle, err := document.NewBundleByPath(manifest.TargetPath)
|
||||
docBundle, err := document.NewBundleByPath(manifest.GetTargetPath())
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ func (c *Config) CurrentContextTargetPath() (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return ccm.TargetPath, nil
|
||||
return ccm.GetTargetPath(), nil
|
||||
}
|
||||
|
||||
// CurrentContextPhaseRepositoryDir returns phase repository directory from current context's manifest
|
||||
@ -516,7 +516,7 @@ func (c *Config) CurrentContextManifestMetadata() (*Metadata, error) {
|
||||
PhaseMeta: &PhaseMeta{},
|
||||
}
|
||||
|
||||
data, err := c.fileSystem.ReadFile(filepath.Join(manifest.TargetPath, phaseRepoDir, manifest.MetadataPath))
|
||||
data, err := c.fileSystem.ReadFile(filepath.Join(manifest.GetTargetPath(), phaseRepoDir, manifest.MetadataPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -50,8 +50,6 @@ const (
|
||||
const (
|
||||
// DefaultTestPhaseRepo holds default repo name
|
||||
DefaultTestPhaseRepo = "primary"
|
||||
// DefaultTargetPath holds default target path
|
||||
DefaultTargetPath = "/tmp/default"
|
||||
// DefaultManifestMetadataFile default path to manifest metadata file
|
||||
DefaultManifestMetadataFile = "manifests/site/test-site/metadata.yaml"
|
||||
)
|
||||
|
@ -14,7 +14,9 @@ limitations under the License.
|
||||
|
||||
package config
|
||||
|
||||
import "sigs.k8s.io/yaml"
|
||||
import (
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
// Manifest is a tuple of references to a Manifest (how do Identify, collect ,
|
||||
// find the yaml manifests that airship uses to perform its operations)
|
||||
@ -74,3 +76,8 @@ func (m *Manifest) String() string {
|
||||
}
|
||||
return string(yamlData)
|
||||
}
|
||||
|
||||
// GetTargetPath returns TargetPath field
|
||||
func (m *Manifest) GetTargetPath() string {
|
||||
return m.TargetPath
|
||||
}
|
||||
|
32
pkg/config/manifest_test.go
Normal file
32
pkg/config/manifest_test.go
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
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 config_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"opendev.org/airship/airshipctl/pkg/config"
|
||||
)
|
||||
|
||||
func TestGetTargetPath(t *testing.T) {
|
||||
expected := "test"
|
||||
m := &config.Manifest{
|
||||
TargetPath: expected,
|
||||
}
|
||||
p := m.GetTargetPath()
|
||||
assert.Equal(t, expected, p)
|
||||
}
|
@ -16,8 +16,10 @@ package config
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"path/filepath"
|
||||
|
||||
"opendev.org/airship/airshipctl/pkg/fs"
|
||||
"opendev.org/airship/airshipctl/pkg/util"
|
||||
)
|
||||
|
||||
// NewConfig returns a newly initialized Config object
|
||||
@ -49,7 +51,7 @@ func NewConfig() *Config {
|
||||
},
|
||||
},
|
||||
},
|
||||
TargetPath: "/tmp/" + AirshipDefaultManifest,
|
||||
TargetPath: filepath.Join(util.UserHomeDir(), AirshipConfigDir, AirshipDefaultManifest),
|
||||
PhaseRepositoryName: DefaultTestPhaseRepo,
|
||||
InventoryRepositoryName: DefaultTestPhaseRepo,
|
||||
MetadataPath: DefaultManifestMetadataFile,
|
||||
@ -84,7 +86,7 @@ func NewManifest() *Manifest {
|
||||
return &Manifest{
|
||||
InventoryRepositoryName: DefaultTestPhaseRepo,
|
||||
PhaseRepositoryName: DefaultTestPhaseRepo,
|
||||
TargetPath: DefaultTargetPath,
|
||||
TargetPath: filepath.Join(util.UserHomeDir(), AirshipConfigDir, AirshipDefaultManifest),
|
||||
Repositories: map[string]*Repository{DefaultTestPhaseRepo: NewRepository()},
|
||||
MetadataPath: DefaultManifestMetadataFile,
|
||||
}
|
||||
|
@ -44,12 +44,12 @@ func cloneRepositories(cfg *config.Config, noCheckout bool) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repository, err := repo.NewRepository(currentManifest.TargetPath, extraRepoConfig)
|
||||
repository, err := repo.NewRepository(currentManifest.GetTargetPath(), extraRepoConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("Downloading %s repository %s from %s into %s",
|
||||
repoName, repository.Name, extraRepoConfig.URL(), currentManifest.TargetPath)
|
||||
repoName, repository.Name, extraRepoConfig.URL(), currentManifest.GetTargetPath())
|
||||
err = repository.Download(noCheckout)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user