Skip to content

Commit

Permalink
pass options to the server for validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 committed Sep 22, 2016
1 parent 5a69887 commit e79d1e1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions client/snap_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ func (client *Client) Install(name string, options *SnapOptions) (changeID strin
return client.doSnapAction("install", name, options)
}

func (client *Client) InstallMany(names []string) (changeID string, err error) {
return client.doMultiSnapAction("install", names, nil)
func (client *Client) InstallMany(names []string, options *SnapOptions) (changeID string, err error) {
return client.doMultiSnapAction("install", names, options)
}

// Remove removes the snap with the given name.
func (client *Client) Remove(name string, options *SnapOptions) (changeID string, err error) {
return client.doSnapAction("remove", name, options)
}

func (client *Client) RemoveMany(names []string) (changeID string, err error) {
return client.doMultiSnapAction("remove", names, nil)
func (client *Client) RemoveMany(names []string, options *SnapOptions) (changeID string, err error) {
return client.doMultiSnapAction("remove", names, options)
}

// Refresh refreshes the snap with the given name (switching it to track
Expand Down
36 changes: 18 additions & 18 deletions cmd/snap/cmd_snap_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,11 @@ type cmdRemove struct {
} `positional-args:"yes" required:"yes"`
}

func (x *cmdRemove) removeOne() error {
func (x *cmdRemove) removeOne(opts *client.SnapOptions) error {
name := x.Positional.Snaps[0]

cli := Client()
changeID, err := cli.Remove(name, &client.SnapOptions{
Revision: x.Revision},
)
changeID, err := cli.Remove(name, opts)
if err != nil {
return err
}
Expand All @@ -184,11 +182,11 @@ func (x *cmdRemove) removeOne() error {
return nil
}

func (x *cmdRemove) removeMany() error {
func (x *cmdRemove) removeMany(opts *client.SnapOptions) error {
names := x.Positional.Snaps

cli := Client()
changeID, err := cli.RemoveMany(names)
changeID, err := cli.RemoveMany(names, opts)
if err != nil {
return err
}
Expand All @@ -212,11 +210,12 @@ func (x *cmdRemove) removeMany() error {
}

func (x *cmdRemove) Execute([]string) error {
opts := &client.SnapOptions{Revision: x.Revision}
if len(x.Positional.Snaps) == 1 {
return x.removeOne()
return x.removeOne(opts)
}

return x.removeMany()
return x.removeMany(opts)
}

type channelMixin struct {
Expand Down Expand Up @@ -381,7 +380,7 @@ func (x *cmdInstall) installOne(name string, opts *client.SnapOptions) error {
return showDone([]string{name}, "install")
}

func (x *cmdInstall) installMany(names []string) error {
func (x *cmdInstall) installMany(names []string, opts *client.SnapOptions) error {
// sanity check
for _, name := range names {
if strings.Contains(name, "/") || strings.HasSuffix(name, ".snap") || strings.Contains(name, ".snap.") {
Expand All @@ -390,7 +389,7 @@ func (x *cmdInstall) installMany(names []string) error {
}

cli := Client()
changeID, err := cli.InstallMany(names)
changeID, err := cli.InstallMany(names, opts)
if err != nil {
return err
}
Expand Down Expand Up @@ -421,18 +420,19 @@ func (x *cmdInstall) Execute([]string) error {
}

dangerous := x.Dangerous || x.ForceDangerous
opts := &client.SnapOptions{
Channel: x.Channel,
DevMode: x.DevMode,
JailMode: x.JailMode,
Revision: x.Revision,
Dangerous: dangerous,
}

if len(x.Positional.Snaps) == 1 {
opts := &client.SnapOptions{
Channel: x.Channel,
DevMode: x.DevMode,
JailMode: x.JailMode,
Revision: x.Revision,
Dangerous: dangerous,
}
return x.installOne(x.Positional.Snaps[0], opts)
}

return x.installMany(x.Positional.Snaps)
return x.installMany(x.Positional.Snaps, opts)
}

type cmdRefresh struct {
Expand Down

0 comments on commit e79d1e1

Please sign in to comment.