Skip host and deploy keys in another level
This commit is contained in:
parent
16bb4e71d5
commit
5b0a46951b
@ -238,14 +238,6 @@ func (c *Container) SetPassword(password string) error {
|
|||||||
// Returns true if the key was generated in this call and error if there is any.
|
// Returns true if the key was generated in this call and error if there is any.
|
||||||
// The container has to run for this to work.
|
// The container has to run for this to work.
|
||||||
func (c *Container) GenerateDeploySSHKeys() (bool, error) {
|
func (c *Container) GenerateDeploySSHKeys() (bool, error) {
|
||||||
status, err := c.Status()
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
if status.Status != "running" {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
driver := c.getDriver()
|
driver := c.getDriver()
|
||||||
|
|
||||||
privateKey, pubKey, _ := c.GetDeploySSHKeys()
|
privateKey, pubKey, _ := c.GetDeploySSHKeys()
|
||||||
@ -253,7 +245,7 @@ func (c *Container) GenerateDeploySSHKeys() (bool, error) {
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = driver.Exec(c.App.Name, []string{"mkdir", "-p", "/srv/.ssh"}, "", []string{}, true)
|
_, err := driver.Exec(c.App.Name, []string{"mkdir", "-p", "/srv/.ssh"}, "", []string{}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@ -275,14 +267,6 @@ func (c *Container) GenerateDeploySSHKeys() (bool, error) {
|
|||||||
// Return private key, public key and error.
|
// Return private key, public key and error.
|
||||||
// The container has to run for this to work.
|
// The container has to run for this to work.
|
||||||
func (c *Container) GetDeploySSHKeys() (string, string, error) {
|
func (c *Container) GetDeploySSHKeys() (string, string, error) {
|
||||||
status, err := c.Status()
|
|
||||||
if err != nil {
|
|
||||||
return "", "", err
|
|
||||||
}
|
|
||||||
if status.Status != "running" {
|
|
||||||
return "", "", nil
|
|
||||||
}
|
|
||||||
|
|
||||||
driver := c.getDriver()
|
driver := c.getDriver()
|
||||||
|
|
||||||
privateKey, err := driver.Exec(c.App.Name, []string{"cat", "/srv/.ssh/" + deployKeyPrefix + "_id_" + deployKeyType}, "", []string{}, true)
|
privateKey, err := driver.Exec(c.App.Name, []string{"cat", "/srv/.ssh/" + deployKeyPrefix + "_id_" + deployKeyType}, "", []string{}, true)
|
||||||
@ -304,14 +288,6 @@ func (c *Container) GetDeploySSHKeys() (string, string, error) {
|
|||||||
// Return host key without hostname
|
// Return host key without hostname
|
||||||
// The container has to run for this to work.
|
// The container has to run for this to work.
|
||||||
func (c *Container) GetHostKey() (string, error) {
|
func (c *Container) GetHostKey() (string, error) {
|
||||||
status, err := c.Status()
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
if status.Status != "running" {
|
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
|
|
||||||
driver := c.getDriver()
|
driver := c.getDriver()
|
||||||
|
|
||||||
hostKeyRaw, err := driver.Exec(c.App.Name, []string{"ssh-keyscan", "localhost"}, "", []string{}, true)
|
hostKeyRaw, err := driver.Exec(c.App.Name, []string{"ssh-keyscan", "localhost"}, "", []string{}, true)
|
||||||
|
16
glue/main.go
16
glue/main.go
@ -489,15 +489,19 @@ func (p *Processor) SetPassword(password string) error {
|
|||||||
// Returns private key, pubkey and error.
|
// Returns private key, pubkey and error.
|
||||||
// Keys are returned every time even if it was already generated
|
// Keys are returned every time even if it was already generated
|
||||||
func (p *Processor) GenerateDeploySSHKeys() (string, string, error) {
|
func (p *Processor) GenerateDeploySSHKeys() (string, string, error) {
|
||||||
err := p.waitForApp()
|
container, err := p.getContainer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
container, err := p.getContainer()
|
// If the container is not running we skip this code
|
||||||
|
status, err := container.Status()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
if status.Status != "running" {
|
||||||
|
return "", "", nil
|
||||||
|
}
|
||||||
|
|
||||||
created, err := container.GenerateDeploySSHKeys()
|
created, err := container.GenerateDeploySSHKeys()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -521,15 +525,19 @@ func (p *Processor) GenerateDeploySSHKeys() (string, string, error) {
|
|||||||
|
|
||||||
// Return SSH host key without hostname (first part of the line)
|
// Return SSH host key without hostname (first part of the line)
|
||||||
func (p *Processor) GetHostKey() (string, error) {
|
func (p *Processor) GetHostKey() (string, error) {
|
||||||
err := p.waitForApp()
|
container, err := p.getContainer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
container, err := p.getContainer()
|
// If the container is not running we skip this code
|
||||||
|
status, err := container.Status()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
if status.Status != "running" {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
hostKey, err := container.GetHostKey()
|
hostKey, err := container.GetHostKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user