Skip to content

Commit

Permalink
Merge pull request #845 from mesg-foundation/feature/marketplace-publ…
Browse files Browse the repository at this point in the history
…ish-service-raw-data

Marketplace publish service raw data
  • Loading branch information
NicolasMahe authored Apr 9, 2019
2 parents b8acb72 + 046f8d4 commit 7905bc2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
25 changes: 12 additions & 13 deletions commands/marketplace_publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/mesg-foundation/core/commands/provider"
"github.com/mesg-foundation/core/service/importer"
"github.com/mesg-foundation/core/protobuf/coreapi"
"github.com/mesg-foundation/core/utils/pretty"
"github.com/mesg-foundation/core/utils/readme"
"github.com/spf13/cobra"
Expand All @@ -19,9 +19,8 @@ const (
type marketplacePublishCmd struct {
baseMarketplaceCmd

path string
sid string
hash string
path string
service *coreapi.Service

e Executor
}
Expand All @@ -48,15 +47,19 @@ func (c *marketplacePublishCmd) preRunE(cmd *cobra.Command, args []string) error
c.path = getFirstOrCurrentPath(args)

var err error
c.sid, c.hash, err = deployService(c.e, c.path, map[string]string{})
_, hash, err := deployService(c.e, c.path, map[string]string{})
if err != nil {
return err
}
fmt.Printf("%s Service deployed with sid %s and hash %s\n", pretty.SuccessSign, pretty.Success(c.sid), pretty.Success(c.hash))
c.service, err = c.e.ServiceByID(hash)
if err != nil {
return err
}
fmt.Printf("%s Service deployed with sid %s and hash %s\n", pretty.SuccessSign, pretty.Success(c.service.Definition.Sid), pretty.Success(c.service.Definition.Hash))

var confirmed bool
if err := survey.AskOne(&survey.Confirm{
Message: fmt.Sprintf("Are you sure to publish a new version of service %q from path %q using account %q?", c.sid, c.path, c.account),
Message: fmt.Sprintf("Are you sure to publish a new version of service %q from path %q using account %q?", c.service.Definition.Sid, c.path, c.account),
}, &confirmed, nil); err != nil {
return err
}
Expand All @@ -83,18 +86,14 @@ func (c *marketplacePublishCmd) runE(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
definition, err := importer.From(c.path)
if err != nil {
return err
}
readme, err := readme.Lookup(c.path)
if err != nil {
return err
}
pretty.Progress("Publishing service on the marketplace...", func() {
if tx, err = c.e.PreparePublishServiceVersion(provider.MarketplaceManifestServiceData{
Definition: *definition,
Hash: c.hash,
Definition: c.service.Definition,
Hash: c.service.Definition.Hash,
HashVersion: marketplaceServiceHashVersion,
Readme: readme,
Deployment: deployment,
Expand Down
12 changes: 6 additions & 6 deletions commands/provider/marketplace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"time"

"github.com/mesg-foundation/core/service/importer"
"github.com/mesg-foundation/core/protobuf/definition"
)

const (
Expand Down Expand Up @@ -55,11 +55,11 @@ type MarketplaceDeployedSource struct {

// MarketplaceManifestServiceData is the data present to the manifest and sent to create a new service's version
type MarketplaceManifestServiceData struct {
Definition importer.ServiceDefinition `json:"definition"`
Readme string `json:"readme,omitempty"`
Hash string `json:"hash"`
HashVersion string `json:"hashVersion"`
Deployment MarketplaceDeployedSource `json:"deployment"`
Definition *definition.Service `json:"definition"`
Readme string `json:"readme,omitempty"`
Hash string `json:"hash"`
HashVersion string `json:"hashVersion"`
Deployment MarketplaceDeployedSource `json:"deployment"`
}

// MarketplaceManifestData struct {
Expand Down

0 comments on commit 7905bc2

Please sign in to comment.