Move the struct for creating and aci context to azure package

This commit is contained in:
Djordje Lukic 2020-07-13 10:38:29 +02:00
parent 43b54ef75a
commit 84dbd1467d
5 changed files with 26 additions and 31 deletions

View file

@ -22,21 +22,14 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/docker/api/azure"
"github.com/docker/api/client"
"github.com/docker/api/context/store"
"github.com/docker/api/errdefs"
)
// AciCreateOpts options for creating ACI context
type AciCreateOpts struct {
Description string
Location string
SubscriptionID string
ResourceGroup string
}
func createAciCommand() *cobra.Command {
var opts AciCreateOpts
var opts azure.ContextParams
cmd := &cobra.Command{
Use: "aci CONTEXT [flags]",
Short: "Create a context for Azure Container Instances",
@ -54,7 +47,7 @@ func createAciCommand() *cobra.Command {
return cmd
}
func runCreateAci(ctx context.Context, contextName string, opts AciCreateOpts) error {
func runCreateAci(ctx context.Context, contextName string, opts azure.ContextParams) error {
if contextExists(ctx, contextName) {
return errors.Wrapf(errdefs.ErrAlreadyExists, "context %s", contextName)
}
@ -66,7 +59,7 @@ func runCreateAci(ctx context.Context, contextName string, opts AciCreateOpts) e
}
func getAciContextData(ctx context.Context, opts AciCreateOpts) (interface{}, string, error) {
func getAciContextData(ctx context.Context, opts azure.ContextParams) (interface{}, string, error) {
cs, err := client.GetCloudService(ctx, store.AciContextType)
if err != nil {
return nil, "", errors.Wrap(err, "cannot connect to ACI backend")