Skip to content

Commit c7c13cf

Browse files
authored
feat: bootstrap code for entropy service (#1)
* feat: bootstrap code for entropy service * fix: linting * fix: Makefile and Dockerfile to fix build test and lint issues * feat: add github workflows for lint, test and publish * feat: add github.com/odpf/salt/cmdx * feat: add version cli command * feat: add configuration for goreleaser * ci: release using goreleaser * feat: add grpc_health_probe executable to docker image * ci: change snapshot name_template for goreleaser * docs: update readme and configuration reference doc
1 parent 9a14cfa commit c7c13cf

28 files changed

+1647
-1
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/workflows/lint.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Lint
2+
on: [push, pull_request, workflow_dispatch]
3+
4+
jobs:
5+
golangci-lint:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
9+
- uses: actions/setup-go@v2
10+
with:
11+
go-version: "1.16"
12+
- name: download dependencies
13+
run: make download
14+
- name: golangci-lint
15+
uses: golangci/golangci-lint-action@v2
16+
with:
17+
skip-go-installation: true
18+
version: v1.41.1

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- "v*.*.*"
6+
7+
jobs:
8+
docker:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
- uses: actions/setup-go@v2
16+
with:
17+
go-version: "1.16"
18+
- name: Login to DockerHub
19+
uses: docker/login-action@v1
20+
with:
21+
username: ${{ secrets.DOCKERHUB_USERNAME }}
22+
password: ${{ secrets.DOCKERHUB_TOKEN }}
23+
- name: Run GoReleaser
24+
uses: goreleaser/[email protected]
25+
with:
26+
distribution: goreleaser
27+
version: latest
28+
args: --rm-dist
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_TOKEN }}

.github/workflows/test.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Test
2+
on: [push, pull_request, workflow_dispatch]
3+
4+
jobs:
5+
test:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
9+
- uses: actions/setup-go@v2
10+
with:
11+
go-version: "1.16"
12+
- name: run tests
13+
run: make test

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@
1313

1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
16+
17+
dist/
18+
coverage/
19+
config.yaml

.goreleaser.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
project_name: entropy
2+
3+
release:
4+
prerelease: auto
5+
draft: true
6+
7+
before:
8+
hooks:
9+
- make clean
10+
11+
builds:
12+
- main: ./main.go
13+
id: "entropy"
14+
binary: entropy
15+
flags: [-a]
16+
ldflags:
17+
- -X github.com/odpf/entropy/version.Version={{.Tag}}
18+
- -X github.com/odpf/entropy/version.Commit={{.FullCommit}}
19+
- -X github.com/odpf/entropy/version.BuildTime={{.Date}}
20+
goos:
21+
- darwin
22+
- linux
23+
- windows
24+
goarch:
25+
- amd64
26+
- 386
27+
- arm
28+
- arm64
29+
env:
30+
- CGO_ENABLED=0
31+
32+
archives:
33+
- replacements:
34+
darwin: macos
35+
linux: linux
36+
windows: windows
37+
386: i386
38+
amd64: x86_64
39+
format_overrides:
40+
- goos: windows
41+
format: zip
42+
43+
checksum:
44+
name_template: 'checksums.txt'
45+
46+
snapshot:
47+
name_template: "{{ .Version }}-next"
48+
49+
changelog:
50+
sort: asc
51+
filters:
52+
exclude:
53+
- '^docs:'
54+
- '^test:'
55+
- '^build:'
56+
- '^ci:'
57+
58+
dockers:
59+
- goos: linux
60+
goarch: amd64
61+
ids:
62+
- entropy
63+
dockerfile: Dockerfile
64+
image_templates:
65+
- 'docker.io/odpf/{{.ProjectName}}:latest'
66+
- 'docker.io/odpf/{{.ProjectName}}:{{ .Version }}'
67+
- 'docker.io/odpf/{{.ProjectName}}:{{ .Version }}-amd64'
68+
69+
brews:
70+
- name: entropy
71+
homepage: "https://github.com/odpf/entropy"
72+
description: "Infrastructure orchestration tool."
73+
tap:
74+
owner: odpf
75+
name: homebrew-taps
76+
license: "Apache 2.0"
77+
folder: Formula
78+
dependencies:
79+
- name: git
80+
install: |-
81+
bin.install "entropy"
82+
commit_author:
83+
name: Rohil Surana
84+

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM alpine:3.13
2+
3+
COPY entropy /usr/bin/entropy
4+
5+
RUN apk --no-cache add ca-certificates bash
6+
RUN GRPC_HEALTH_PROBE_VERSION=v0.4.5 && \
7+
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
8+
chmod +x /bin/grpc_health_probe
9+
10+
CMD ["entropy"]

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
NAME=github.com/odpf/entropy
2+
VERSION=$(shell git describe --tags --always --first-parent 2>/dev/null)
3+
COMMIT=$(shell git rev-parse --short HEAD)
4+
BUILD_TIME=$(shell date)
5+
COVERAGE_DIR=coverage
6+
BUILD_DIR=dist
7+
EXE=entropy
8+
9+
.PHONY: all build clean
10+
11+
all: clean test build
12+
13+
build:
14+
mkdir -p ${BUILD_DIR}
15+
CGO_ENABLED=0 go build -ldflags '-X "${NAME}/version.Version=${VERSION}" -X "${NAME}/version.Commit=${COMMIT}" -X "${NAME}/version.BuildTime=${BUILD_TIME}"' -o ${BUILD_DIR}/${EXE}
16+
17+
clean:
18+
rm -rf ${COVERAGE_DIR} ${BUILD_DIR}
19+
20+
download:
21+
go mod download
22+
23+
test:
24+
mkdir -p ${COVERAGE_DIR}
25+
go test ./... -coverprofile=${COVERAGE_DIR}/coverage.out
26+
27+
test-coverage: test
28+
go tool cover -html=${COVERAGE_DIR}/coverage.out

