Skip to content

Commit 2066cb9

Browse files
committed
Add contributing guide
1 parent cc60b48 commit 2066cb9

File tree

4 files changed

+145
-0
lines changed

4 files changed

+145
-0
lines changed

CONTRIBUTING.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Contributing guidelines
2+
3+
First off, thanks for taking the time to contribute!
4+
5+
The following is a set of guidelines for contributing to this project, which are hosted in the FOSSIL Organization on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
6+
7+
## How to become a contributor
8+
9+
### Feature Request
10+
11+
If you have an idea to improve the feature of this project, feel free to open a [new feature issue](https://github.com/fossildev/ghost-operator/issues/new?assignees=&labels=&template=feature_request.md&title=)
12+
13+
### Contributing A Code
14+
15+
Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:
16+
17+
1. Fork the repo and create your branch from `master`.
18+
2. If you've added code that should be tested, add tests.
19+
3. If you've changed APIs, update the documentation.
20+
4. Ensure the test suite passes.
21+
5. Make sure your code lints.
22+
6. Submit that pull request!
23+
24+
#### Any contributions you make will be under the Apache License 2.0
25+
26+
In short, when you submit code changes, your submissions are understood to be under the same [Apache License 2.0](LICENSE) that covers the project.
27+
28+
#### Code style
29+
30+
The coding style suggested by the Golang community is used in this project. See the [style doc](https://github.com/golang/go/wiki/CodeReviewComments) for details.
31+
32+
### Reporting Bugs
33+
34+
If you think you found a bug, please open a [new bug issue](https://github.com/fossildev/ghost-operator/issues/new?assignees=&labels=&template=bug_report.md&title=)
35+
36+
## Development Guide
37+
38+
For detail of development guide please refer to [docs/devel.md](docs/devel.md)

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ uninstall: ## Uninstall all that all performed in the $ make install.
4040

4141
##@ Development
4242

43+
.PHONY: install-sdk
44+
install-sdk: ## Installing operator-sdk
45+
@echo ....... Installing operator-sdk .......
46+
hack/install-operator-sdk.sh
47+
4348
.PHONY: dep
4449
dep: ## Update dependencies.
4550
@echo ....... Updating dependencies .......
@@ -60,6 +65,11 @@ publish: ## Push docker image to container registry.
6065
@echo ........ Pushing ghost operator image ${IMAGE_TAG} ..........
6166
- docker push ${IMAGE_TAG}
6267

68+
.PHONY: run
69+
run: ## Run operator locally
70+
@echo ....... Running operator .......
71+
operator-sdk up local
72+
6373
##@ Tests
6474

6575
.PHONY: test

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ kubectl port-forward service/example-ghost 2368
5151

5252
In this example, the Ghost App is available at http://127.0.0.1:2368 and Ghost Admin at http://127.0.0.1:2368/ghost
5353

54+
## Contributions
55+
56+
We hope you'll get involved! Read our [Contributors' Guide](CONTRIBUTING.md) for details.
57+
5458
## License
5559

5660
This project is licensed under the Apache-2.0 License - see the [LICENSE](LICENSE) for details

docs/devel.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Ghost Operator Development Guide
2+
3+
## Getting Started
4+
5+
This project is a regular [Kubernetes Operator](https://coreos.com/operators/) built using the Operator SDK. Refer to the Operator SDK documentation to understand the basic architecture of this operator.
6+
7+
### Installing the Operator SDK command line tool
8+
9+
Follow the installation guidelines from [Operator SDK GitHub page](https://github.com/operator-framework/operator-sdk) or run `make install-sdk`.
10+
11+
### Developing
12+
13+
The first step is to get a local Kubernetes instance up and running. You can use any tools as you want eg: [minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/), [docker-for-desktop](https://docs.docker.com/docker-for-mac/install/) or [kind](https://github.com/kubernetes-sigs/kind#installation-and-usage).
14+
15+
Most of development processes can be done with the `make` command. See available `make` command by executing
16+
17+
```
18+
make help
19+
```
20+
21+
Once local kubernetes has finished starting, apply the CustomResourceDefinitions:
22+
23+
```
24+
kubectl apply -f deploy/crds/ghost.fossil.or.id_ghostapps_crd.yaml
25+
```
26+
27+
Then you can get the Operator running:
28+
29+
```
30+
make run
31+
```
32+
33+
At this point, a GhostApp instance can be installed:
34+
35+
```
36+
kubectl apply -f deploy/example/ghost.fossil.or.id_v1alpha1_ghostapp_cr.yaml
37+
kubectl get ghostapp
38+
```
39+
40+
Example GhostApp status:
41+
42+
```
43+
NAME REPLICAS PHASE AGE
44+
example-ghostapp 1 Running 12s
45+
```
46+
47+
To remove the instance:
48+
49+
```
50+
kubectl delete -f deploy/example/ghost.fossil.or.id_v1alpha1_ghostapp_cr.yaml
51+
```
52+
53+
### Testing
54+
55+
Tests should be simple unit tests and/or end-to-end tests. For small changes, unit tests should be sufficient, but every new feature should be accompanied with end-to-end tests as well. Tests can be executed with:
56+
57+
```
58+
make test
59+
```
60+
61+
The whole set of end-to-end tests can be executed via:
62+
63+
```
64+
make test-e2e
65+
```
66+
67+
> NOTE: the command above requires you to build the Docker image and push to container registry. You can see instruction to build Docker image bellow.
68+
69+
Instead that, you can also run end-to-end tests locally with:
70+
71+
```
72+
make test-e2e-local
73+
```
74+
75+
### Build
76+
77+
To build Docker image of this operator can be executed with:
78+
79+
```
80+
make build
81+
```
82+
83+
> NOTE: by default, command above will build Docker image with tag `fossildev/ghost-operator:latest`. You can adjust the Docker image tag by overriding the variable `IMAGE_TAG`, like:
84+
85+
```
86+
IMAGE_TAG=docker.io/yourusername/ghost-operator:latest make build
87+
```
88+
89+
Then you can push the Docker image as usually
90+
91+
```
92+
docker push docker.io/yourusername/ghost-operator:latest
93+
```

0 commit comments

Comments
 (0)