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

Working rudimentary example version #2

Closed
wants to merge 10 commits into from
7 changes: 7 additions & 0 deletions templates/ttvars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

## TT_PROJECTS - This is the root folder of your git-backed projects
TT_PROJECTS=~/tmp
Copy link
Member

Choose a reason for hiding this comment

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

This is really cool. I suppose this would give you the option to both:

  1. create two workspaces that share the same source code directories for equally named services
  2. create two workspaces that do not share the same source code directories for equally named services


## TT_GIT_BASE - This is the base URL of your git projects (will be used like $TT_GIT_BASE/project.git)
[email protected]:meet-tarantino
6 changes: 4 additions & 2 deletions tt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/bash

# variables
TT_PROJECTS=${TT_PROJECTS:-~/tmp}
TT_GIT_BASE=${TT_GIT_BASE:[email protected]:meet-tarantino}
TT_IS_GLOBAL=$([ "$0" = "/usr/local/bin/tt" ] && echo true || echo false)
TT_SHARE=$([ $TT_IS_GLOBAL = true ] && echo /usr/local/share/tarantino || dirname $0)
TT_HOME=${TT_HOME:-~/.tt}
Expand Down Expand Up @@ -57,6 +55,10 @@ main() {
esac
fi

TT_PROJECTS=${TT_PROJECTS:-~/tmp}
TT_GIT_BASE=${TT_GIT_BASE:[email protected]:meet-tarantino}
apply_workspace_vars # this may override the above defaults
Copy link
Member

Choose a reason for hiding this comment

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

Now that I think of it, are you sure we need to do this explicitly? Part of our vision included allowing workspaces to define their own bash scripts to be automatically sourced so that additional commands could be added. (Think tt logs being added by a workspace where Kibana is included.)

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, not sure if lines 58/59 need to exist, it was more for back-compat for my other workspace that uses those lol

Copy link
Member

Choose a reason for hiding this comment

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

Based on what's in master and #1, our intent was to allow workspaces to contain a plugins directory. We would then . source the scripts in there so we could inherit other tt_... functions. We could leverage that for configuration too?

Copy link
Member Author

Choose a reason for hiding this comment

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

interesting, yeah i remember that now, lets cross that bridge when we get to plugins :)


run_sub_command tt $@
}

Expand Down
11 changes: 11 additions & 0 deletions workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ init() {

cp $TT_SHARE/templates/docker-compose-static.yml .
echo sample docker-compose-static.yml file created

cp $TT_SHARE/templates/ttvars.sh .
echo sample ttvars.sh created
}

is_workspace() {
Expand All @@ -133,3 +136,11 @@ get_workspace_dir() {
get_workspace() {
basename "$(get_workspace_dir)"
}

apply_workspace_vars() {
varsFile="$(get_workspace_dir)/ttvars.sh"
if [ ! -f $varsFile ]; then
return 0;
fi
source $varsFile
}