-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add registry to amp with HAProxy reverse proxy (#155)
* add registry * update haproxy * update image list * update registry volume * add amp command: push * add persistence to registry * minor format update
- Loading branch information
1 parent
041cbf2
commit bc774a2
Showing
2 changed files
with
74 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
|
||
"github.com/appcelerator/amp/api/client" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var pushCmd = &cobra.Command{ | ||
Use: "push", | ||
Short: "push an image in the amp registry", | ||
Long: `push an image to the amp registry`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := RegistryPush(AMP, cmd, args) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(pushCmd) | ||
} | ||
|
||
// RegistryPush displays resource usage statistcs | ||
func RegistryPush(amp *client.AMP, cmd *cobra.Command, args []string) error { | ||
_, err := amp.GetAuthorizedContext() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
image := args[0] | ||
|
||
if amp.Verbose() { | ||
fmt.Println("Execute registry push command with:") | ||
fmt.Printf("image: %s\n", image) | ||
} | ||
|
||
if err = validateRegistryImage(image); err != nil { | ||
return err | ||
} | ||
cmdexe := exec.Command("docker", "push", image) | ||
cmdexe.Stdout = os.Stdout | ||
cmdexe.Stderr = os.Stderr | ||
err = cmdexe.Run() | ||
if err != nil { | ||
return err | ||
} | ||
return err | ||
} | ||
|
||
func validateRegistryImage(image string) error { | ||
if image == "" { | ||
return errors.New("need a valid image name") | ||
} | ||
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