@@ -5,12 +5,14 @@ import (
55 "encoding/json"
66 "fmt"
77 "io"
8+ "maps"
89 "os"
910 "path/filepath"
1011
1112 "github.com/spf13/cobra"
1213 flag "github.com/spf13/pflag"
1314
15+ "github.com/oasisprotocol/oasis-core/go/common/sgx"
1416 "github.com/oasisprotocol/oasis-core/go/common/sgx/pcs"
1517 "github.com/oasisprotocol/oasis-core/go/common/sgx/quote"
1618 consensus "github.com/oasisprotocol/oasis-core/go/consensus/api"
@@ -455,6 +457,53 @@ var (
455457 },
456458 }
457459
460+ deployCmd = & cobra.Command {
461+ Use : "deploy" ,
462+ Short : "Deploy ROFL to a specified instance" ,
463+ Args : cobra .NoArgs ,
464+ Run : func (_ * cobra.Command , _ []string ) {
465+ cfg := cliConfig .Global ()
466+ npa := common .GetNPASelection (cfg )
467+
468+ manifest , deployment := roflCommon .LoadManifestAndSetNPA (cfg , npa , deploymentName , & roflCommon.ManifestOptions {
469+ NeedAppID : true ,
470+ NeedAdmin : true ,
471+ })
472+
473+ manifestEnclaves := make (map [sgx.EnclaveIdentity ]struct {})
474+ for _ , eid := range deployment .Policy .Enclaves {
475+ manifestEnclaves [eid ] = struct {}{}
476+ }
477+
478+ ctx := context .Background ()
479+ cfgEnclaves , err := roflCommon .GetRegisteredEnclaves (ctx , deployment .AppID , npa )
480+ cobra .CheckErr (err )
481+
482+ if ! maps .Equal (manifestEnclaves , cfgEnclaves ) {
483+ // TODO: Generate and run Update TX automatically.
484+ cobra .CheckErr ("Local enclave identities DIFFER from on-chain enclave identities! Run `oasis rofl update` first" )
485+ }
486+
487+ orcFilename := roflCommon .GetOrcFilename (manifest , deploymentName )
488+ cfgSnippet := " runtime:\n " +
489+ " paths:\n " +
490+ " - /node/rofls/" + orcFilename + "\n "
491+ fmt .Printf (
492+ "To deploy your ROFL app, you can decide between one of the two options:\n " +
493+ "\n A. RUN YOUR OWN OASIS NODE\n \n " +
494+ " 1. Follow https://docs.oasis.io/node/run-your-node/paratime-client-node\n " +
495+ " and configure your TDX Oasis node\n " +
496+ " 2. Copy '%s' to your node, for example:\n \n " +
497+ " scp %s mynode.com:/node/rofls\n \n " +
498+ " 3. Add the following snippet to your Oasis node config.yml:\n \n %s\n " +
499+ " 4. Restart your node\n " +
500+ "\n B. DEPLOY YOUR ROFL TO THE OASIS PROVIDER\n \n " +
501+ " 1. Upload '%s' to a publicly accessible file server\n " +
502+ " 2. Reach out to us at https://oasis.io/discord #dev-central channel and we\n " +
503+ " will run your ROFL app on our TDX Oasis nodes\n " , orcFilename , orcFilename , cfgSnippet , orcFilename )
504+ },
505+ }
506+
458507 upgradeCmd = & cobra.Command {
459508 Use : "upgrade" ,
460509 Short : "Upgrade all artifacts to their latest default versions" ,
@@ -676,6 +725,10 @@ func init() {
676725 updateCmd .Flags ().AddFlagSet (deploymentFlags )
677726 updateCmd .Flags ().AddFlagSet (updateFlags )
678727
728+ deployCmd .Flags ().AddFlagSet (common .SelectorFlags )
729+ deployCmd .Flags ().AddFlagSet (common .RuntimeTxFlags )
730+ deployCmd .Flags ().AddFlagSet (deploymentFlags )
731+
679732 removeCmd .Flags ().AddFlagSet (common .SelectorFlags )
680733 removeCmd .Flags ().AddFlagSet (common .RuntimeTxFlags )
681734 removeCmd .Flags ().AddFlagSet (deploymentFlags )
0 commit comments