Skip to content

Commit 6fdafae

Browse files
tassjacaspiano
andauthored
conform to PlaceOS::Model::Version (#107)
* feat: conform to PlaceOS::Model::Version * test: healthcheck * ci: allow varying crystal version Co-authored-by: Caspian Baska <[email protected]>
1 parent ed30fbf commit 6fdafae

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

shard.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,3 @@ shards:
196196
yaml_mapping:
197197
git: https://github.com/crystal-lang/yaml_mapping.cr.git
198198
version: 0.1.1
199-

shard.yml

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

4848
placeos-models:
4949
github: placeos/models
50-
version: ~> 5.0
50+
version: ~> 5.3
5151

5252
placeos-resource:
5353
github: place-labs/resource

spec/controllers/root_spec.cr

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

src/controllers/root.cr

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require "./application"
2+
require "placeos-models/version"
23

34
require "rethinkdb"
45
require "rethinkdb-orm"
@@ -17,6 +18,15 @@ module PlaceOS::Core::Api
1718
head self.class.healthcheck? ? HTTP::Status::OK : HTTP::Status::INTERNAL_SERVER_ERROR
1819
end
1920

21+
get "/version", :version do
22+
render :ok, json: PlaceOS::Model::Version.new(
23+
version: VERSION,
24+
build_time: BUILD_TIME,
25+
commit: BUILD_COMMIT,
26+
service: APP_NAME
27+
)
28+
end
29+
2030
def self.healthcheck? : Bool
2131
Promise.all(
2232
Promise.defer {

src/placeos-core/client.cr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ module PlaceOS::Core
213213
CoreStatus.from_json(response.body)
214214
end
215215

216+
def version : PlaceOS::Model::Version
217+
PlaceOS::Model::Version.from_json(get("/version").body)
218+
end
219+
216220
struct Load < BaseResponse
217221
getter local : SystemLoad
218222
getter edge : Hash(String, SystemLoad)

0 commit comments

Comments
 (0)