/go-resthell

Micro-DDD RestAPI for Shell Executor

Primary LanguageGoMIT LicenseMIT

go-resthell

Micro-DDD (Hex-Arc) RestAPI for Shell Executor

Build Test Test

PkgGoDev GitHub Actions CI Status Stars Badge Forks Badge Pull Requests Badge Issues Badge GitHub contributors License Badge

Stack

GitHub GitHub Actions Go Docker Kubernetes

Dependencies

Go-Gin Go-Ioc Go-Json Go-Yaml Go-Uuid Testify

Getting Started

Resthell provides the ability to run a shell command with RestAPI. You can run it locally or as a container.

It has been developed with Domain Driven Design (Hex-Arc) architecture and allows you to be included in the domain and perform external operations in all microservice infrastructures without additional development processes.

Do you want to learn more information about Domain Driven Design and Hex-Arc?

Also, you can see these pictures about Domain Driven Design (Hex-Arc).

Installation

git clone https://github.com/husamettinarabaci/go-resthell.git
cd go-resthell
go mod download

Test

go test -v ./...

Usage

POST https://localhost:18080/api/cmd HTTP/1.1
content-type: application/json

{
    "command": "ls -al"
}

Local Run

export LOCAL=true && go run cmd/main.go

Docker Build & Run

docker build -t {DOCKER_USERNAME}/{YOUR_REPO} -f script/Dockerfile .
docker tag {DOCKER_USERNAME}/{YOUR_REPO} {DOCKER_USERNAME}/{YOUR_REPO}:latest
docker push {DOCKER_USERNAME}/{YOUR_REPO}:latest
docker run -p 18080:18080 {DOCKER_USERNAME}/{YOUR_REPO}:latest

Kubernetes Deploy

kubectl apply -f script/k8s.yml

Github Actions

Fork the project and create the below secrets in your repo.

DOCKERHUB_USERNAME

DOCKERHUB_TOKEN

Create "release" branch and create a pull request to "release" branch and merge it. Github Actions will build and push docker image to your dockerhub repo.

Project Structure - Domain Driven Design (Hex-Arc)

.
├── cmd
│   └── main.go
├── config
│   ├── log_local.yml
│   ├── log.yml
│   ├── rest_local.yml
│   └── rest.yml
├── core
│   ├── application
│   │   ├── infrastructure
│   │   │   └── port
│   │   │       ├── log.go
│   │   │       └── shell.go
│   │   ├── presentation
│   │   │   ├── adapter
│   │   │   │   ├── command.go
│   │   │   │   └── query.go
│   │   │   └── port
│   │   │       ├── command.go
│   │   │       └── query.go
│   │   └── service
│   │       └── service.go
│   └── domain
│       ├── model
│       │   ├── entity
│       │   │   ├── commandrequest.go
│       │   │   └── commandresponse.go
│       │   ├── interface
│       │   │   └── loggable.go
│       │   └── object
│       │       ├── command.go
│       │       ├── error.go
│       │       └── response.go
│       └── service
│           └── service.go
├── go.mod
├── go.sum
├── LICENSE
├── pkg
│   ├── infrastructure
│   │   ├── adapter
│   │   │   ├── log.go
│   │   │   └── shell.go
│   │   └── mapper
│   │       └── command.go
│   └── presentation
│       ├── controller
│       │   └── rest
│       │       └── restapi.go
│       └── dto
│           ├── commandrequest.go
│           └── commandresponse.go
├── README.md
├── script
│   ├── Dockerfile
│   └── k8s.yml
├── TODO.md
└── tool
    ├── config
    │   ├── log.go
    │   └── rest.go
    └── json
        └── json.go

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Tasks

  • Implement Pipe Supporting

Contact

Hüsamettin ARABACI - info@husamettinarabaci.com

Project Link: https://github.com/husamettinarabaci/go-resthell