mirror of
https://github.com/docker/compose.git
synced 2025-07-26 23:24:05 +02:00
Skeletton for "compose up" command
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
40bf8c2dae
commit
91daf0dcc0
@ -5,6 +5,7 @@ import (
|
|||||||
"github.com/docker/cli/cli-plugins/manager"
|
"github.com/docker/cli/cli-plugins/manager"
|
||||||
"github.com/docker/cli/cli-plugins/plugin"
|
"github.com/docker/cli/cli-plugins/plugin"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
|
"github.com/docker/ecs-plugin/pkg/amazon"
|
||||||
"github.com/docker/ecs-plugin/pkg/compose"
|
"github.com/docker/ecs-plugin/pkg/compose"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -24,6 +25,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type clusterOptions struct {
|
type clusterOptions struct {
|
||||||
|
profile string
|
||||||
region string
|
region string
|
||||||
cluster string
|
cluster string
|
||||||
}
|
}
|
||||||
@ -42,6 +44,7 @@ func NewRootCmd(name string, dockerCli command.Cli) *cobra.Command {
|
|||||||
VersionCommand(),
|
VersionCommand(),
|
||||||
ComposeCommand(&opts),
|
ComposeCommand(&opts),
|
||||||
)
|
)
|
||||||
|
cmd.Flags().StringVarP(&opts.profile, "profile", "p", "default", "AWS Profile")
|
||||||
cmd.Flags().StringVarP(&opts.cluster, "cluster", "c", "default", "ECS cluster")
|
cmd.Flags().StringVarP(&opts.cluster, "cluster", "c", "default", "ECS cluster")
|
||||||
cmd.Flags().StringVarP(&opts.region, "region", "r", "", "AWS region")
|
cmd.Flags().StringVarP(&opts.region, "region", "r", "", "AWS region")
|
||||||
|
|
||||||
@ -65,5 +68,23 @@ func ComposeCommand(clusteropts *clusterOptions) *cobra.Command {
|
|||||||
}
|
}
|
||||||
opts := &compose.ProjectOptions{}
|
opts := &compose.ProjectOptions{}
|
||||||
opts.AddFlags(cmd.Flags())
|
opts.AddFlags(cmd.Flags())
|
||||||
|
|
||||||
|
cmd.AddCommand(
|
||||||
|
UpCommand(clusteropts, opts),
|
||||||
|
)
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpCommand(clusteropts *clusterOptions, opts *compose.ProjectOptions) *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "up",
|
||||||
|
RunE: compose.WithProject(opts, func(project *compose.Project, args []string) error {
|
||||||
|
client, err := amazon.NewClient(clusteropts.profile, clusteropts.cluster, clusteropts.region)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return client.ComposeUp(project)
|
||||||
|
}),
|
||||||
|
}
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
@ -1,7 +1,37 @@
|
|||||||
package amazon
|
package amazon
|
||||||
|
|
||||||
import "github.com/aws/aws-sdk-go/aws/session"
|
import (
|
||||||
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
|
"github.com/docker/ecs-plugin/pkg/compose"
|
||||||
|
)
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
|
const (
|
||||||
|
ProjectTag = "com.docker.compose.project"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewClient(profile string, cluster string, region string) (compose.API, error) {
|
||||||
|
sess, err := session.NewSessionWithOptions(session.Options{
|
||||||
|
Profile: profile,
|
||||||
|
Config: aws.Config{
|
||||||
|
Region: aws.String(region),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &client{
|
||||||
|
Cluster: cluster,
|
||||||
|
Region: region,
|
||||||
|
sess: sess,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type client struct {
|
||||||
|
Cluster string
|
||||||
|
Region string
|
||||||
sess *session.Session
|
sess *session.Session
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ compose.API = &client{}
|
||||||
|
11
ecs/pkg/amazon/compose.go
Normal file
11
ecs/pkg/amazon/compose.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package amazon
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/docker/ecs-plugin/pkg/compose"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *client) ComposeUp(project *compose.Project) error {
|
||||||
|
fmt.Println("TODO Up")
|
||||||
|
return nil
|
||||||
|
}
|
5
ecs/pkg/compose/api.go
Normal file
5
ecs/pkg/compose/api.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package compose
|
||||||
|
|
||||||
|
type API interface {
|
||||||
|
ComposeUp(project *Project) error
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user