Skip to content

Commit

Permalink
Revert "add option to watch command to whitelist functions which will…
Browse files Browse the repository at this point in the history
… be deployed on changes"

This reverts commit 8e1496e.
  • Loading branch information
Ivan Vlasic committed Aug 16, 2021
1 parent 18deab6 commit 8674e8c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 34 deletions.
10 changes: 3 additions & 7 deletions cmd/mantil/cmd/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ var watchCmd = &cobra.Command{
if err != nil {
log.Fatal(err)
}
whitelistedFuncs, err := cmd.Flags().GetStringSlice("functions")
if err != nil {
log.Fatal(err)
}
d, err := deploy.New(p, aws, path, token, whitelistedFuncs...)
d, err := deploy.New(p, aws, path, token)
if err != nil {
log.Fatal(err)
}
watch.Start(path, func() {
log.Println("changes detected - starting deploy")
defer log.Println("deploy successfully finished")
if err := d.Deploy(); err != nil {
log.Fatal(err)
}
Expand All @@ -35,7 +33,5 @@ var watchCmd = &cobra.Command{
}

func init() {
watchCmd.Flags().StringSliceP("functions", "f", nil, "Whitelist functions which will be deployed on changes. If left empty all are whitelisted.")
rootCmd.AddCommand(watchCmd)

}
35 changes: 9 additions & 26 deletions internal/commands/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,18 @@ const (
)

type DeployCmd struct {
aws *aws.AWS
project *mantil.Project
path string
token string
whitelistedFuncs []string
aws *aws.AWS
project *mantil.Project
path string
token string
}

func New(project *mantil.Project, awsClient *aws.AWS, path, token string, whitelistedFuncs ...string) (*DeployCmd, error) {
func New(project *mantil.Project, awsClient *aws.AWS, path, token string) (*DeployCmd, error) {
d := &DeployCmd{
aws: awsClient,
project: project,
path: path,
token: token,
whitelistedFuncs: whitelistedFuncs,
aws: awsClient,
project: project,
path: path,
token: token,
}
return d, nil
}
Expand Down Expand Up @@ -178,9 +176,6 @@ func (d *DeployCmd) removedFunctions(localFuncs []string) []string {
func (d *DeployCmd) prepareFunctionsForDeploy() []mantil.Function {
funcsForDeploy := []mantil.Function{}
for i, f := range d.project.Functions {
if !d.isWhitelistedFunc(f) {
continue
}
funcDir := path.Join(d.path, FunctionsDir, f.Name)
isImage := d.isFunctionImage(funcDir)

Expand Down Expand Up @@ -249,18 +244,6 @@ func (d *DeployCmd) uploadBinaryToS3(key, binaryPath string) error {
return nil
}

func (d *DeployCmd) isWhitelistedFunc(f mantil.Function) bool {
if len(d.whitelistedFuncs) == 0 {
return true
}
for _, wlf := range d.whitelistedFuncs {
if wlf == f.Name {
return true
}
}
return false
}

func (d *DeployCmd) deployRequest(updates []mantil.FunctionUpdate) error {
type req struct {
ProjectName string
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/watch/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func Start(path string, onChange func()) {
log.Fatal(err)
}

log.Printf("starting watch on go files in %s", path)
log.Printf("starting watch for all go files in %s", path)
if err := w.Start(1 * time.Second); err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 8674e8c

Please sign in to comment.