Skip to content

Commit

Permalink
Ensure consistency and implement new orb publish release command
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Scott committed Aug 6, 2018
1 parent 22dedbe commit ccaf60b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
3 changes: 2 additions & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ func OrbQuery(ctx context.Context, logger *logger.Logger, configPath string) (*C

// OrbPublish publishes a new version of an orb
func OrbPublish(ctx context.Context, logger *logger.Logger,
name string, configPath string, orbVersion string) (*PublishOrbResponse, error) {
configPath string, namespace string, orb string, orbVersion string) (*PublishOrbResponse, error) {
name := namespace + "/" + orb
orbID, err := getOrbID(ctx, logger, name)
if err != nil {
return nil, err
Expand Down
27 changes: 12 additions & 15 deletions cmd/orb.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
"gopkg.in/yaml.v2"
)

var orbVersion string

func newOrbCommand() *cobra.Command {

listCommand := &cobra.Command{
Expand All @@ -41,16 +39,16 @@ func newOrbCommand() *cobra.Command {
}

publishCommand := &cobra.Command{
Use: "publish <namespace>/<orb> <orb.yml>",
Use: "publish",
Short: "publish a version of an orb",
RunE: publishOrb,
Args: cobra.ExactArgs(2),
}

publishCommand.Flags().StringVarP(&orbVersion, "orb-version", "o", "", "version of orb to publish (required)")
if err := publishCommand.MarkFlagRequired("orb-version"); err != nil {
panic(err)
}
publishCommand.AddCommand(&cobra.Command{
Use: "release PATH NAMESPACE ORB SEMVER",
Short: "release a semantic version of an orb",
RunE: releaseOrb,
Args: cobra.ExactArgs(4),
})

sourceCommand := &cobra.Command{
Use: "source <namespace>/<name>",
Expand Down Expand Up @@ -229,7 +227,7 @@ func validateOrb(cmd *cobra.Command, args []string) error {
return response.ToError()
}

Logger.Infof("Orb at %s is valid", orbPath)
Logger.Infof("Orb at %s is valid", args[0])
return nil
}

Expand All @@ -249,9 +247,9 @@ func expandOrb(cmd *cobra.Command, args []string) error {
return nil
}

func publishOrb(cmd *cobra.Command, args []string) error {
func releaseOrb(cmd *cobra.Command, args []string) error {
ctx := context.Background()
response, err := api.OrbPublish(ctx, Logger, args[0], args[1], orbVersion)
response, err := api.OrbPublish(ctx, Logger, args[0], args[1], args[2], args[3])

if err != nil {
return err
Expand Down Expand Up @@ -290,10 +288,9 @@ func createOrb(cmd *cobra.Command, args []string) error {
}

func showSource(cmd *cobra.Command, args []string) error {
orb := args[0]
source, err := api.OrbSource(context.Background(), Logger, orb)
source, err := api.OrbSource(context.Background(), Logger, args[0])
if err != nil {
return errors.Wrapf(err, "Failed to get source for '%s'", orb)
return errors.Wrapf(err, "Failed to get source for '%s'", args[0])
}
Logger.Info(source)
return nil
Expand Down
20 changes: 10 additions & 10 deletions cmd/orb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ var _ = Describe("Orb integration tests", func() {
Describe("when using default path", func() {
BeforeEach(func() {
var err error
orb, err = openTmpFile(command.Dir, "orb.yml")
Expect(err).ToNot(HaveOccurred())

token = "testtoken"
command = exec.Command(pathCLI,
"orb", "validate",
"orb", "validate", orb.Path,
"-t", token,
"-e", testServer.URL(),
)

orb, err = openTmpFile(command.Dir, "orb.yml")
Expect(err).ToNot(HaveOccurred())
})

AfterEach(func() {
Expand Down Expand Up @@ -165,10 +165,9 @@ var _ = Describe("Orb integration tests", func() {
Describe("when validating orb", func() {
BeforeEach(func() {
command = exec.Command(pathCLI,
"orb", "validate",
"orb", "validate", orb.Path,
"-t", token,
"-e", testServer.URL(),
orb.Path,
)
})

Expand Down Expand Up @@ -326,15 +325,16 @@ var _ = Describe("Orb integration tests", func() {
})
})

Describe("when publishing an orb version", func() {
Describe("when releasing an semantic version", func() {
BeforeEach(func() {
command = exec.Command(pathCLI,
"orb", "publish",
"orb", "publish", "release",
"-t", token,
"-e", testServer.URL(),
"my/orb",
orb.Path,
"--orb-version", "0.0.1",
"my",
"orb",
"0.0.1",
)
})

Expand Down

0 comments on commit ccaf60b

Please sign in to comment.