Skip to content

Commit db2b2c1

Browse files
authored
Merge pull request #26 from PlaceOS/service-version
feat: conform to PlaceOS::Model::Version
2 parents d0d3ec0 + 955df12 commit db2b2c1

8 files changed

Lines changed: 51 additions & 21 deletions

File tree

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
FROM crystallang/crystal:1.0.0-alpine as builder
2+
ARG PLACE_COMMIT="DEV"
3+
ARG PLACE_VERSION="DEV"
24

35
WORKDIR /build
46

@@ -10,7 +12,9 @@ RUN CRFLAGS="--static" shards install --production --ignore-crystal-version
1012

1113
COPY src /build/src
1214

13-
RUN crystal build --error-trace --static --release --no-debug -o bin/frontends src/app.cr
15+
RUN PLACE_COMMIT=$PLACE_COMMIT \
16+
PLACE_VERSION=$PLACE_VERSION \
17+
crystal build --release --no-debug --error-trace -o bin/frontends src/app.cr
1418

1519
FROM alpine:3.11
1620
WORKDIR /app

shard.lock

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ shards:
77

88
action-controller:
99
git: https://github.com/spider-gazelle/action-controller.git
10-
version: 4.4.1
10+
version: 4.5.0
1111

1212
active-model:
1313
git: https://github.com/spider-gazelle/active-model.git
@@ -21,13 +21,9 @@ shards:
2121
git: https://github.com/spider-gazelle/bindata.git
2222
version: 1.9.0
2323

24-
bisect:
25-
git: https://github.com/spider-gazelle/bisect.git
26-
version: 1.2.1
27-
2824
connect-proxy:
2925
git: https://github.com/spider-gazelle/connect-proxy.git
30-
version: 1.2.1
26+
version: 1.4.0
3127

3228
crc16:
3329
git: https://github.com/maiha/crc16.cr.git
@@ -45,6 +41,10 @@ shards:
4541
git: https://github.com/sija/debug.cr.git
4642
version: 2.0.1
4743

44+
dtls:
45+
git: https://github.com/spider-gazelle/crystal-dtls.git
46+
version: 0.9.0
47+
4848
etcd:
4949
git: https://github.com/place-labs/crystal-etcd.git
5050
version: 1.2.4
@@ -111,15 +111,15 @@ shards:
111111

112112
placeos-driver:
113113
git: https://github.com/placeos/driver.git
114-
version: 5.1.1
114+
version: 5.3.13
115115

116116
placeos-log-backend:
117117
git: https://github.com/place-labs/log-backend.git
118118
version: 0.4.0
119119

120120
placeos-models:
121121
git: https://github.com/placeos/models.git
122-
version: 4.18.2
122+
version: 5.5.0
123123

124124
placeos-resource:
125125
git: https://github.com/place-labs/resource.git
@@ -129,10 +129,6 @@ shards:
129129
git: https://github.com/ysbaddaden/pool.git
130130
version: 0.2.4
131131

132-
priority-queue:
133-
git: https://github.com/spider-gazelle/priority-queue.git
134-
version: 1.0.1
135-
136132
promise:
137133
git: https://github.com/spider-gazelle/promise.git
138134
version: 2.2.2
@@ -179,7 +175,7 @@ shards:
179175

180176
tasker:
181177
git: https://github.com/spider-gazelle/tasker.git
182-
version: 2.0.3
178+
version: 2.0.5
183179

184180
tokenizer:
185181
git: https://github.com/spider-gazelle/tokenizer.git

shard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020

2121
placeos-models:
2222
github: placeos/models
23-
version: ~> 4.13
23+
version: ~> 5.3
2424

2525
placeos-log-backend:
2626
github: place-labs/log-backend

spec/helper.cr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
require "file_utils"
22
require "placeos-log-backend"
33
require "placeos-models/spec/generator"
4-
54
require "../src/placeos-frontends"
5+
require "../lib/action-controller/spec/curl_context"
6+
require "action-controller/server"
67

78
require "spec"
89

spec/root_spec.cr

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require "./helper"
2+
3+
module PlaceOS::Frontends::Api
4+
describe Root do
5+
with_server do
6+
it "health checks" do
7+
result = curl("GET", "/api/frontends/v1/")
8+
result.success?.should be_true
9+
end
10+
11+
it "should check version" do
12+
result = curl("GET", "/api/frontends/v1/version")
13+
result.status_code.should eq 200
14+
PlaceOS::Model::Version.from_json(result.body).service.should eq "frontends"
15+
end
16+
end
17+
end
18+
end

src/constants.cr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
require "secrets-env"
22

33
module PlaceOS::Frontends
4-
APP_NAME = "frontends"
5-
VERSION = {{ `shards version "#{__DIR__}"`.chomp.stringify.downcase }}
4+
APP_NAME = "frontends"
5+
VERSION = {{ `shards version "#{__DIR__}"`.chomp.stringify.downcase }}
6+
BUILD_TIME = {{ system("date -u").stringify }}
7+
BUILD_COMMIT = {{ env("PLACE_COMMIT") || "DEV" }}
68

79
PROD = (ENV["SG_ENV"]? || ENV["ENV"]?) == "production"
810

src/placeos-frontends/client.cr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ module PlaceOS::Frontends
6060
Array(String).from_json(response.body)
6161
end
6262

63+
def version : PlaceOS::Model::Version
64+
Model::Version.from_json(get("/version").body)
65+
end
66+
6367
###########################################################################
6468

6569
def initialize(
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
require "./base"
22

3+
require "placeos-models/version"
4+
35
module PlaceOS::Frontends::Api
46
class Root < Base
57
base "/api/frontends/v1"
@@ -9,9 +11,12 @@ module PlaceOS::Frontends::Api
911
end
1012

1113
get "/version", :version do
12-
render :ok, json: {
13-
version: VERSION.to_s,
14-
}
14+
render :ok, json: PlaceOS::Model::Version.new(
15+
version: VERSION,
16+
build_time: BUILD_TIME,
17+
commit: BUILD_COMMIT,
18+
service: APP_NAME
19+
)
1520
end
1621
end
1722
end

0 commit comments

Comments
 (0)