Skip to content

Commit

Permalink
Add contributing guide
Browse files Browse the repository at this point in the history
  • Loading branch information
prksu committed Jan 2, 2020
1 parent cc60b48 commit 2066cb9
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 0 deletions.
38 changes: 38 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Contributing guidelines

First off, thanks for taking the time to contribute!

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.

## How to become a contributor

### Feature Request

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=)

### Contributing A Code

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:

1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
5. Make sure your code lints.
6. Submit that pull request!

#### Any contributions you make will be under the Apache License 2.0

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.

#### Code style

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.

### Reporting Bugs

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=)

## Development Guide

For detail of development guide please refer to [docs/devel.md](docs/devel.md)
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ uninstall: ## Uninstall all that all performed in the $ make install.

##@ Development

.PHONY: install-sdk
install-sdk: ## Installing operator-sdk
@echo ....... Installing operator-sdk .......
hack/install-operator-sdk.sh

.PHONY: dep
dep: ## Update dependencies.
@echo ....... Updating dependencies .......
Expand All @@ -60,6 +65,11 @@ publish: ## Push docker image to container registry.
@echo ........ Pushing ghost operator image ${IMAGE_TAG} ..........
- docker push ${IMAGE_TAG}

.PHONY: run
run: ## Run operator locally
@echo ....... Running operator .......
operator-sdk up local

##@ Tests

.PHONY: test
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ kubectl port-forward service/example-ghost 2368

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

## Contributions

We hope you'll get involved! Read our [Contributors' Guide](CONTRIBUTING.md) for details.

## License

This project is licensed under the Apache-2.0 License - see the [LICENSE](LICENSE) for details
93 changes: 93 additions & 0 deletions docs/devel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Ghost Operator Development Guide

## Getting Started

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.

### Installing the Operator SDK command line tool

Follow the installation guidelines from [Operator SDK GitHub page](https://github.com/operator-framework/operator-sdk) or run `make install-sdk`.

### Developing

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).

Most of development processes can be done with the `make` command. See available `make` command by executing

```
make help
```

Once local kubernetes has finished starting, apply the CustomResourceDefinitions:

```
kubectl apply -f deploy/crds/ghost.fossil.or.id_ghostapps_crd.yaml
```

Then you can get the Operator running:

```
make run
```

At this point, a GhostApp instance can be installed:

```
kubectl apply -f deploy/example/ghost.fossil.or.id_v1alpha1_ghostapp_cr.yaml
kubectl get ghostapp
```

Example GhostApp status:

```
NAME REPLICAS PHASE AGE
example-ghostapp 1 Running 12s
```

To remove the instance:

```
kubectl delete -f deploy/example/ghost.fossil.or.id_v1alpha1_ghostapp_cr.yaml
```

### Testing

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:

```
make test
```

The whole set of end-to-end tests can be executed via:

```
make test-e2e
```

> 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.
Instead that, you can also run end-to-end tests locally with:

```
make test-e2e-local
```

### Build

To build Docker image of this operator can be executed with:

```
make build
```

> 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:
```
IMAGE_TAG=docker.io/yourusername/ghost-operator:latest make build
```

Then you can push the Docker image as usually

```
docker push docker.io/yourusername/ghost-operator:latest
```

0 comments on commit 2066cb9

Please sign in to comment.