diff --git a/.gitignore b/.gitignore index da19ed7..070d0c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Project binary -poseidon +/poseidon # Configuration file configuration.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bc1a3f9..d17e6e8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -77,7 +77,7 @@ dockerimage: # Prevent pull rate limit but still have normal alpine image in Dockerfile - docker pull $DOCKER_REGISTRY/library/alpine:latest - docker tag $DOCKER_REGISTRY/library/alpine:latest alpine:latest - - docker build -t $IMAGE_NAME_ENV . + - docker build -t $IMAGE_NAME_ENV -f deploy/poseidon/Dockerfile . # Run vulnerability scan before pushing the image - make trivy-scan-docker DOCKER_TAG=$IMAGE_NAME_ENV - docker push $IMAGE_NAME_ENV @@ -98,7 +98,7 @@ nomadimage: alias: docker needs: [] script: - - cd ci + - cd deploy/nomad-ci - docker login -u $DOCKER_REGISTRY_USER -p $DOCKER_REGISTRY_PASSWORD $DOCKER_REGISTRY - docker pull $DOCKER_REGISTRY/library/golang:latest - docker tag $DOCKER_REGISTRY/library/golang:latest golang:latest @@ -131,7 +131,7 @@ test_e2e: - nomad agent -dev -log-level=WARN & - sleep 5 - export NOMAD_NAMESPACE="default" - - ./ci/nomad-run-env-job.sh ci/demo-job.tpl.nomad ci/demo-job.nomad + - ./deploy/nomad-run-env-job.sh deploy/demo-job.tpl.nomad deploy/demo-job.nomad - sleep 5 # Start Poseidon and wait for it - ./poseidon & @@ -151,15 +151,15 @@ test_e2e: - nomad namespace apply $NOMAD_NAMESPACE script: # Only replace set env vars - - envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < ci/api.tpl.nomad > ci/api.nomad + - envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < deploy/api.tpl.nomad > deploy/api.nomad # Make sure to set NOMAD_ADDR, NOMAD_SKIP_VERIFY and NOMAD_TOKEN env vars in CI settings appropriately - - nomad validate ci/api.nomad + - nomad validate deploy/api.nomad # nomad plan returns 1 if allocation is created or destroyed which is what we want here - - nomad plan ci/api.nomad || [ $? == 1 ] - - nomad-run-and-wait ci/api.nomad + - nomad plan deploy/api.nomad || [ $? == 1 ] + - nomad-run-and-wait deploy/api.nomad artifacts: paths: - - ci/api.nomad + - deploy/api.nomad expire_in: 1 month expose_as: api-nomad @@ -174,7 +174,7 @@ deploy_review: before_script: - export NOMAD_NAMESPACE="$NOMAD_SLUG" - nomad namespace apply $NOMAD_NAMESPACE - - ./ci/nomad-run-env-job.sh ci/demo-job.tpl.nomad ci/demo-job.nomad + - ./deploy/nomad-run-env-job.sh deploy/demo-job.tpl.nomad deploy/demo-job.nomad only: - branches - tags diff --git a/Makefile b/Makefile index 6820551..c399b57 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PROJECT_NAME := "poseidon" -PKG := "gitlab.hpi.de/codeocean/codemoon/$(PROJECT_NAME)" +PKG := "gitlab.hpi.de/codeocean/codemoon/$(PROJECT_NAME)/cmd/$(PROJECT_NAME)" UNIT_TESTS = $(shell go list ./... | grep -v /e2e) DOCKER_E2E_CONTAINER_NAME := "$(PROJECT_NAME)-e2e-tests" @@ -28,16 +28,16 @@ git-hooks: .git/hooks/pre-commit ## Install the git-hooks .PHONY: build build: deps ## Build the binary - @go build -v $(PKG) + @go build -o $(PROJECT_NAME) -v $(PKG) .PHONY: clean clean: ## Remove previous build - @rm -f $(PROJECT_NAME) + @rm -f poseidon .PHONY: docker docker: @CGO_ENABLED=0 make build - @docker build -t $(DOCKER_TAG) . + @docker build -t $(DOCKER_TAG) -f deploy/poseidon/Dockerfile . .PHONY: lint-deps lint-deps: ## Install linter dependencies diff --git a/README.md b/README.md index 7c6f3f1..a05405d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ To get your local setup going, run `make bootstrap`. It will install all require The project can be compiled using `make build`. This should create a binary which can then be executed. -Alternatively, the `go run .` command can be used to automatically compile and run the project. +Alternatively, the `go run ./cmd/poseidon` command can be used to automatically compile and run the project. ### Docker @@ -55,7 +55,7 @@ If a value is not specified, the value of the subsequent possibility is used. ### Documentation -For the OpenAPI 3.0 definition of the API Poseidon provides, see [`swagger.yaml`](docs/swagger.yaml). +For the OpenAPI 3.0 definition of the API Poseidon provides, see [`swagger.yaml`](api/swagger.yaml). ### Authentication diff --git a/docs/swagger.yaml b/api/swagger.yaml similarity index 100% rename from docs/swagger.yaml rename to api/swagger.yaml diff --git a/docs/websocket.schema.json b/api/websocket.schema.json similarity index 100% rename from docs/websocket.schema.json rename to api/websocket.schema.json diff --git a/main.go b/cmd/poseidon/main.go similarity index 87% rename from main.go rename to cmd/poseidon/main.go index a8331f7..e5f1fbf 100644 --- a/main.go +++ b/cmd/poseidon/main.go @@ -3,12 +3,12 @@ package main import ( "context" "errors" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api" - "gitlab.hpi.de/codeocean/codemoon/poseidon/config" - "gitlab.hpi.de/codeocean/codemoon/poseidon/environment" - "gitlab.hpi.de/codeocean/codemoon/poseidon/logging" - "gitlab.hpi.de/codeocean/codemoon/poseidon/nomad" - "gitlab.hpi.de/codeocean/codemoon/poseidon/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/api" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/config" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/environment" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/nomad" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/logging" "net/http" "os" "os/signal" diff --git a/ci/api.tpl.nomad b/deploy/api.tpl.nomad similarity index 100% rename from ci/api.tpl.nomad rename to deploy/api.tpl.nomad diff --git a/ci/demo-job.tpl.nomad b/deploy/demo-job.tpl.nomad similarity index 100% rename from ci/demo-job.tpl.nomad rename to deploy/demo-job.tpl.nomad diff --git a/ci/docker-make/Dockerfile b/deploy/docker-make/Dockerfile similarity index 100% rename from ci/docker-make/Dockerfile rename to deploy/docker-make/Dockerfile diff --git a/ci/Dockerfile b/deploy/nomad-ci/Dockerfile similarity index 100% rename from ci/Dockerfile rename to deploy/nomad-ci/Dockerfile diff --git a/ci/nomad-run-and-wait b/deploy/nomad-ci/nomad-run-and-wait similarity index 100% rename from ci/nomad-run-and-wait rename to deploy/nomad-ci/nomad-run-and-wait diff --git a/ci/nomad-run-env-job.sh b/deploy/nomad-run-env-job.sh similarity index 100% rename from ci/nomad-run-env-job.sh rename to deploy/nomad-run-env-job.sh diff --git a/Dockerfile b/deploy/poseidon/Dockerfile similarity index 100% rename from Dockerfile rename to deploy/poseidon/Dockerfile diff --git a/api/api.go b/internal/api/api.go similarity index 88% rename from api/api.go rename to internal/api/api.go index 4ee0d6e..2cae1a2 100644 --- a/api/api.go +++ b/internal/api/api.go @@ -2,10 +2,10 @@ package api import ( "github.com/gorilla/mux" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/auth" - "gitlab.hpi.de/codeocean/codemoon/poseidon/environment" - "gitlab.hpi.de/codeocean/codemoon/poseidon/logging" - "gitlab.hpi.de/codeocean/codemoon/poseidon/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/api/auth" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/environment" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/logging" "net/http" ) diff --git a/api/api_test.go b/internal/api/api_test.go similarity index 97% rename from api/api_test.go rename to internal/api/api_test.go index 69c8cc5..8661602 100644 --- a/api/api_test.go +++ b/internal/api/api_test.go @@ -3,7 +3,7 @@ package api import ( "github.com/gorilla/mux" "github.com/stretchr/testify/assert" - "gitlab.hpi.de/codeocean/codemoon/poseidon/config" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/config" "net/http" "net/http/httptest" "testing" diff --git a/api/auth/auth.go b/internal/api/auth/auth.go similarity index 87% rename from api/auth/auth.go rename to internal/api/auth/auth.go index 81303cc..8c568da 100644 --- a/api/auth/auth.go +++ b/internal/api/auth/auth.go @@ -2,8 +2,8 @@ package auth import ( "crypto/subtle" - "gitlab.hpi.de/codeocean/codemoon/poseidon/config" - "gitlab.hpi.de/codeocean/codemoon/poseidon/logging" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/config" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/logging" "net/http" ) diff --git a/api/auth/auth_test.go b/internal/api/auth/auth_test.go similarity index 98% rename from api/auth/auth_test.go rename to internal/api/auth/auth_test.go index de51502..0f72373 100644 --- a/api/auth/auth_test.go +++ b/internal/api/auth/auth_test.go @@ -5,7 +5,7 @@ import ( "github.com/sirupsen/logrus/hooks/test" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "gitlab.hpi.de/codeocean/codemoon/poseidon/config" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/config" "net/http" "net/http/httptest" "testing" diff --git a/api/environments.go b/internal/api/environments.go similarity index 90% rename from api/environments.go rename to internal/api/environments.go index 2f324c8..3d58ae7 100644 --- a/api/environments.go +++ b/internal/api/environments.go @@ -5,9 +5,9 @@ import ( "errors" "fmt" "github.com/gorilla/mux" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" - "gitlab.hpi.de/codeocean/codemoon/poseidon/environment" - "gitlab.hpi.de/codeocean/codemoon/poseidon/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/environment" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "net/http" ) diff --git a/api/environments_test.go b/internal/api/environments_test.go similarity index 94% rename from api/environments_test.go rename to internal/api/environments_test.go index 351fd9f..a63df60 100644 --- a/api/environments_test.go +++ b/internal/api/environments_test.go @@ -6,9 +6,9 @@ import ( "github.com/gorilla/mux" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" - "gitlab.hpi.de/codeocean/codemoon/poseidon/environment" - "gitlab.hpi.de/codeocean/codemoon/poseidon/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/environment" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests" "math" "net/http" diff --git a/api/health.go b/internal/api/health.go similarity index 100% rename from api/health.go rename to internal/api/health.go diff --git a/api/health_test.go b/internal/api/health_test.go similarity index 100% rename from api/health_test.go rename to internal/api/health_test.go diff --git a/api/helpers.go b/internal/api/helpers.go similarity index 96% rename from api/helpers.go rename to internal/api/helpers.go index 89b72db..787b8ed 100644 --- a/api/helpers.go +++ b/internal/api/helpers.go @@ -3,7 +3,7 @@ package api import ( "encoding/json" "fmt" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "net/http" ) diff --git a/api/runners.go b/internal/api/runners.go similarity index 96% rename from api/runners.go rename to internal/api/runners.go index 8e65655..80c739d 100644 --- a/api/runners.go +++ b/internal/api/runners.go @@ -5,9 +5,9 @@ import ( "fmt" "github.com/google/uuid" "github.com/gorilla/mux" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" - "gitlab.hpi.de/codeocean/codemoon/poseidon/config" - "gitlab.hpi.de/codeocean/codemoon/poseidon/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/config" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "net/http" "net/url" ) diff --git a/api/runners_test.go b/internal/api/runners_test.go similarity index 99% rename from api/runners_test.go rename to internal/api/runners_test.go index 5cd0496..8ad2b7b 100644 --- a/api/runners_test.go +++ b/internal/api/runners_test.go @@ -7,8 +7,8 @@ import ( "github.com/gorilla/mux" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" - "gitlab.hpi.de/codeocean/codemoon/poseidon/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests" "net/http" "net/http/httptest" diff --git a/api/websocket.go b/internal/api/websocket.go similarity index 98% rename from api/websocket.go rename to internal/api/websocket.go index 418d71f..d3b1ba3 100644 --- a/api/websocket.go +++ b/internal/api/websocket.go @@ -6,8 +6,8 @@ import ( "errors" "fmt" "github.com/gorilla/websocket" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" - "gitlab.hpi.de/codeocean/codemoon/poseidon/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "io" "net/http" ) diff --git a/api/websocket_connection_mock.go b/internal/api/websocket_connection_mock.go similarity index 100% rename from api/websocket_connection_mock.go rename to internal/api/websocket_connection_mock.go diff --git a/api/websocket_test.go b/internal/api/websocket_test.go similarity index 98% rename from api/websocket_test.go rename to internal/api/websocket_test.go index 40559ee..cecdfd7 100644 --- a/api/websocket_test.go +++ b/internal/api/websocket_test.go @@ -12,9 +12,9 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" - "gitlab.hpi.de/codeocean/codemoon/poseidon/nomad" - "gitlab.hpi.de/codeocean/codemoon/poseidon/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/nomad" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests/helpers" "io" diff --git a/config/config.go b/internal/config/config.go similarity index 98% rename from config/config.go rename to internal/config/config.go index 3fe89b3..634db4c 100644 --- a/config/config.go +++ b/internal/config/config.go @@ -6,7 +6,7 @@ import ( "flag" "fmt" "github.com/sirupsen/logrus" - "gitlab.hpi.de/codeocean/codemoon/poseidon/logging" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/logging" "gopkg.in/yaml.v3" "net/url" "os" diff --git a/config/config_test.go b/internal/config/config_test.go similarity index 100% rename from config/config_test.go rename to internal/config/config_test.go diff --git a/environment/manager.go b/internal/environment/manager.go similarity index 94% rename from environment/manager.go rename to internal/environment/manager.go index 80a39fe..8d8c765 100644 --- a/environment/manager.go +++ b/internal/environment/manager.go @@ -6,10 +6,10 @@ import ( nomadApi "github.com/hashicorp/nomad/api" "github.com/hashicorp/nomad/jobspec2" "github.com/hashicorp/nomad/nomad/structs" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" - "gitlab.hpi.de/codeocean/codemoon/poseidon/logging" - "gitlab.hpi.de/codeocean/codemoon/poseidon/nomad" - "gitlab.hpi.de/codeocean/codemoon/poseidon/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/nomad" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/logging" "strconv" ) diff --git a/environment/manager_mock.go b/internal/environment/manager_mock.go similarity index 90% rename from environment/manager_mock.go rename to internal/environment/manager_mock.go index 674af83..6e52ed2 100644 --- a/environment/manager_mock.go +++ b/internal/environment/manager_mock.go @@ -4,9 +4,9 @@ package environment import ( mock "github.com/stretchr/testify/mock" - dto "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" + dto "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" - runner "gitlab.hpi.de/codeocean/codemoon/poseidon/runner" + runner "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/runner" ) // ManagerMock is an autogenerated mock type for the Manager type diff --git a/environment/manager_test.go b/internal/environment/manager_test.go similarity index 96% rename from environment/manager_test.go rename to internal/environment/manager_test.go index 5958fec..7cfe245 100644 --- a/environment/manager_test.go +++ b/internal/environment/manager_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" - "gitlab.hpi.de/codeocean/codemoon/poseidon/nomad" - "gitlab.hpi.de/codeocean/codemoon/poseidon/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/nomad" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests" "testing" ) diff --git a/environment/template-environment-job.hcl b/internal/environment/template-environment-job.hcl similarity index 100% rename from environment/template-environment-job.hcl rename to internal/environment/template-environment-job.hcl diff --git a/nomad/api_querier.go b/internal/nomad/api_querier.go similarity index 100% rename from nomad/api_querier.go rename to internal/nomad/api_querier.go diff --git a/nomad/api_querier_mock.go b/internal/nomad/api_querier_mock.go similarity index 100% rename from nomad/api_querier_mock.go rename to internal/nomad/api_querier_mock.go diff --git a/nomad/executor_api_mock.go b/internal/nomad/executor_api_mock.go similarity index 100% rename from nomad/executor_api_mock.go rename to internal/nomad/executor_api_mock.go diff --git a/nomad/job.go b/internal/nomad/job.go similarity index 100% rename from nomad/job.go rename to internal/nomad/job.go diff --git a/nomad/job_test.go b/internal/nomad/job_test.go similarity index 100% rename from nomad/job_test.go rename to internal/nomad/job_test.go diff --git a/nomad/nomad.go b/internal/nomad/nomad.go similarity index 98% rename from nomad/nomad.go rename to internal/nomad/nomad.go index c8eca7e..7ff2120 100644 --- a/nomad/nomad.go +++ b/internal/nomad/nomad.go @@ -6,9 +6,9 @@ import ( "fmt" nomadApi "github.com/hashicorp/nomad/api" "github.com/hashicorp/nomad/nomad/structs" - "gitlab.hpi.de/codeocean/codemoon/poseidon/config" - "gitlab.hpi.de/codeocean/codemoon/poseidon/logging" - "gitlab.hpi.de/codeocean/codemoon/poseidon/util" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/config" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/logging" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/nullreader" "io" "net/url" "strconv" @@ -348,7 +348,7 @@ func (a *APIClient) executeCommandInteractivelyWithStderr(allocationID string, c go func() { // Catch stderr in separate execution. exit, err := a.Execute(allocationID, ctx, stderrFifoCommand(currentNanoTime), true, - util.NullReader{}, stderr, io.Discard) + nullreader.NullReader{}, stderr, io.Discard) if err != nil { log.WithError(err).WithField("runner", allocationID).Warn("Stderr task finished with error") } diff --git a/nomad/nomad_test.go b/internal/nomad/nomad_test.go similarity index 98% rename from nomad/nomad_test.go rename to internal/nomad/nomad_test.go index 17deb3d..f8f3002 100644 --- a/nomad/nomad_test.go +++ b/internal/nomad/nomad_test.go @@ -11,9 +11,9 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "gitlab.hpi.de/codeocean/codemoon/poseidon/config" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/config" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/nullreader" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests" - "gitlab.hpi.de/codeocean/codemoon/poseidon/util" "io" "net/url" "regexp" @@ -678,7 +678,7 @@ func (s *ExecuteCommandTestSuite) TestWithSeparateStderr() { }) exitCode, err := s.nomadAPIClient. - ExecuteCommand(s.allocationID, s.ctx, s.testCommandArray, withTTY, util.NullReader{}, &stdout, &stderr) + ExecuteCommand(s.allocationID, s.ctx, s.testCommandArray, withTTY, nullreader.NullReader{}, &stdout, &stderr) s.Require().NoError(err) s.apiMock.AssertNumberOfCalls(s.T(), "Execute", 2) @@ -709,7 +709,7 @@ func (s *ExecuteCommandTestSuite) TestWithSeparateStderrReturnsCommandError() { s.mockExecute(s.testCommandArray, 1, tests.ErrDefault, func(args mock.Arguments) {}) s.mockExecute(mock.AnythingOfType("[]string"), 1, nil, func(args mock.Arguments) {}) _, err := s.nomadAPIClient. - ExecuteCommand(s.allocationID, s.ctx, s.testCommandArray, withTTY, util.NullReader{}, io.Discard, io.Discard) + ExecuteCommand(s.allocationID, s.ctx, s.testCommandArray, withTTY, nullreader.NullReader{}, io.Discard, io.Discard) s.Equal(tests.ErrDefault, err) } @@ -731,7 +731,7 @@ func (s *ExecuteCommandTestSuite) TestWithoutSeparateStderr() { }) exitCode, err := s.nomadAPIClient. - ExecuteCommand(s.allocationID, s.ctx, s.testCommandArray, withTTY, util.NullReader{}, &stdout, &stderr) + ExecuteCommand(s.allocationID, s.ctx, s.testCommandArray, withTTY, nullreader.NullReader{}, &stdout, &stderr) s.Require().NoError(err) s.apiMock.AssertNumberOfCalls(s.T(), "Execute", 1) @@ -744,7 +744,7 @@ func (s *ExecuteCommandTestSuite) TestWithoutSeparateStderrReturnsCommandError() config.Config.Server.InteractiveStderr = false s.mockExecute(s.testCommandArray, 1, tests.ErrDefault, func(args mock.Arguments) {}) _, err := s.nomadAPIClient. - ExecuteCommand(s.allocationID, s.ctx, s.testCommandArray, withTTY, util.NullReader{}, io.Discard, io.Discard) + ExecuteCommand(s.allocationID, s.ctx, s.testCommandArray, withTTY, nullreader.NullReader{}, io.Discard, io.Discard) s.ErrorIs(err, tests.ErrDefault) } diff --git a/runner/constants_test.go b/internal/runner/constants_test.go similarity index 100% rename from runner/constants_test.go rename to internal/runner/constants_test.go diff --git a/runner/execution_storage.go b/internal/runner/execution_storage.go similarity index 96% rename from runner/execution_storage.go rename to internal/runner/execution_storage.go index 3d7d17a..6d548ab 100644 --- a/runner/execution_storage.go +++ b/internal/runner/execution_storage.go @@ -1,7 +1,7 @@ package runner import ( - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "sync" ) diff --git a/runner/inactivity_timer_mock.go b/internal/runner/inactivity_timer_mock.go similarity index 100% rename from runner/inactivity_timer_mock.go rename to internal/runner/inactivity_timer_mock.go diff --git a/runner/manager.go b/internal/runner/manager.go similarity index 99% rename from runner/manager.go rename to internal/runner/manager.go index 0902b88..63ea512 100644 --- a/runner/manager.go +++ b/internal/runner/manager.go @@ -7,8 +7,8 @@ import ( "github.com/google/uuid" nomadApi "github.com/hashicorp/nomad/api" "github.com/sirupsen/logrus" - "gitlab.hpi.de/codeocean/codemoon/poseidon/logging" - "gitlab.hpi.de/codeocean/codemoon/poseidon/nomad" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/nomad" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/logging" "strconv" "strings" "time" diff --git a/runner/manager_mock.go b/internal/runner/manager_mock.go similarity index 100% rename from runner/manager_mock.go rename to internal/runner/manager_mock.go diff --git a/runner/manager_test.go b/internal/runner/manager_test.go similarity index 99% rename from runner/manager_test.go rename to internal/runner/manager_test.go index 20265b2..422a5c2 100644 --- a/runner/manager_test.go +++ b/internal/runner/manager_test.go @@ -7,7 +7,7 @@ import ( "github.com/sirupsen/logrus/hooks/test" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" - "gitlab.hpi.de/codeocean/codemoon/poseidon/nomad" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/nomad" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests/helpers" "strconv" diff --git a/runner/nomad_environment_storage.go b/internal/runner/nomad_environment_storage.go similarity index 100% rename from runner/nomad_environment_storage.go rename to internal/runner/nomad_environment_storage.go diff --git a/runner/nomad_environment_storage_test.go b/internal/runner/nomad_environment_storage_test.go similarity index 100% rename from runner/nomad_environment_storage_test.go rename to internal/runner/nomad_environment_storage_test.go diff --git a/runner/runner.go b/internal/runner/runner.go similarity index 98% rename from runner/runner.go rename to internal/runner/runner.go index d4976b5..fae635e 100644 --- a/runner/runner.go +++ b/internal/runner/runner.go @@ -8,8 +8,8 @@ import ( "errors" "fmt" nomadApi "github.com/hashicorp/nomad/api" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" - "gitlab.hpi.de/codeocean/codemoon/poseidon/nomad" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/nomad" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "io" "strings" "sync" diff --git a/runner/runner_mock.go b/internal/runner/runner_mock.go similarity index 98% rename from runner/runner_mock.go rename to internal/runner/runner_mock.go index cda0c17..408c454 100644 --- a/runner/runner_mock.go +++ b/internal/runner/runner_mock.go @@ -6,7 +6,7 @@ import ( context "context" io "io" - dto "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" + dto "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" mock "github.com/stretchr/testify/mock" diff --git a/runner/runner_test.go b/internal/runner/runner_test.go similarity index 99% rename from runner/runner_test.go rename to internal/runner/runner_test.go index db957a3..0cfebc3 100644 --- a/runner/runner_test.go +++ b/internal/runner/runner_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" - "gitlab.hpi.de/codeocean/codemoon/poseidon/nomad" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/nomad" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests" "io" "regexp" diff --git a/runner/storage.go b/internal/runner/storage.go similarity index 100% rename from runner/storage.go rename to internal/runner/storage.go diff --git a/runner/storage_test.go b/internal/runner/storage_test.go similarity index 98% rename from runner/storage_test.go rename to internal/runner/storage_test.go index c6960f2..d1471c4 100644 --- a/runner/storage_test.go +++ b/internal/runner/storage_test.go @@ -2,7 +2,7 @@ package runner import ( "github.com/stretchr/testify/suite" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests" "testing" ) diff --git a/api/dto/dto.go b/pkg/dto/dto.go similarity index 100% rename from api/dto/dto.go rename to pkg/dto/dto.go diff --git a/logging/logging.go b/pkg/logging/logging.go similarity index 100% rename from logging/logging.go rename to pkg/logging/logging.go diff --git a/logging/logging_test.go b/pkg/logging/logging_test.go similarity index 100% rename from logging/logging_test.go rename to pkg/logging/logging_test.go diff --git a/util/util.go b/pkg/nullreader/nullreader.go similarity index 92% rename from util/util.go rename to pkg/nullreader/nullreader.go index 300e829..040ad6e 100644 --- a/util/util.go +++ b/pkg/nullreader/nullreader.go @@ -1,4 +1,4 @@ -package util +package nullreader // NullReader is a struct that implements the io.Reader interface and returns nothing when reading // from it. diff --git a/util/util_test.go b/pkg/nullreader/nullreader_test.go similarity index 96% rename from util/util_test.go rename to pkg/nullreader/nullreader_test.go index dace55d..a21b048 100644 --- a/util/util_test.go +++ b/pkg/nullreader/nullreader_test.go @@ -1,4 +1,4 @@ -package util +package nullreader import ( "github.com/stretchr/testify/assert" diff --git a/tests/constants.go b/tests/constants.go index 40bc963..5be6be6 100644 --- a/tests/constants.go +++ b/tests/constants.go @@ -3,7 +3,7 @@ package tests import ( "errors" nomadApi "github.com/hashicorp/nomad/api" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "time" ) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index c259ee0..fc1d4ab 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -4,10 +4,10 @@ import ( "flag" nomadApi "github.com/hashicorp/nomad/api" "github.com/stretchr/testify/suite" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" - "gitlab.hpi.de/codeocean/codemoon/poseidon/config" - "gitlab.hpi.de/codeocean/codemoon/poseidon/logging" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/api" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/config" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/logging" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests/helpers" "net/http" diff --git a/tests/e2e/environments_test.go b/tests/e2e/environments_test.go index f8711af..2c2548b 100644 --- a/tests/e2e/environments_test.go +++ b/tests/e2e/environments_test.go @@ -4,9 +4,9 @@ import ( nomadApi "github.com/hashicorp/nomad/api" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" - "gitlab.hpi.de/codeocean/codemoon/poseidon/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/api" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/runner" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests/helpers" "io" diff --git a/tests/e2e/health_test.go b/tests/e2e/health_test.go index 15603f6..a5b96f1 100644 --- a/tests/e2e/health_test.go +++ b/tests/e2e/health_test.go @@ -2,7 +2,7 @@ package e2e import ( "github.com/stretchr/testify/assert" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/api" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests/helpers" "net/http" "testing" diff --git a/tests/e2e/runners_test.go b/tests/e2e/runners_test.go index 6163a8e..93f9d8b 100644 --- a/tests/e2e/runners_test.go +++ b/tests/e2e/runners_test.go @@ -5,8 +5,8 @@ import ( "encoding/json" "fmt" "github.com/gorilla/websocket" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/api" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests/helpers" "io" diff --git a/tests/e2e/websocket_test.go b/tests/e2e/websocket_test.go index c5d338f..b931852 100644 --- a/tests/e2e/websocket_test.go +++ b/tests/e2e/websocket_test.go @@ -7,9 +7,9 @@ import ( "fmt" "github.com/gorilla/websocket" "github.com/stretchr/testify/suite" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" - "gitlab.hpi.de/codeocean/codemoon/poseidon/nomad" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/api" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/nomad" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests/helpers" "net/http" diff --git a/tests/helpers/test_helpers.go b/tests/helpers/test_helpers.go index 9569fe8..3f3e193 100644 --- a/tests/helpers/test_helpers.go +++ b/tests/helpers/test_helpers.go @@ -10,8 +10,8 @@ import ( "github.com/gorilla/mux" "github.com/gorilla/websocket" nomadApi "github.com/hashicorp/nomad/api" - "gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto" - "gitlab.hpi.de/codeocean/codemoon/poseidon/config" + "gitlab.hpi.de/codeocean/codemoon/poseidon/internal/config" + "gitlab.hpi.de/codeocean/codemoon/poseidon/pkg/dto" "gitlab.hpi.de/codeocean/codemoon/poseidon/tests" "io" "net/http"