-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from leapfrogtechnology/save-config-to-json
save config data to shift.json on working dir
- Loading branch information
Showing
6 changed files
with
46 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/leapfrogtechnology/shift/cli/internal/deploy" | ||
) | ||
// "github.com/leapfrogtechnology/shift/cli/internal/deploy" | ||
|
||
// Deploy triggers deployment for provided project. | ||
func Deploy(project string, deployment string) { | ||
deploy.Run(project, deployment) | ||
// deploy.Run(project, deployment) | ||
} |
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
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 |
---|---|---|
@@ -1,37 +1,18 @@ | ||
package internals | ||
|
||
import ( | ||
"github.com/leapfrogtechnology/shift/core/services/mq" | ||
"errors" | ||
"github.com/leapfrogtechnology/shift/core/utils/logger" | ||
"github.com/leapfrogtechnology/shift/infrastructure/infrastructure" | ||
"github.com/streadway/amqp" | ||
"log" | ||
) | ||
|
||
func Initialize() { | ||
conn, err := amqp.Dial(mq.GenerateQueueUrl()) | ||
logger.FailOnError(err, "Failed to Connect to Message Queue") | ||
defer conn.Close() | ||
ch, err := conn.Channel() | ||
logger.FailOnError(err, "Failed to open a channel") | ||
defer ch.Close() | ||
messages := mq.Consume(ch, "Infrastructure") | ||
forever := make(chan bool) | ||
go func() { | ||
for message := range messages { | ||
log.Printf("Received a message: %s", message.MessageId) | ||
infrastructureInfo, err := infrastrucuture.Initialize(message.Body) | ||
if err != nil { | ||
logger.LogError(err, "Cannot Init Infrastructure") | ||
} else { | ||
logger.LogOutput(infrastructureInfo) | ||
err = mq.Publish([]byte(infrastructureInfo), ch, "Deployment") | ||
if err != nil { | ||
logger.LogError(err, "Cannot Publish Output") | ||
} | ||
} | ||
} | ||
}() | ||
logger.LogInfo("[*] Waiting for messages. To exit Press Ctrl+C") | ||
<-forever | ||
func Initialize(details string) (string, error) { | ||
infrastructureInfo, err := infrastrucuture.Initialize([]byte(details)) | ||
if err != nil { | ||
logger.LogError(err, "Cannot Init Infrastructure") | ||
return "", errors.New("issue Initializing the infrastructure") | ||
} else { | ||
logger.LogOutput(infrastructureInfo) | ||
return infrastructureInfo, 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 |
---|---|---|
@@ -1,7 +1,19 @@ | ||
package main | ||
package infrastructure | ||
|
||
import "github.com/leapfrogtechnology/shift/infrastructure/internals" | ||
import ( | ||
"errors" | ||
"github.com/leapfrogtechnology/shift/core/utils/logger" | ||
"github.com/leapfrogtechnology/shift/infrastructure/internals" | ||
"github.com/leapfrogtechnology/shift/infrastructure/utils" | ||
) | ||
|
||
func main() { | ||
internals.Initialize() | ||
func Initialize(details string) (string, error) { | ||
if !utils.CommandExists("terraform") { | ||
logger.FailOnError(errors.New("terraform does not exist"), "Please install terraform on your device") | ||
} | ||
infrastructureInfo, err := internals.Initialize(details) | ||
if err != nil { | ||
logger.FailOnError(err, "Failed to Init Infrastructure") | ||
} | ||
return infrastructureInfo, err | ||
} |
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,8 @@ | ||
package utils | ||
|
||
import "os/exec" | ||
|
||
func CommandExists(command string) bool { | ||
_, err := exec.LookPath(command) | ||
return err == nil | ||
} |