Exemplo n.º 1
0
 public DockerConnection(DockerContainerTransportSettings settings, Connection outerConnection, string name)
     : base(outerConnection, name)
 {
     _settings               = settings;
     _containerName          = settings.ContainerName;
     _dockerExecutionManager = new DockerExecutionManager(settings, outerConnection);
 }
Exemplo n.º 2
0
 public DockerExecSettings(DockerContainerTransportSettings settings, string command, bool runInShell, bool makeInteractive = true)
     : base(settings)
 {
     Debug.Assert(!string.IsNullOrWhiteSpace(command), "Exec command cannot be null");
     _runInShell       = runInShell;
     _commandToExecute = command;
     _makeInteractive  = makeInteractive;
 }
Exemplo n.º 3
0
        internal static bool TryConvertConnectionStringToSettings(string connectionString, out DockerContainerTransportSettings settings, out Connection remoteConnection)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            remoteConnection = null;
            settings         = null;

            string containerName = string.Empty;
            string hostName      = string.Empty;
            bool   invalidString = false;

            // Assume format is <containername>;ssh=<sshconnection>;host=<dockerhostvalue> or some mixture
            string[] connectionStrings = connectionString.Split(Separator);

            if (connectionStrings.Length <= 3 && connectionStrings.Length > 0)
            {
                Regex SshRegex        = new Regex(SshPrefixRegex);
                Regex dockerHostRegex = new Regex(DockerHostPrefixRegex);

                foreach (var item in connectionStrings)
                {
                    string segment = item.Trim(' ');
                    if (SshRegex.IsMatch(segment))
                    {
                        Match match = SshRegex.Match(segment);
                        remoteConnection = ConnectionManager.GetSSHConnection(segment.Substring(match.Length));
                    }
                    else if (dockerHostRegex.IsMatch(segment))
                    {
                        Match match = dockerHostRegex.Match(segment);
                        hostName = segment.Substring(match.Length);
                    }
                    else if (segment.Contains("="))
                    {
                        invalidString = true;
                    }
                    else
                    {
                        if (!string.IsNullOrWhiteSpace(containerName))
                        {
                            Debug.Fail("containerName should be empty");
                            invalidString = true;
                        }
                        else
                        {
                            containerName = segment;
                        }
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(containerName) && !invalidString)
            {
                settings = new DockerContainerTransportSettings(hostName, containerName, remoteConnection != null);
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
 private ICommandRunner GetCommandRunner(DockerContainerTransportSettings settings, bool handleRawOutput = false)
 {
     if (OuterConnection == null)
     {
         return(LocalCommandRunner.CreateInstance(handleRawOutput, settings));
     }
     else
     {
         return(new RemoteCommandRunner(settings, OuterConnection, handleRawOutput));
     }
 }
Exemplo n.º 5
0
 public DockerCopySettings(DockerContainerTransportSettings settings, string sourcePath, string destinationPath)
     : base(settings)
 {
     _sourcePath      = sourcePath;
     _destinationPath = destinationPath;
 }
Exemplo n.º 6
0
 public DockerContainerTransportSettings(DockerContainerTransportSettings settings)
     : base(settings)
 {
     ContainerName = settings.ContainerName;
 }
Exemplo n.º 7
0
 public DockerExecutionManager(DockerContainerTransportSettings baseSettings, Connection outerConnection)
 {
     _baseSettings    = baseSettings;
     _outerConnection = outerConnection;
 }