Skip to content

Commit

Permalink
Remove router and protos
Browse files Browse the repository at this point in the history
Signed-off-by: Elliott Davis <elliott@excellent.io>
  • Loading branch information
Elliott Davis committed Nov 2, 2018
1 parent a4676d7 commit 92f4e05
Show file tree
Hide file tree
Showing 53 changed files with 264 additions and 3,619 deletions.
10 changes: 0 additions & 10 deletions .bldr.toml
Expand Up @@ -38,16 +38,6 @@ paths = [
"support/ci/builder-base-plan.sh",
]

[builder-router]
plan_path = "components/builder-router/habitat"
paths = [
"components/builder-router/*",
"components/builder-protocol/*",
"components/core/*",
"components/net/*",
"support/ci/builder-base-plan.sh",
]

[builder-worker]
plan_path = "components/builder-worker/habitat"
paths = [
Expand Down
16 changes: 7 additions & 9 deletions .studiorc
Expand Up @@ -99,7 +99,7 @@ _build-builder() {
fi

if [[ "$#" -eq 0 ]]; then
build-builder api jobsrv router worker
build-builder api jobsrv worker
return $?
fi

Expand Down Expand Up @@ -141,7 +141,6 @@ _start-builder() {
configure
start-builder cache
start-builder memcached
start-builder router
start-builder api
start-builder api-proxy
start-builder jobsrv
Expand Down Expand Up @@ -210,18 +209,17 @@ start-cache() {
}

declare -A svc_params=(
[api]=" -s at-once --bind router:builder-router.default --bind memcached:builder-memcached.default --bind datastore:builder-datastore.default --bind jobsrv:builder-jobsrv.default"
[api]=" -s at-once --bind memcached:builder-memcached.default --bind datastore:builder-datastore.default --bind jobsrv:builder-jobsrv.default"
[api-proxy]=" --bind http:builder-api.default"
[jobsrv]=" -s at-once --bind router:builder-router.default --bind datastore:builder-datastore.default"
[router]=" -s at-once"
[jobsrv]=" -s at-once --bind datastore:builder-datastore.default"
[worker]=" -s at-once --bind jobsrv:builder-jobsrv.default --bind depot:builder-api-proxy.default"
[minio]=" -s at-once"
[memcached]=" -s at-once"
)

_stop-builder() {
if [[ "$#" -eq 0 ]]; then
stop-builder cache api api-proxy datastore jobsrv router worker minio memcached
stop-builder cache api api-proxy datastore jobsrv worker minio memcached
return $?
fi

Expand Down Expand Up @@ -305,7 +303,7 @@ export -f psql

# Cleanup any development touch files we laid down when checking to see if we could run NO_INSTALL_DEPS
local_cleanup() {
for svc in api api-proxy datastore jobsrv router worker minio; do
for svc in api api-proxy datastore jobsrv worker minio; do
if [ -f "/src/components/builder-${svc}/cleanup" ]; then
rm "/src/components/builder-${svc}/cleanup"
fi
Expand All @@ -331,14 +329,14 @@ The following commands are available:
* build-builder (alias: bb) - build Builder components
USAGE: build-builder [COMPONENT]...
With no args, build all builder components
Valid components: api jobsrv router worker
Valid components: api jobsrv worker
3. Running Builder
* install-packages - Install all dependent packages
* start-builder/stop-builder - load/unload Builder services
USAGE: start-builder [SERVICE]...
stop-builder [SERVICE]...
With no args, load/unload all builder services
Valid services: api api-proxy cache datastore jobsrv router worker minio
Valid services: api api-proxy cache datastore jobsrv worker minio
* ui-dev-mode - helper to switch the github app to localhost:3000
4. Helpers
* psql - wrapper around psql to enable passwordless auth
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -14,7 +14,7 @@ env:
# Habitat Rust program components
- _RUST_HAB_BIN_COMPONENTS="components/airlock"
# Builder Rust program components
- _RUST_BLDR_BIN_COMPONENTS="components/builder-api components/builder-jobsrv components/builder-router components/builder-worker"
- _RUST_BLDR_BIN_COMPONENTS="components/builder-api components/builder-jobsrv components/builder-worker"
# Builder Rust crate components
- _RUST_BLDR_LIB_COMPONENTS="components/builder-core components/builder-db components/net components/github-api-client components/segment-api-client"

Expand Down
1 change: 0 additions & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -9,7 +9,6 @@ components/builder-worker/src/main.rs @apriofrost
components/builder-api/src/main.rs @apriofrost
components/builder-graph/src/main.rs @apriofrost
components/builder-jobsrv/src/main.rs @apriofrost
components/builder-router/src/main.rs @apriofrost
components/github-api-client @chefsalim @raskchanky
components/net @chefsalim @raskchanky
components/oauth-client @chefsalim @raskchanky
Expand Down
19 changes: 0 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Expand Up @@ -10,7 +10,6 @@ members = [
"components/builder-graph",
"components/builder-jobsrv",
"components/builder-protocol",
"components/builder-router",
"components/builder-worker",
"components/github-api-client",
"components/net",
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPING.md
Expand Up @@ -113,7 +113,7 @@ If you are developing the UI:
* `origin <name>` - Create the core origin. Default: core
* `project` - Create a project (you can also configure this in the web UI)
* `build-builder` - Build all the builder components
* `build-<component>` - Ex: `build-router` will build the router component for development and load it
* `build-builder <component>` - Ex: `build-builder api` will build the api component for development and load it
* `dev_docs` - Print the full set of command docs

### Generate a Personal Access Token using the web UI
Expand Down
8 changes: 3 additions & 5 deletions Dockerfile
Expand Up @@ -36,8 +36,7 @@ RUN adduser -g tty -h /home/krangschnak -D krangschnak \
habitat/builder-datastore \
habitat/builder-api \
habitat/builder-api-proxy \
habitat/builder-jobsrv \
habitat/builder-router
habitat/builder-jobsrv\

RUN /tmp/init-datastore.sh \
&& APP_HOSTNAME=$APP_HOSTNAME \
Expand All @@ -56,10 +55,9 @@ RUN hab pkg exec core/openssl openssl s_client -showcerts -connect $GITHUB_ADDR:
/usr/local/share/ca-certificates/github.crt && update-ca-certificates

RUN hab svc load habitat/builder-datastore \
&& hab svc load habitat/builder-router \
&& hab svc load habitat/builder-api-proxy --bind http:builder-api.default \
&& hab svc load habitat/builder-api --bind router:builder-router.default \
&& hab svc load habitat/builder-jobsrv --bind router:builder-router.default --bind datastore:builder-datastore.default
&& hab svc load habitat/builder-api --bind datastore:builder-datastore.default \
&& hab svc load habitat/builder-jobsrv --bind datastore:builder-datastore.default

VOLUME ["/hab/svc", "/hab/cache/keys", "/hab/sup"]
EXPOSE 80 443 9631 9636 9638
Expand Down
2 changes: 1 addition & 1 deletion Makefile
@@ -1,7 +1,7 @@
UNAME_S := $(shell uname -s)
BIN = airlock
LIB = builder-db builder-core github-api-client net
SRV = builder-api builder-router builder-jobsrv builder-worker
SRV = builder-api builder-jobsrv builder-worker
ALL = $(BIN) $(LIB) $(SRV)

.DEFAULT_GOAL := build-bin
Expand Down
4 changes: 1 addition & 3 deletions builder/plan.sh
Expand Up @@ -8,13 +8,11 @@ pkg_services=(
habitat/builder-api-proxy
habitat/builder-datastore
habitat/builder-jobsrv
habitat/builder-router
habitat/builder-worker
)

pkg_bind_map=(
[habitat/builder-api-proxy]="http:habitat/builder-api"
[habitat/builder-api]="router:habitat/builder-router"
[habitat/builder-jobsrv]="router:habitat/builder-router datastore:habitat/builder-datastore"
[habitat/builder-jobsrv]="datastore:habitat/builder-datastore"
[habitat/builder-worker]="jobsrv:habitat/builder-jobsrv depot:habitat/builder-api"
)
6 changes: 0 additions & 6 deletions components/builder-api/habitat/config/config.toml
Expand Up @@ -14,12 +14,6 @@ app_private_key = "{{pkg.svc_files_path}}/builder-github-app.pem"
[oauth]
{{toToml cfg.oauth}}

{{~#eachAlive bind.router.members as |member|}}
[[routers]]
host = "{{member.sys.ip}}"
port = {{member.cfg.port}}
{{~/eachAlive}}

[s3]
{{toToml cfg.s3}}

Expand Down
1 change: 0 additions & 1 deletion components/builder-api/habitat/plan.sh
Expand Up @@ -13,7 +13,6 @@ pkg_exports=(
)
pkg_exposes=(port)
pkg_binds=(
[router]="port"
[memcached]="port"
[datastore]="port"
)
Expand Down
15 changes: 0 additions & 15 deletions components/builder-api/src/config.rs
Expand Up @@ -28,7 +28,6 @@ use db::config::DataStoreCfg;
use hab_core;
use hab_core::config::ConfigFile;
use hab_core::package::target::{self, PackageTarget};
use hab_net::app::config::RouterAddr;

use github_api_client::config::GitHubCfg;
use oauth_client::config::OAuth2Cfg;
Expand All @@ -48,9 +47,6 @@ pub trait GatewayCfg {
fn listen_addr(&self) -> &IpAddr;

fn listen_port(&self) -> u16;

/// Return a list of router addresses
fn route_addrs(&self) -> &[RouterAddr];
}

#[derive(Clone, Debug, Deserialize)]
Expand All @@ -60,7 +56,6 @@ pub struct Config {
pub github: GitHubCfg,
pub http: HttpCfg,
pub oauth: OAuth2Cfg,
pub routers: Vec<RouterAddr>,
pub s3: S3Cfg,
pub segment: SegmentCfg,
pub ui: UiCfg,
Expand All @@ -76,7 +71,6 @@ impl Default for Config {
github: GitHubCfg::default(),
http: HttpCfg::default(),
oauth: OAuth2Cfg::default(),
routers: vec![RouterAddr::default()],
s3: S3Cfg::default(),
segment: SegmentCfg::default(),
ui: UiCfg::default(),
Expand Down Expand Up @@ -180,10 +174,6 @@ impl GatewayCfg for Config {
fn listen_port(&self) -> u16 {
self.http.port
}

fn route_addrs(&self) -> &[RouterAddr] {
self.routers.as_slice()
}
}

/// Public listening net address for HTTP requests
Expand Down Expand Up @@ -314,10 +304,6 @@ mod tests {
[ui]
root = "/some/path"
[[routers]]
host = "172.18.0.2"
port = 9632
[oauth]
client_id = "0c2f738a7d0bd300de10"
client_secret = "438223113eeb6e7edf2d2f91a232b72de72b9bdf"
Expand Down Expand Up @@ -381,7 +367,6 @@ mod tests {
assert_eq!(config.http.port, 9636);
assert_eq!(config.http.handler_count, 128);
assert_eq!(config.http.keep_alive, 30);
assert_eq!(&format!("{}", config.routers[0]), "172.18.0.2:9632");

assert_eq!(config.oauth.client_id, "0c2f738a7d0bd300de10");
assert_eq!(
Expand Down
37 changes: 6 additions & 31 deletions components/builder-api/src/server/helpers.rs
Expand Up @@ -22,8 +22,7 @@ use serde_json;

use hab_core::package::PackageTarget;

use protocol::jobsrv::*;
use protocol::originsrv::*;
use protocol::jobsrv;

use db::models::channel::PackageChannelTrigger as PCT;
use db::models::package::PackageVisibility;
Expand Down Expand Up @@ -134,22 +133,6 @@ pub fn visibility_for_optional_session(
req: &HttpRequest<AppState>,
optional_session_id: Option<u64>,
origin: &str,
) -> Vec<OriginPackageVisibility> {
let mut v = Vec::new();
v.push(OriginPackageVisibility::Public);

if optional_session_id.is_some() && authorize_session(req, Some(&origin)).is_ok() {
v.push(OriginPackageVisibility::Hidden);
v.push(OriginPackageVisibility::Private);
}

v
}

pub fn visibility_for_optional_session_model(
req: &HttpRequest<AppState>,
optional_session_id: Option<u64>,
origin: &str,
) -> Vec<PackageVisibility> {
let mut v = Vec::new();
v.push(PackageVisibility::Public);
Expand All @@ -162,28 +145,20 @@ pub fn visibility_for_optional_session_model(
v
}

pub fn all_visibilities() -> Vec<OriginPackageVisibility> {
vec![
OriginPackageVisibility::Public,
OriginPackageVisibility::Private,
OriginPackageVisibility::Hidden,
]
}

pub fn all_visibilities_model() -> Vec<PackageVisibility> {
pub fn all_visibilities() -> Vec<PackageVisibility> {
vec![
PackageVisibility::Public,
PackageVisibility::Private,
PackageVisibility::Hidden,
]
}

pub fn trigger_from_request(req: &HttpRequest<AppState>) -> JobGroupTrigger {
pub fn trigger_from_request(req: &HttpRequest<AppState>) -> jobsrv::JobGroupTrigger {
// TODO: the search strings should be configurable.
match req.headers().get(header::USER_AGENT) {
Some(ref agent) => match agent.to_str() {
Ok(s) => if s.starts_with("hab/") {
return JobGroupTrigger::HabClient;
return jobsrv::JobGroupTrigger::HabClient;
},
Err(_) => (),
},
Expand All @@ -194,14 +169,14 @@ pub fn trigger_from_request(req: &HttpRequest<AppState>) -> JobGroupTrigger {
Some(ref referer) => match referer.to_str() {
// this needs to be as generic as possible otherwise local dev envs and on-prem depots won't work
Ok(s) => if s.contains("http") {
return JobGroupTrigger::BuilderUI;
return jobsrv::JobGroupTrigger::BuilderUI;
},
Err(_) => (),
},
None => (),
}

JobGroupTrigger::Unknown
jobsrv::JobGroupTrigger::Unknown
}

// TED remove function above when it's no longer used anywhere
Expand Down

0 comments on commit 92f4e05

Please sign in to comment.