Skip to content

Commit

Permalink
First version of kpt live migrate command
Browse files Browse the repository at this point in the history
  • Loading branch information
seans3 committed Oct 30, 2020
1 parent c9ec366 commit ae7d9fa
Show file tree
Hide file tree
Showing 9 changed files with 1,044 additions and 13 deletions.
11 changes: 9 additions & 2 deletions commands/initcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ import (

const defaultInventoryName = "inventory"

// InvExistsError defines new error when the inventory
// values have already been set on the Kptfile.
type InvExistsError struct{}

func (i *InvExistsError) Error() string {
return invExistsError
}

var invExistsError = `ResourceGroup configuration has already been created. Changing
them after a package has been applied to the cluster can lead to
undesired results. Use the --force flag to suppress this error.
Expand Down Expand Up @@ -64,7 +72,6 @@ func (io *KptInitOptions) Run(args []string) error {
return err
}
io.namespace = strings.TrimSpace(ns)
fmt.Fprintf(io.ioStreams.Out, "namespace: %s is used for inventory object\n", io.namespace)
// Set the init options default inventory object name, if not set by flag.
if io.name == "" {
randomSuffix := common.RandomStr(time.Now().UTC().UnixNano())
Expand Down Expand Up @@ -116,7 +123,7 @@ func (io *KptInitOptions) updateKptfile() error {
// Validate the inventory values don't already exist
isEmpty := kptfileInventoryEmpty(kf.Inventory)
if !isEmpty && !io.force {
return fmt.Errorf(invExistsError)
return &InvExistsError{}
}
// Check the new inventory values are valid.
if err := io.validate(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion commands/initcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ upstream:
ref: master
inventory:
name: foo
namespace: bar
namespace: test-namespace
inventoryID: SSSSSSSSSS-RRRRR
`

Expand Down
Loading

0 comments on commit ae7d9fa

Please sign in to comment.