Exemple #1
0
        public DockerApps(DappConfig config)
        {
            Directory.CreateDirectory(config.AppsDir);

              _appsDir = config.AppsDir;
              _config = config;
        }
Exemple #2
0
 public Desktop(DappConfig config, string runnerPath)
 {
   Prefix = config.DesktopPrefix;
   _runnerPath = runnerPath;
 }
Exemple #3
0
        public static DappResult CreateDapp(DappConfig config)
        {
            var result = new DappResult();

            try
            {
                if (string.IsNullOrWhiteSpace(config.Name))
                {
                    throw new DappException("Dapp Name is required");
                }

                if (string.IsNullOrWhiteSpace(config.Description))
                {
                    throw new DappException("Dapp Description is required");
                }

                if (string.IsNullOrWhiteSpace(config.Secret))
                {
                    throw new DappException("Dapp Secret is required");
                }

                if (string.IsNullOrWhiteSpace(config.PublicKeys))
                {
                    throw new DappException("Dapp Public Keys is required");
                }
                if (string.IsNullOrWhiteSpace(config.SdkLink))
                {
                    throw new DappException("Sdk link is invalid");
                }

                if (config.IsGit)
                {
                    if (string.IsNullOrWhiteSpace(config.GitUsername) || string.IsNullOrWhiteSpace(config.GitPassword))
                    {
                        throw new DappException("IsGit checked, Git user credentials are required");
                    }
                    if (string.IsNullOrWhiteSpace(config.Git))
                    {
                        throw new DappException("Git link invalid");
                    }
                }

                var   genesisAccount = AccountHelper.GetAccount(config.Secret);
                Block block;
                if (config.NewGenesisBlock)
                {
                    block = BlockHelper.CreateNewBlock(genesisAccount, config.ToDapp());
                }
                else
                {
                    //block = BlockHelper.CreateFromBlock()
                }
            }
            catch (DappException ex)
            {
                result.Error = ex.Message;
            }
            catch (Exception ex)
            {
                result.Error = "An error occurred " + ex.Message;
            }

            return(result);
        }
Exemple #4
0
 public DockerService(DappConfig cfg, IDockerLogger logger)
 {
     _cfg = cfg;
       Logger = logger;
 }
Exemple #5
0
 public Docker(DappConfig config, IDockerLogger logger)
 {
   Logger = logger;
   _config = config;
 }
Exemple #6
0
    public void Run()
    {
      var dapCfg = new DappConfig("/tmp/config");
      dapCfg.Load();
      var logger = new DockerLogger(opts.Verbose);
      _dockerService = new DockerService(dapCfg, logger);
      try
      {
        if (parsed)
        {
          var apps = new DockerApps(dapCfg);

          // Generate template
          if (!string.IsNullOrEmpty(opts.GenerateApp))
          {
            apps.GenerateTemplate(opts.GenerateApp);
          }

          // Applications
          if (opts.List)
          {
            Console.WriteLine("Applications:");
            foreach (var p in apps.Apps)
            {
              Console.WriteLine("|>>" + p.Name);
            }
            Console.WriteLine("NMew");
            var appsEnumerable = PrepareApps(apps.Apps);
            TableFormatter.Format(Console.Error, appsEnumerable, "\t{0}\t({1})\n");
            return;
          }

          // Run
          if (!string.IsNullOrEmpty(opts.App))
          {
            RunApp(apps, opts.App, opts.RunOpts);
            return;
          }

          // Details
          if (!string.IsNullOrEmpty(opts.Details))
          {
            ShowApp(apps, opts.Details);
            return;
          }

          // Desktop file
          if (!string.IsNullOrEmpty(opts.CreateDesktop))
          {
            var d = new Desktop.Desktop(dapCfg, _runnable);
            CreateDesktop(d, apps, opts.CreateDesktop);
            return;
          }

          Console.WriteLine(opts.GetUsage());
        }
        else
        {
          // Parse error
          Console.WriteLine(opts.GetUsage());
        }
      }
      catch (DockerException ex)
      {
        logger.Exit($"Exited with exit code ({ex.ExitCode}): docker {ex.Message}");
      }
    }