Skip to content

Commit

Permalink
Add all well known actions
Browse files Browse the repository at this point in the history
Rename Status action to io.cnab.status
Remove Downgrade action

Signed-off-by: Guillaume Lours <[email protected]>
  • Loading branch information
glours committed Oct 28, 2019
1 parent ae93036 commit a71d74c
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 125 deletions.
2 changes: 0 additions & 2 deletions action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ const stateful = false
// - install
// - upgrade
// - uninstall
// - downgrade
// - status
type Action interface {
// Run an action, and record the status in the given claim
Run(*claim.Claim, credentials.Set, ...OperationConfigFunc) error
Expand Down
34 changes: 0 additions & 34 deletions action/status.go

This file was deleted.

85 changes: 0 additions & 85 deletions action/status_test.go

This file was deleted.

66 changes: 66 additions & 0 deletions action/well_known.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package action

import (
"github.com/deislabs/cnab-go/claim"
"github.com/deislabs/cnab-go/credentials"
"github.com/deislabs/cnab-go/driver"
)

// Well known constants define the Well Know CNAB action to be taken
const (
ActionDryRun = "io.cnab.dry-run"
ActionHelp = "io.cnab.help"
ActionLog = "io.cnab.log"
ActionStatus = "io.cnab.status"
ActionStatusJSON = "io.cnab.status+json"
)

// DryRun runs a dry-run action on a CNAB bundle.
type DryRun struct {
Driver driver.Driver
}

// Help runs a help action on a CNAB bundle.
type Help struct {
Driver driver.Driver
}

// Log runs a log action on a CNAB bundle.
type Log struct {
Driver driver.Driver
}

// Status runs a status action on a CNAB bundle.
type Status struct {
Driver driver.Driver
}

// StatusJSON runs a status+JSON action on a CNAB bundle.
type StatusJSON struct {
Driver driver.Driver
}

// Run executes a dry-run action in an image
func (i *DryRun) Run(c *claim.Claim, creds credentials.Set, opCfgs ...OperationConfigFunc) error {
return (&RunCustom{Driver: i.Driver, Action: ActionDryRun}).Run(c, creds, opCfgs...)
}

// Run executes a help action in an image
func (i *Help) Run(c *claim.Claim, creds credentials.Set, opCfgs ...OperationConfigFunc) error {
return (&RunCustom{Driver: i.Driver, Action: ActionHelp}).Run(c, creds, opCfgs...)
}

// Run executes a status action in an image
func (i *Log) Run(c *claim.Claim, creds credentials.Set, opCfgs ...OperationConfigFunc) error {
return (&RunCustom{Driver: i.Driver, Action: ActionLog}).Run(c, creds, opCfgs...)
}

// Run executes a status action in an image
func (i *Status) Run(c *claim.Claim, creds credentials.Set, opCfgs ...OperationConfigFunc) error {
return (&RunCustom{Driver: i.Driver, Action: ActionStatus}).Run(c, creds, opCfgs...)
}

// Run executes a status+JSON action in an image
func (i *StatusJSON) Run(c *claim.Claim, creds credentials.Set, opCfgs ...OperationConfigFunc) error {
return (&RunCustom{Driver: i.Driver, Action: ActionStatusJSON}).Run(c, creds, opCfgs...)
}
8 changes: 8 additions & 0 deletions action/well_known_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package action

// makes sure DryRun, Help, Log, Status, StatusJSON implements Action interface
var _ Action = &DryRun{}
var _ Action = &Help{}
var _ Action = &Log{}
var _ Action = &Status{}
var _ Action = &StatusJSON{}
6 changes: 2 additions & 4 deletions claim/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ const (
const (
ActionInstall = "install"
ActionUpgrade = "upgrade"
ActionDowngrade = "downgrade"
ActionUninstall = "uninstall"
ActionStatus = "status"
ActionUnknown = "unknown"
)

// Claim is an installation claim receipt.
//
// Claims reprsent information about a particular installation, and
// provide the necessary data to upgrade, uninstall, and downgrade
// Claims represent information about a particular installation, and
// provide the necessary data to upgrade and uninstall
// a CNAB package.
type Claim struct {
Name string `json:"name"`
Expand Down

0 comments on commit a71d74c

Please sign in to comment.