From 5aaae70a991c0ba1c1df2841c2539a4e46a33d5d Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Sun, 28 Apr 2019 13:31:43 -0400 Subject: [PATCH 1/2] check that /api doesn't import internal nomad pkgs --- GNUmakefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/GNUmakefile b/GNUmakefile index 7e24146e366c..ad9d3b917a20 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -183,6 +183,9 @@ check: ## Lint the source code @$(MAKE) proto @if (git status | grep -q .pb.go); then echo the following proto files are out of sync; git status |grep .pb.go; exit 1; fi + @echo "==> Check API package is isolated from rest" + @! go list -f '{{ join .Deps "\n" }}' ./api | grep github.com/hashicorp/nomad/ | grep -v -e /vendor/ -e /nomad/api/ + .PHONY: checkscripts checkscripts: ## Lint shell scripts @echo "==> Linting scripts..." From 1a54a0b8391a68ff2579023493dad15ce45605d4 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Sat, 27 Apr 2019 08:33:47 -0400 Subject: [PATCH 2/2] divest /api from nomad/structs The API package needs to be independent from rest of nomad packages, to avoid leaking internal packages and dependencies (e.g. raft, ugorji, etc) --- api/allocations.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/api/allocations.go b/api/allocations.go index 7ca28d759002..d9ea7063d130 100644 --- a/api/allocations.go +++ b/api/allocations.go @@ -4,8 +4,6 @@ import ( "fmt" "sort" "time" - - "github.com/hashicorp/nomad/nomad/structs" ) var ( @@ -111,13 +109,13 @@ func (a *Allocations) Signal(alloc *Allocation, q *QueryOptions, task, signal st return err } - req := structs.AllocSignalRequest{ + req := AllocSignalRequest{ AllocID: alloc.ID, Signal: signal, Task: task, } - var resp structs.GenericResponse + var resp GenericResponse _, err = nodeClient.putQuery("/v1/client/allocation/"+alloc.ID+"/signal", &req, &resp, q) return err } @@ -295,6 +293,18 @@ type AllocationRestartRequest struct { TaskName string } +type AllocSignalRequest struct { + AllocID string + Task string + Signal string +} + +// GenericResponse is used to respond to a request where no +// specific response information is needed. +type GenericResponse struct { + WriteMeta +} + // RescheduleTracker encapsulates previous reschedule events type RescheduleTracker struct { Events []*RescheduleEvent