Enable remote host connections on tsh

next
Sayan Nandan 4 years ago
parent 583932bdde
commit 44e0affc82
No known key found for this signature in database
GPG Key ID: C31EFD7DDA12AEE0

@ -1,72 +1,21 @@
name: Build latest docker image
name: Build docker image
on:
push:
# Publish `next` as Docker `latest` image.
branches:
- next
# Publish `v1.2.3` tags as releases.
tags:
- v*
env:
IMAGE_NAME: tdb
jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
run: |
if [ -f docker-compose.test.yml ]; then
docker-compose --file docker-compose.test.yml build
docker-compose --file docker-compose.test.yml run sut
else
docker build . --file Dockerfile
fi
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
# Ensure test job passes before pushing image.
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "next" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Checkout code
uses: actions/checkout@v2
- name: Build and push Docker images
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: terrabasedb/tdb
tags: latest

@ -22,6 +22,6 @@ RUN \
CMD ["tdb"]
EXPOSE 2003
EXPOSE 2003/tcp
ARG DEBIAN_FRONTEND=noninteractive

@ -20,10 +20,24 @@
*/
use crate::protocol;
use corelib::terrapipe::ADDR;
use std::env;
use std::io::{self, prelude::*};
use std::process;
pub async fn execute_query() {
let mut con = match protocol::Connection::new().await {
let args: Vec<String> = env::args().skip(1).collect();
if args.len() > 1 {
eprintln!("Incorrect number of arguments\n\tUSAGE tsh [host]");
}
let host = match args.get(0) {
Some(h) => {
let mut addr = h.clone();
addr.push_str(":2003");
addr
}
None => ADDR.to_owned(),
};
let mut con = match protocol::Connection::new(&host).await {
Ok(c) => c,
Err(e) => {
eprintln!("ERROR: {}", e);

@ -23,7 +23,6 @@ mod deserializer;
use bytes::{Buf, BytesMut};
use corelib::builders::query::*;
use corelib::de::*;
use corelib::terrapipe::*;
use corelib::TResult;
use deserializer::{ClientResult, Response};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
@ -34,8 +33,8 @@ pub struct Connection {
}
impl Connection {
pub async fn new() -> TResult<Self> {
let stream = TcpStream::connect(ADDR).await?;
pub async fn new(host: &str) -> TResult<Self> {
let stream = TcpStream::connect(host).await?;
Ok(Connection {
stream,
buffer: BytesMut::with_capacity(BUF_CAP),

Loading…
Cancel
Save