Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
rename Validate() to Prepare() to cover more resposibility
Browse files Browse the repository at this point in the history
  • Loading branch information
imantung committed Oct 25, 2019
1 parent a858431 commit d993162
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion EXPERIMENTAL/typicmd/buildtool/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func Run(c *typictx.Context) {
app.Description = c.Description
app.Version = c.Version
app.Before = func(ctx *cli.Context) error {
return c.Validate()
return c.Preparing()
}
for _, cmd := range commands(c) {
app.Commands = append(app.Commands, cmd.CliCommand(c))
Expand Down
4 changes: 2 additions & 2 deletions EXPERIMENTAL/typicmd/prebuilder/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func Run(ctx *typictx.Context) {
if os.Getenv(debugEnv) != "" {
log.SetLevel(log.DebugLevel)
}
log.Debug("Validate the context")
fatalIfError(ctx.Validate())
log.Debug("Preparing the context")
fatalIfError(ctx.Preparing())
log.Debug("Prepare Environment File")
typienv.PrepareEnvFile(ctx)
prebuilder := prebuilder{}
Expand Down
11 changes: 9 additions & 2 deletions EXPERIMENTAL/typictx/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,15 @@ func (c *Context) DockerCompose() (dockerCompose *docker.Compose) {
return
}

// Validate the context
func (c *Context) Validate() error {
// Preparing context
func (c *Context) Preparing() (err error) {
if err = c.validate(); err != nil {
return invalidContextError("Name can't not empty")
}
return
}

func (c *Context) validate() error {
if c.Name == "" {
return invalidContextError("Name can't not empty")
}
Expand Down

0 comments on commit d993162

Please sign in to comment.