Skip to content

Commit

Permalink
Merge pull request #2 from coderj001/adding_viper_config
Browse files Browse the repository at this point in the history
Adding viper config
  • Loading branch information
coderj001 committed Feb 9, 2023
2 parents d8575a6 + 3d98b19 commit 3e7be60
Show file tree
Hide file tree
Showing 16 changed files with 715 additions and 191 deletions.
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ linters-settings:
sections:
- standard # standard packages
- default # all other imports that do not fall in any group
- prefix(github.com/coderj001/go-wallheven) # internal imports from `go-wallheven`
- prefix(github.com/coderj001/go-wallhaven) # internal imports from `go-wallhaven`
section-separators:
- newLine

Expand Down Expand Up @@ -233,7 +233,7 @@ linters-settings:
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/coderj001/go-wallheven
local-prefixes: github.com/coderj001/go-wallhaven

golint:
# minimal confidence for issues, default is 0.8
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# printed in the help command

# Name of the current directory
PROJECTNAME="go-wallheven"
PROJECTNAME="go-wallhaven"

# List of all Go-files to be processed
GOFILES=$(wildcard *.go)
Expand Down Expand Up @@ -40,7 +40,7 @@ help: Makefile

# Will install missing dependencies
.PHONY: install
## `install`: Fetch dependencies needed to run `go-wallheven`
## `install`: Fetch dependencies needed to run `go-wallhaven`
install:
echo " > Getting dependencies..."
go get -v $(get)
Expand Down Expand Up @@ -94,14 +94,14 @@ test-suite: lint test

.PHONY: run
## :
## `run`: Run `go-wallheven` in production mode
## `run`: Run `go-wallhaven` in production mode
run: export production_mode=production
run: export __BUILD_MODE__=production
run:
go run main.go $(q)

.PHONY: run-debug
## `run-debug`: Run `go-wallheven` in debug mode
## `run-debug`: Run `go-wallhaven` in debug mode
run-debug: export debug_mode=debug
run-debug: export __BUILD_MODE__=debug
run-debug:
Expand All @@ -110,7 +110,7 @@ run-debug:

.PHONY: docker-gen
## :
## `docker-gen`: Create a production docker image for `go-wallheven`
## `docker-gen`: Create a production docker image for `go-wallhaven`
docker-gen:
echo "Building docker image \`$(IMAGE):$(VERSION)\`..."
docker build --rm \
Expand All @@ -121,7 +121,7 @@ docker-gen:


.PHONY: docker-debug
## `docker-debug`: Create debug-friendly docker images for `go-wallheven`
## `docker-debug`: Create debug-friendly docker images for `go-wallhaven`
docker-debug:
echo "Building docker image \`$(IMAGE):$(VERSION)\`..."
docker build --rm=false \
Expand Down
79 changes: 20 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
# go-wallheven
# go-wallhaven

<div align="center">

