-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8f2fe0
commit 28d195b
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 1999-2021. Plesk International GmbH. | ||
|
||
package cmd | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"github.com/plesk/pleskapp/plesk/actions" | ||
"github.com/plesk/pleskapp/plesk/config" | ||
"github.com/plesk/pleskapp/plesk/locales" | ||
"github.com/plesk/pleskapp/plesk/types" | ||
"github.com/spf13/cobra" | ||
"os" | ||
"path" | ||
"strings" | ||
) | ||
|
||
var deployCmd = &cobra.Command{ | ||
Use: "deploy [SERVER]", | ||
Short: locales.L.Get("deploy.description"), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
workDir, _ := os.Getwd() | ||
appName := path.Base(workDir) | ||
fmt.Println("App name:", appName) | ||
|
||
server, err := config.GetServerByArgs(args) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if 0 == len(server.Info.IP.IPv4) { | ||
return errors.New("IPv4 address is required") | ||
} | ||
defaultIp := server.Info.IP.IPv4[0] | ||
fmt.Printf("IP: %v\n", defaultIp) | ||
|
||
domainName := fmt.Sprintf("%s.%s.plesk.page", appName, strings.ReplaceAll(defaultIp, ".", "-")) | ||
fmt.Println("Domain name:", domainName) | ||
|
||
var domain *types.Domain | ||
domain, err = config.GetDomain(*server, domainName) | ||
if err != nil { | ||
fmt.Printf("Creating the domain %s...\n", domainName) | ||
err = actions.DomainAdd(*server, domainName, types.ServerIPAddresses{ | ||
IPv4: []string{defaultIp}, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println("Domain has been created.") | ||
} else { | ||
fmt.Printf("Domain %s has been found.\n", domainName) | ||
} | ||
|
||
fmt.Println("Uploading the content...") | ||
err = actions.UploadDirectory(*server, *domain, true, false, workDir, nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ func Execute() error { | |
webCmd, | ||
completionCmd, | ||
pleskCmd, | ||
deployCmd, | ||
) | ||
|
||
return rootCmd.Execute() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters