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

LXD backend discovery support #76

Merged
merged 1 commit into from
Jun 7, 2017
Merged
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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Illarion Kovalchuk <illarion.kovalchuk@gmail.com>
Ievgen Ponomarenko <kikomdev@gmail.com>
Nick Doikov <Nick.Doikov@gmail.com>
Seua Polyakov <ctrlok@gmail.com>
Joe Topjian <joe@topjian.net>
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ deps: clean-deps
github.com/gin-gonic/gin \
github.com/hashicorp/consul/api \
github.com/spf13/cobra \
github.com/gin-contrib/cors \
github.com/Microsoft/go-winio \
golang.org/x/sys/windows \
github.com/inconshreveable/mousetrap
github.com/inconshreveable/mousetrap \
github.com/gin-contrib/cors \
github.com/lxc/lxd \
github.com/jtopjian/lxdhelpers

clean-dist:
rm -rf ./dist/${VERSION}
Expand All @@ -78,7 +80,7 @@ clean-dist:
dist:
@# For linux 386 when building on linux amd64 you'll need 'libc6-dev-i386' package
@echo Building dist

@# os arch cgo ext
@for arch in "linux 386 1 " "linux amd64 1 " \
"windows 386 0 .exe " "windows amd64 0 .exe " \
Expand All @@ -98,11 +100,11 @@ dist:
fi \
done

build-container-latest: build
build-container-latest: build
@echo Building docker container LATEST
docker build -t yyyar/gobetween .

build-container-tagged: build
build-container-tagged: build
@echo Building docker container ${VERSION}
docker build -t yyyar/gobetween:${VERSION} .

22 changes: 21 additions & 1 deletion config/gobetween.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ bind = "localhost:3000"
"localhost:8001"
]


# ---------- udp example ----------- #

[servers.udpsample]
Expand Down Expand Up @@ -236,3 +235,24 @@ protocol = "udp"
# consul_tls_key_path = "/path/to/key.pem"
# consul_tls_cacert_path = "/path/to/cacert.pem"
#
# # -- lxd -- #
# kind = "lxd"
# lxd_server_address = "unix:///var/lib/lxd/unix.socket" # (required) Address of the LXD server. Either unix://<path> or https://<addr>:port
# lxd_server_remote_name = "" # (optional) Name of the LXD server
# lxd_server_remote_password = "" # (optional) Password to the remote LXD server. Only used when address scheme is https
#
# lxd_config_directory = "~/.config/lxd" # (optional) Directory where LXD server info and certificates are stored
# lxd_generate_client_certs = false # (optional) Generate client SSL certificates for gobetween if not previously generated. Only used when scheme is https
# lxd_accept_server_cert = false # (optional) Accept the LXD server certificate. Only used when scheme is https
#
# lxd_container_label_key = "user.label" # (optional) Filter containers that have specified setting
# lxd_container_label_value = "foo" # (optional) Filter continers that have specified value of 'lxd_container_label_key' setting
#
# lxd_container_port = 0 # (required) Port of container to use
# lxd_container_port_key = "user.gobetween.port" # (optional) Container setting key that specifies the port.
#
# lxd_container_interface = "eth0" # (optional) Interface of container to use
# lxd_container_interface_key = "user.gobetween.interface" # (optional) Container setting that specifies the interface.
#
# lxd_container_sni_key = "" # (optional) Container setting that specifies the sni name of the container.
# lxd_container_address_type = "IPv4" # (optional) Container setting that specifies whether to use an IPv4 or IPv6 address. Valid options are IPv4 or IPv6.
25 changes: 24 additions & 1 deletion src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type ApiConfig struct {
Bind string `toml:"bind" json:"bind"`
BasicAuth *ApiBasicAuthConfig `toml:"basic_auth" json:"basic_auth"`
Tls *ApiTlsConfig `toml:"tls" json:"tls"`
Cors bool `toml:"cors" json:"cors"`
Cors bool `toml:"cors" json:"cors"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is changed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My vim config automatically runs gofmt upon save. It must have done some tabs/space fix.

}

/**
Expand Down Expand Up @@ -170,6 +170,7 @@ type DiscoveryConfig struct {
*ExecDiscoveryConfig
*PlaintextDiscoveryConfig
*ConsulDiscoveryConfig
*LXDDiscoveryConfig
}

type StaticDiscoveryConfig struct {
Expand Down Expand Up @@ -228,6 +229,28 @@ type ConsulDiscoveryConfig struct {
ConsulTlsCacertPath string `toml:"consul_tls_cacert_path" json:"consul_tls_cacert_path"`
}

type LXDDiscoveryConfig struct {
LXDServerAddress string `toml:"lxd_server_address" json:"lxd_server_address"`
LXDServerRemoteName string `toml:"lxd_server_remote_name" json:"lxd_server_remote_name"`
LXDServerRemotePassword string `toml:"lxd_server_remote_password" json:"lxd_server_remote_password"`

LXDConfigDirectory string `toml:"lxd_config_directory" json:"lxd_config_directory"`
LXDGenerateClientCerts bool `toml:"lxd_generate_client_certs" json:"lxd_generate_client_certs"`
LXDAcceptServerCert bool `toml:"lxd_accept_server_cert" json:"lxd_accept_server_cert"`

LXDContainerLabelKey string `toml:"lxd_container_label_key" json:"lxd_container_label_key"`
LXDContainerLabelValue string `toml:"lxd_container_label_value" json:"lxd_container_label_value"`

LXDContainerPort int `toml:"lxd_container_port" json:"lxd_container_port"`
LXDContainerPortKey string `toml:"lxd_container_port_key" json:"lxd_container_port_key"`

LXDContainerInterface string `toml:"lxd_container_interface" json:"lxd_container_interface"`
LXDContainerInterfaceKey string `toml:"lxd_container_interface_key" json:"lxd_container_interface_key"`

LXDContainerSNIKey string `toml:"lxd_container_sni_key" json:"lxd_container_sni_key"`
LXDContainerAddressType string `toml:"lxd_container_address_type" json:"lxd_container_address_type"`
}

/**
* Healthcheck configuration
*/
Expand Down
1 change: 1 addition & 0 deletions src/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func init() {
registry["exec"] = NewExecDiscovery
registry["plaintext"] = NewPlaintextDiscovery
registry["consul"] = NewConsulDiscovery
registry["lxd"] = NewLXDDiscovery
}

/**
Expand Down
Loading