[![Build Status](https://img.shields.io/github/checks-status/coderj001/go-wallheven/main?color=black&style=for-the-badge&logo=github)][github-actions]
[![Code Coverage](https://img.shields.io/codecov/c/github/coderj001/go-wallheven?color=blue&logo=codecov&style=for-the-badge)][github-actions-tests]
[![Build Status](https://img.shields.io/github/checks-status/coderj001/go-wallhaven/main?color=black&style=for-the-badge&logo=github)][github-actions]
[![Code Coverage](https://img.shields.io/codecov/c/github/coderj001/go-wallhaven?color=blue&logo=codecov&style=for-the-badge)][github-actions-tests]
[![Security: bandit](https://img.shields.io/badge/Security-GoSec-lightgrey?style=for-the-badge&logo=springsecurity)](https://github.com/securego/gosec)
[![Dependencies Status](https://img.shields.io/badge/Dependencies-Up%20to%20Date-brightgreen?style=for-the-badge&logo=dependabot)][dependabot-pulls]
[![Semantic Versioning](https://img.shields.io/badge/versioning-semantic-black?style=for-the-badge&logo=semver)][github-releases]
[![Pre-Commit Enabled](https://img.shields.io/badge/Pre--Commit-Enabled-blue?style=for-the-badge&logo=pre-commit)][precommit-config]
[![License](https://img.shields.io/github/license/coderj001/go-wallheven?color=red&style=for-the-badge)][project-license]
[![License](https://img.shields.io/github/license/coderj001/go-wallhaven?color=red&style=for-the-badge)][project-license]
[![Go v1.18](https://img.shields.io/badge/Go-%20v1.18-black?style=for-the-badge&logo=go)][gomod-file]

GoWallheven is a Go application created using https://github.com/notsatan/go-template

</div>


## Initial Setup

This section is intended to help developers and contributors get a working copy of
`go-wallheven` on their end
`go-wallhaven` on their end

<details>
<summary>
1. Clone this repository
</summary><br>

```sh
git clone https://github.com/coderj001/go-wallheven
cd go-wallheven
git clone https://github.com/coderj001/go-wallhaven
cd go-wallhaven
```
</details>

Expand All @@ -44,18 +42,18 @@ Install `golangci-lint` from the [official website][golangci-install] for your O

## Local Development

This section will guide you to setup a fully-functional local copy of `go-wallheven`
This section will guide you to setup a fully-functional local copy of `go-wallhaven`
on your end and teach you how to use it! Make sure you have installed
[golangci-lint][golangci-install] before following this section!

**Note:** This section relies on the usage of [Makefile][makefile-official]. If you
can't (or don't) use Makefile, you can follow along by running the internal commands
from [`go-wallheven's` Makefile][makefile-file] (most of which are
from [`go-wallhaven's` Makefile][makefile-file] (most of which are
OS-independent)!

### Installing dependencies

To install all dependencies associated with `go-wallheven`, run the
To install all dependencies associated with `go-wallhaven`, run the
command

```sh
Expand Down Expand Up @@ -87,7 +85,7 @@ make lint

### Running Tests

Tests in `go-wallheven` are classified as *fast* and *slow* - depending
Tests in `go-wallhaven` are classified as *fast* and *slow* - depending
on how quick they are to execute.

To selectively run tests from either test group, use the Makefile command
Expand Down Expand Up @@ -142,9 +140,9 @@ and [all tests](#running-tests) one after the other!
| `fast-tests` | Selectively run *fast* tests | NA |
| `slow-tests` | Selectively run *slow* tests | NA |
| `test-suite` | Check codestyle, run linters and **all** tests | golangci-lint |
| `run` | Run *go-wallheven* | NA |
| `docker-gen` | Create production docker image for *go-wallheven* | docker |
| `docker-debug` | Create debug-friendly docker image for *go-wallheven* | docker |
| `run` | Run *go-wallhaven* | NA |
| `docker-gen` | Create production docker image for *go-wallhaven* | docker |
| `docker-debug` | Create debug-friendly docker image for *go-wallhaven* | docker |
| `clean-docker` | Remove docker image generated by `docker-gen` | docker |

<br>
Expand Down Expand Up @@ -181,7 +179,7 @@ directory inside the project directory.
The binaries generated will be named in the format

```text
go-wallheven_<version>_<target-os>_<architecture>.<extension>
go-wallhaven_<version>_<target-os>_<architecture>.<extension>
```

The `<extension>` is optional. By default, `version` is an empty string. A custom
Expand All @@ -194,7 +192,7 @@ bash build-script.sh v1.2.1
An example of the files generated by the previous command will be;

```sh
go-wallheven_v1.2.1_windows_x86_64.exe
go-wallhaven_v1.2.1_windows_x86_64.exe
```

### Setting up Codecov
Expand All @@ -217,12 +215,12 @@ after the next run of CI pipeline!

### Using Docker

To run `go-wallheven` in a docker container, read the instructions in
To run `go-wallhaven` in a docker container, read the instructions in
[docker section](./docker).

### Running `go-wallheven`
### Running `go-wallhaven`

To run go-wallheven, use the command
To run go-wallhaven, use the command

```sh
make run
Expand Down Expand Up @@ -302,41 +300,4 @@ for repositories. [Dependabot][dependabot-link] will implicitly create the
`dependencies` label with the first pull request raised by it.

The remaining labels can be created as needed!
<br>


## Credits

<div align="center"><br>

`go-wallheven` is powered by a template generated using [`go-template`][go-template-link]

[![go-template](https://img.shields.io/badge/go--template-black?style=for-the-badge&logo=go)][go-template-link]

</div>

[makefile-file]: ./Makefile
[project-license]: ./LICENSE
[github-actions]: ../../actions
[github-releases]: ../../releases
[precommit-config]: ./.pre-commit-config.yaml
[gomod-file]: ../main/go.mod
[github-actions-tests]: ../../actions/workflows/tests.yml
[dependabot-pulls]: ../../pulls?utf8=%E2%9C%93&q=is%3Apr%20author%3Aapp%2Fdependabot

[semver-link]: https://semver.org
[pre-commit]: https://pre-commit.com
[github-repo]: https://github.com/new
[gitlab-repo]: https://gitlab.com/new
[dependabot-link]: https://dependabot.com
[githooks]: https://git-scm.com/docs/githooks
[python-install]: https://www.python.org/downloads
[release-drafter-config]: ./.github/release-drafter.yml
[makefile-official]: https://www.gnu.org/software/make
[pip-install]: https://pip.pypa.io/en/stable/installation
[codecov-docs]: https://docs.codecov.com/docs#basic-usage
[go-template-link]: https://github.com/notsatan/go-template
[golangci-install]: https://golangci-lint.run/usage/install
[cookiecutter-link]: https://github.com/cookiecutter/cookiecutter
[release-drafter]: https://github.com/marketplace/actions/release-drafter
[creating-secrets]: https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository
<br>
78 changes: 39 additions & 39 deletions build-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bin_path="./bin"
checksums="checksums.txt"

# Basename for the generated binaries - name of the project for example
basename="go-wallheven"
basename="go-wallhaven"

# Release version - can be blank if needed; if blank, will be populated by command-line
# arguments passed while running this script (if any).
Expand Down Expand Up @@ -93,41 +93,41 @@ done
echo -e ": Done"
echo -ne "Archiving Binaries"

cd "${bin_path}" || exit # Exit if `cd` fails

# Zip the windows executables
if ! command -v zip >/dev/null; then
echo -e "\tZip not found, unable to generate archives for Windows executables"
else

# Iterating through each executable file - to generate individual `.zip` files
for file in "${file_name}"**".exe"; do
zip_name="${file//.exe/}" # form name of the zip file - remove `.exe`

# Create a zip container for the file, the `-m` flag deletes the original file
zip "${zip_name}.zip" "${file}" -q -m
done
fi

# Run GZip on Linux/Mac binaries
if ! command -v gzip >/dev/null; then
echo -e "\tGZip not found, unable to generate archives"
else
for file in "${file_name}"**; do
if [[ "${file}" == "${file_name}"**".zip" ]]; then
# Skip iteration over zip files
continue
fi

gzip "${file}" -q
done
fi

# Add these checksums to the text file as well
echo "" >>"${checksums}" # append new line
for file in "${file_name}"**; do
sha256sum "$file" >>"${checksums}"
done

echo -e ": Done"
echo -e "\nExecution completed successfully \nBinaries stored in: \"${bin_path}\" \n"
# cd "${bin_path}" || exit # Exit if `cd` fails

# # Zip the windows executables
# if ! command -v zip >/dev/null; then
# echo -e "\tZip not found, unable to generate archives for Windows executables"
# else

# # Iterating through each executable file - to generate individual `.zip` files
# for file in "${file_name}"**".exe"; do
# zip_name="${file//.exe/}" # form name of the zip file - remove `.exe`

# # Create a zip container for the file, the `-m` flag deletes the original file
# zip "${zip_name}.zip" "${file}" -q -m
# done
# fi

# # Run GZip on Linux/Mac binaries
# if ! command -v gzip >/dev/null; then
# echo -e "\tGZip not found, unable to generate archives"
# else
# for file in "${file_name}"**; do
# if [[ "${file}" == "${file_name}"**".zip" ]]; then
# # Skip iteration over zip files
# continue
# fi

# gzip "${file}" -q
# done
# fi

# # Add these checksums to the text file as well
# echo "" >>"${checksums}" # append new line
# for file in "${file_name}"**; do
# sha256sum "$file" >>"${checksums}"
# done

# echo -e ": Done"
# echo -e "\nExecution completed successfully \nBinaries stored in: \"${bin_path}\" \n"
8 changes: 0 additions & 8 deletions checksums.txt

This file was deleted.

4 changes: 2 additions & 2 deletions cookiecutter-config-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# https://github.com/notsatan/go-template

cookiecutter_inputs:
project_name: "go-wallheven"
go_module_path: "github.com/coderj001/go-wallheven"
project_name: "go-wallhaven"
go_module_path: "github.com/coderj001/go-wallhaven"
license_owner: "example"
base_branch: "main"
contact_email: "[email protected]"
Expand Down
10 changes: 5 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ENV GO111MODULE=on \
GOARCH=amd64

# Create a build directory if one does not exist, and use it as the work directory
WORKDIR "/src/__go-wallheven__"
WORKDIR "/src/__go-wallhaven__"

# Selectively copy the requirements into the image - using `*go.sum` prevents failure
# if the file does not exist!
Expand All @@ -37,7 +37,7 @@ RUN go mod download
COPY . .

# Generate a binary -- custom name to avoid collisions with existing files/directories
RUN go build -v -o "../__go-wallheven_build_output__"
RUN go build -v -o "../__go-wallhaven_build_output__"


# Second stage - `scratch` for production builds, `golang:1.18` for debug builds
Expand All @@ -46,8 +46,8 @@ FROM ${final_image}
WORKDIR "/builds"

# Copy generated binary from previous image to this one - rename for readability
COPY --from=builder "/src/__go-wallheven_build_output__" \
"./go-wallheven"
COPY --from=builder "/src/__go-wallhaven_build_output__" \
"./go-wallhaven"

# Set environment variables to distuinguish between build modes
ARG build_mode=production
Expand All @@ -57,4 +57,4 @@ ENV ${build_mode}_mode=${build_mode}


# Run the binary
CMD ["./go-wallheven"]
CMD ["./go-wallhaven"]
Loading

0 comments on commit 3e7be60

Please sign in to comment.