README.md

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,85 @@
1-
# entropy
1+
# Entropy
2+
3+
![test workflow](https://github.com/odpf/entropy/actions/workflows/test.yml/badge.svg)
4+
[![Go Report Card](https://goreportcard.com/badge/github.com/odpf/entropy)](https://goreportcard.com/report/github.com/odpf/entropy)
5+
[![Version](https://img.shields.io/github/v/release/odpf/entropy?logo=semantic-release)](Version)
6+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?logo=apache)](LICENSE)
7+
8+
Entropy is an extensible infrastructure orchestration and application deployment tool. Entropy provides features required for deploying and managing complex applications like resource versioning, config schema versioning, rollbacks dry runs etc.
9+
10+
## Key Features
11+
12+
- **No Dependency:** Written in Go. It compiles into a single binary with no external dependency.
13+
- **Extensible:** Entropy provides framework to easily write and deploy applications to your choice of cloud
14+
- **Runtime:** Entropy can run inside VMs or containers with minimal memory footprint.
15+
16+
## Documentation
17+
18+
Explore the following resources to get started with Entropy:
19+
20+
- [Configuration](./docs/reference/configuration.md) to get familar with configuring Entropy.
21+
22+
## Installation
23+
24+
Install Entropy on macOS, Windows, Linux, OpenBSD, FreeBSD, and on any machine.
25+
26+
#### Binary (Cross-platform)
27+
28+
Download the appropriate version for your platform from [releases](https://github.com/odpf/entropy/releases) page. Once downloaded, the binary can be run from anywhere.
29+
You don’t need to install it into a global location. This works well for shared hosts and other systems where you don’t have a privileged account.
30+
Ideally, you should install it somewhere in your PATH for easy use. `/usr/local/bin` is the most probable location.
31+
32+
#### Homebrew
33+
34+
```sh
35+
# Install entropy (requires homebrew installed)
36+
$ brew install odpf/taps/entropy
37+
38+
# Upgrade entropy (requires homebrew installed)
39+
$ brew upgrade entropy
40+
41+
# Check for installed entropy version
42+
$ entropy version
43+
```
44+
45+
## Usage
46+
47+
Entropy typically runs as a service and requires a MongoDB to store its state.
48+
49+
## Running locally
50+
51+
```sh
52+
# Clone the repo
53+
$ git clone https://github.com/odpf/entropy.git
54+
55+
# Build entropy binary file
56+
$ make build
57+
58+
# Start a MongoDB instance
59+
$ docker-compose up
60+
61+
# Run entropy on a recipe file
62+
$ ./entropy serve
63+
64+
```
65+
66+
## Running tests
67+
68+
```sh
69+
# Running all unit tests, excluding extractors
70+
$ make test
71+
```
72+
73+
## Contribute
74+
75+
Development of Entropy happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving Entropy.
76+
77+
Read our [contributing guide](https://odpf.github.io/entropy/docs/contribute/contributing) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to Entropy.
78+
79+
To help you get your feet wet and get you familiar with our contribution process, we have a list of [good first issues](https://github.com/odpf/entropy/labels/good%20first%20issue) that contain bugs which have a relatively limited scope. This is a great place to get started.
80+
81+
This project exists thanks to all the [contributors](https://github.com/odpf/entropy/graphs/contributors).
82+
83+
## License
84+
85+
Entropy is [Apache 2.0](LICENSE) licensed.

api/handlers/v1/resource.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package handlersv1
2+
3+
import (
4+
"github.com/odpf/entropy/service"
5+
)
6+
7+
type APIServer struct {
8+
container *service.Container
9+
}
10+
11+
func NewApiServer(container *service.Container) *APIServer {
12+
return &APIServer{
13+
container: container,
14+
}
15+
}

0 commit comments

Comments
 (0)