Skip to content

Commit

Permalink
Moved to Giltfile.yml from gilt.yml (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
retr0h authored Nov 13, 2023
1 parent b25aeeb commit 8823598
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 25 deletions.
5 changes: 0 additions & 5 deletions CHANGELOG.md

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This version of Gilt does not provide built in locking, unlike our python friend

### Overlay Repository

Create the giltfile (`gilt.yml`).
Create the giltfile (`Giltfile.yml`).

Clone the specified `url`@`version` to the configurable path `--giltdir`.
Extract the repo the `dstDir` when `dstDir` is provided. Otherwise, copy files
Expand Down Expand Up @@ -62,9 +62,9 @@ Overlay a remote repository into the destination provided.
$ gilt overlay
Use an alternate config file (default `gilt.yml`).
Use an alternate config file (default `Giltfile.yml`).

$ gilt overlay --filename /path/to/gilt.yml
$ gilt --giltfile /path/to/Giltfile.yml overlay

Optionally, override gilt's cache location (defaults to `~/.gilt/clone`):

Expand Down
10 changes: 3 additions & 7 deletions cmd/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ import (
"github.com/spf13/cobra"
)

var fileName string

// newRepositories constructs a new `repositories.Repositories`.
func newRepositories(debug bool, fileName string) (*repositories.Repositories, error) {
expandedFileName, err := util.ExpandUser(fileName)
func newRepositories(debug bool, giltFile string) (*repositories.Repositories, error) {
expandedFileName, err := util.ExpandUser(giltFile)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -76,7 +74,7 @@ var overlayCmd = &cobra.Command{
// We are logging errors, no need for cobra to re-log the error
cmd.SilenceErrors = true

r, err := newRepositories(debug, fileName)
r, err := newRepositories(debug, giltFile)
if err != nil {
logger.Error(
"error creating new Repositories",
Expand Down Expand Up @@ -116,7 +114,5 @@ var overlayCmd = &cobra.Command{
}

func init() {
rootCmd.PersistentFlags().
StringVarP(&fileName, "filename", "f", "gilt.yml", "Path to config file")
rootCmd.AddCommand(overlayCmd)
}
13 changes: 10 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ import (
)

var (
debug bool
giltDir string
logger *slog.Logger
debug bool
giltDir string
giltFile string
logger *slog.Logger
)

// rootCmd represents the base command when called without any subcommands
Expand Down Expand Up @@ -74,6 +75,12 @@ func init() {
rootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "Enable or disable debug mode")
rootCmd.PersistentFlags().
StringVarP(&giltDir, "giltdir", "c", "~/.gilt/clone", "Path to Gilt's clone dir")
rootCmd.PersistentFlags().
StringVarP(&giltFile, "giltfile", "f", "Giltfile.yml", "Path to config file")

if err := viper.BindPFlag("debug", rootCmd.PersistentFlags().Lookup("debug")); err != nil {
return
}
}

func initLogger() {
Expand Down
2 changes: 1 addition & 1 deletion internal/repositories/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
// Repositories is an object which implements the business logic interface.
type Repositories struct {
Debug bool // Debug option set from CLI with debug state.
Filename string // Filename option set from CLI with path to gilt.yml.
Filename string // Filename option set from CLI with path to Giltfile.yml.
Items []repository.Repository // Items slice containing Repository items.
}

Expand Down
2 changes: 1 addition & 1 deletion internal/repositories/repositories_public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (suite *RepositoriesTestSuite) TestUnmarshalYAMLFileReturnsErrorWithMissing
}

func (suite *RepositoriesTestSuite) TestUnmarshalYAMLFile() {
suite.r.Filename = path.Join("..", "..", "test", "gilt.yml")
suite.r.Filename = path.Join("..", "..", "test", "Giltfile.yml")
err := suite.r.UnmarshalYAMLFile()
assert.NoError(suite.T(), err)

Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions test/integration/test_cli.bats
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ setup() {

mkdir -p ${GILT_LIBRARY_DIR}
mkdir -p ${GILT_ROLES_DIR}
cp test/gilt.yml ${GILT_TEST_BASE_DIR}/gilt.yml
cp test/Giltfile.yml ${GILT_TEST_BASE_DIR}/Giltfile.yml
}

teardown() {
Expand All @@ -47,7 +47,7 @@ teardown() {
rm -rf ${GILT_LIBRARY_DIR}
rm -rf ${GILT_ROLES_DIR}
rm -rf ${GILT_TEST_DIR}
rm -f ${GILT_TEST_BASE_DIR}/gilt.yml
rm -f ${GILT_TEST_BASE_DIR}/Giltfile.yml
}

@test "invoke gilt without arguments prints usage" {
Expand All @@ -72,14 +72,14 @@ teardown() {
[ "$status" -eq 0 ]
}

@test "invoke gilt overlay subcommand with filename flag" {
run bash -c "cd ${GILT_TEST_BASE_DIR}; go run ${GILT_PROGRAM} --giltdir ${GILT_DIR} overlay --filename gilt.yml"
@test "invoke gilt overlay subcommand with giltfile flag" {
run bash -c "cd ${GILT_TEST_BASE_DIR}; go run ${GILT_PROGRAM} --giltdir ${GILT_DIR} --giltfile Giltfile.yml overlay"

[ "$status" -eq 0 ]
}

@test "invoke gilt overlay subcommand with f flag" {
run bash -c "cd ${GILT_TEST_BASE_DIR}; go run ${GILT_PROGRAM} --giltdir ${GILT_DIR} overlay -f gilt.yml"
run bash -c "cd ${GILT_TEST_BASE_DIR}; go run ${GILT_PROGRAM} --giltdir ${GILT_DIR} -f Giltfile.yml overlay"

[ "$status" -eq 0 ]
}
Expand Down

0 comments on commit 8823598

Please sign in to comment.