Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to do non docker-machine ssh #162

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Ductus.FluentDocker/Builders/DockerContextAwareRemoteBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// TODO: https://www.docker.com/blog/how-to-deploy-on-remote-docker-hosts-with-docker-compose/

using Ductus.FluentDocker.Builders;
using Ductus.FluentDocker.Services;

namespace Ductus.FluentDocker.Builders
{

public class DockerContextAwareRemoteBuilder : BaseBuilder<IHostService>
{
private string _uri;
internal DockerContextAwareRemoteBuilder(IBuilder parent, string uri = null) : base(parent)
{
_uri = uri;
}

public override IHostService Build()
{
throw new System.NotImplementedException();
}

protected override IBuilder InternalCreate()
{
throw new System.NotImplementedException();
}
}
}
8 changes: 8 additions & 0 deletions Ductus.FluentDocker/Builders/DockerContextBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Ductus.FluentDocker.Builders
{
// TODO: Implement one for docker context - https://docs.docker.com/engine/reference/commandline/context/
public class DockerContextBuilder
{

}
}
126 changes: 67 additions & 59 deletions Ductus.FluentDocker/Builders/HostBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,84 @@

namespace Ductus.FluentDocker.Builders
{
public sealed class HostBuilder : BaseBuilder<IHostService>
{
internal HostBuilder(IBuilder builder) : base(builder)
public sealed class HostBuilder : BaseBuilder<IHostService>
{
}
internal HostBuilder(IBuilder builder) : base(builder)
{
}

public override IHostService Build()
{
return IsNative ? new Hosts().Native() : null;
}
public override IHostService Build()
{
return IsNative ? new Hosts().Native() : null;
}

protected override IBuilder InternalCreate()
{
return new HostBuilder(this);
}
protected override IBuilder InternalCreate()
{
return new HostBuilder(this);
}

public bool IsNative { get; private set; }
public bool IsNative { get; private set; }

public HostBuilder UseNative()
{
IsNative = true;
return this;
}
public HostBuilder UseNative()
{
IsNative = true;
return this;
}

public MachineBuilder UseMachine()
{
var existing = Childs.FirstOrDefault(x => x is MachineBuilder);
if (null != existing)
{
return (MachineBuilder)existing;
}
public MachineBuilder UseMachine()
{
var existing = Childs.FirstOrDefault(x => x is MachineBuilder);
if (null != existing)
{
return (MachineBuilder)existing;
}

var builder = new MachineBuilder(this);
Childs.Add(builder);
return builder;
}
var builder = new MachineBuilder(this);
Childs.Add(builder);
return builder;
}

public RemoteSshHostBuilder UseSsh(string ipAddress = null)
{
var builder = new RemoteSshHostBuilder(this, ipAddress);
Childs.Add(builder);
return builder;
}
public RemoteSshHostBuilder UseSsh(string ipAddress = null)
{
var builder = new RemoteSshHostBuilder(this, ipAddress);
Childs.Add(builder);
return builder;
}

public ImageBuilder DefineImage(string image = null)
{
var builder = new ImageBuilder(this).AsImageName(image);
Childs.Add(builder);
return builder;
}
// Same as <see cref="UseSsh" /> but uses docker context instead of docker-machine
public DockerContextAwareRemoteBuilder UseContextSsh(string uri = null)
{
var builder = new DockerContextAwareRemoteBuilder(this, uri);
Childs.Add(builder);
return builder;
}

public ContainerBuilder UseContainer()
{
var builder = new ContainerBuilder(this);
Childs.Add(builder);
return builder;
}
public ImageBuilder DefineImage(string image = null)
{
var builder = new ImageBuilder(this).AsImageName(image);
Childs.Add(builder);
return builder;
}

public NetworkBuilder UseNetwork(string name = null)
{
var builder = new NetworkBuilder(this, name);
Childs.Add(builder);
return builder;
}
public ContainerBuilder UseContainer()
{
var builder = new ContainerBuilder(this);
Childs.Add(builder);
return builder;
}

public VolumeBuilder UseVolume(string name = null)
{
var builder = new VolumeBuilder(this, name);
Childs.Add(builder);
return builder;
public NetworkBuilder UseNetwork(string name = null)
{
var builder = new NetworkBuilder(this, name);
Childs.Add(builder);
return builder;
}

public VolumeBuilder UseVolume(string name = null)
{
var builder = new VolumeBuilder(this, name);
Childs.Add(builder);
return builder;
}
}
}
}
Loading