Skip to content

Commit

Permalink
CCS-3436: Updates git2pantheon to pass down the server url to the upl…
Browse files Browse the repository at this point in the history
…oader. (#237)

* Read pantheon server URL on git2pantheon instead of the uploader.
  • Loading branch information
jmarrero committed Feb 24, 2020
1 parent e94f484 commit 7772251
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
7 changes: 4 additions & 3 deletions tools/git2pantheon/git_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ func push2Pantheon(directory string) {
log.Print("Found pantheon2.yml in the root of the repo, uploading.")
var user = os.Getenv("UPLOADER_USER")
var password = os.Getenv("UPLOADER_PASSWORD")
args := []string{"pantheon.py", "push", "--user", user, "--password", password, "--directory", directory}
if user == "" || password == "" {
log.Print("Credentials not found, using uploader's default credentials.")
var server = os.Getenv("PANTHEON_SERVER")
args := []string{"pantheon.py", "push", "--user", user, "--password", password, "--directory", directory, "--server", server}
if user == "" || password == "" || server == "" {
log.Print("Environment variables not found, using uploader and pantheon.yml settings.")
args = []string{"pantheon.py", "push", "--directory", directory}
}
//Now call python
Expand Down
4 changes: 2 additions & 2 deletions tools/git2pantheon/git_uploader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func TestPush2PantheonWithYML(t *testing.T) {
if strings.Contains(output, "pantheon2.yml was not found in the root of the repo, skipping upload.") {
t.Errorf("No pantheon2.yml was found, and no upload attempted.")
}
if !strings.Contains(output, "Credentials not found") {
t.Errorf("ENV UPLOADER_PASSWORD and UPLOADER_USER should always be not set during build.")
if !strings.Contains(output, "Environment variables not found") {
t.Errorf("ENV PANTHEON_SERVER, UPLOADER_PASSWORD and UPLOADER_USER should always be not set during build.")
}
cleanup(uploader)
cleanup(yml)
Expand Down
6 changes: 2 additions & 4 deletions uploader/pantheon.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import yaml

DEFAULT_SERVER = 'http://localhost:8080'
# This check needs to be removed when we start forcing a REPOSITORY name.
if 'PANTHEON_SERVER' in os.environ:
DEFAULT_REPOSITORY = 'gitImport'
else:
Expand Down Expand Up @@ -308,10 +309,7 @@ def processRegexMatches(files, globs, filetype):
files.remove(f)


if 'PANTHEON_SERVER' in os.environ:
server = os.environ['PANTHEON_SERVER']
else:
server = resolveOption(args.server, 'server', DEFAULT_SERVER)
server = resolveOption(args.server, 'server', DEFAULT_SERVER)

repository = resolveOption(args.repository, 'repository', DEFAULT_REPOSITORY)
mode = 'sandbox' if args.sandbox else 'repository'
Expand Down

0 comments on commit 7772251

Please sign in to comment.