本文整理匯總了Golang中github.com/apex/apex/project.Project類的典型用法代碼示例。如果您正苦於以下問題:Golang Project類的具體用法?Golang Project怎麽用?Golang Project使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Project類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: deploy
// deploy code and config changes.
func deploy(project *project.Project, names []string, env []string) {
for _, s := range env {
parts := strings.Split(s, "=")
project.SetEnv(parts[0], parts[1])
}
if len(names) == 0 {
names = project.FunctionNames()
}
if err := project.DeployAndClean(names); err != nil {
log.Fatalf("error: %s", err)
}
}
示例2: delete
// delete the functions.
func delete(project *project.Project, names []string, force bool) {
if len(names) == 0 {
names = project.FunctionNames()
}
if !force && len(names) > 1 {
fmt.Printf("The following will be deleted:\n\n")
for _, name := range names {
fmt.Printf(" - %s\n", name)
}
fmt.Printf("\n")
}
if !force && !prompt.Confirm("Are you sure? (yes/no)") {
return
}
if err := project.Delete(names); err != nil {
log.Fatalf("error: %s", err)
}
}
示例3: build
// build outputs the generated archive to stdout.
func build(project *project.Project, name []string) {
fn, err := project.FunctionByName(name[0])
if err != nil {
log.Fatalf("error: %s", err)
}
zip, err := fn.Zip()
if err != nil {
log.Fatalf("error: %s", err)
}
_, err = io.Copy(os.Stdout, zip)
if err != nil {
log.Fatalf("error: %s", err)
}
}
示例4: rollback
// rollback the function with optional version.
func rollback(project *project.Project, name []string, version interface{}) {
fn, err := project.FunctionByName(name[0])
if err != nil {
log.Fatalf("error: %s", err)
}
if version == nil {
err = fn.Rollback()
} else {
err = fn.RollbackVersion(version.(string))
}
if err != nil {
log.Fatalf("error: %s", err)
}
}
示例5: invoke
// invoke reads request json from stdin and outputs the responses.
func invoke(project *project.Project, name []string, verbose, async bool) {
dec := json.NewDecoder(os.Stdin)
kind := function.RequestResponse
if async {
kind = function.Event
}
fn, err := project.FunctionByName(name[0])
if err != nil {
log.Fatalf("error: %s", err)
}
for {
var v struct {
Event interface{}
Context interface{}
}
err := dec.Decode(&v)
if err == io.EOF {
break
}
if err != nil {
log.Fatalf("error: %s", err)
}
reply, logs, err := fn.Invoke(v.Event, v.Context, kind)
if err != nil {
log.Fatalf("error: %s", err)
}
// TODO(tj) rename flag to --with-logs or --logs
if verbose {
io.Copy(os.Stderr, logs)
}
io.Copy(os.Stdout, reply)
fmt.Fprintf(os.Stdout, "\n")
}
}