Skip to content

Commit

Permalink
Merge pull request #10 from lfaoro/develop
Browse files Browse the repository at this point in the history
release-v2
  • Loading branch information
lfaoro authored Jun 3, 2019
2 parents bad70c4 + d0ec9f5 commit 5e10f59
Show file tree
Hide file tree
Showing 91 changed files with 5,986 additions and 9,116 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
idea.md
*.bind
.dockerignore
flaredns
*.cast
.vscode/
.idea/
.idea/
dist/
7 changes: 5 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ backup:
image: docker
stage: build
retry: 2
script:
script: |
# CloudFlare API key is here:
# https://dash.cloudflare.com/profile -> Global API Key -> View
- docker run -t --rm -e CF_API_KEY="$CF_API_KEY" -e CF_API_EMAIL="$CF_API_EMAIL" lfaoro/flares $CF_DOMAINS_TO_BACKUP > dns-backup-bind.txt
docker run -t --rm \
-e CF_API_KEY="$CF_API_KEY" \
-e CF_API_EMAIL="$CF_API_EMAIL" \
lfaoro/flares --all > dns-backup-bind.txt
artifacts:
untracked: true
# uncomment if needed (default is forever on gitlab.com)
Expand Down
61 changes: 61 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
builds:
- env:
- CGO_ENABLED=0
flags:
- -mod=vendor
goos:
- darwin
- linux
- freebsd
goarch:
- 386
- amd64
- arm64

checksum:
name_template: 'checksums.txt'
sign:
artifacts: checksum
snapshot:
name_template: "{{ .Tag }}"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- '^vendor:'
- '^refactor:'

brew:
# Repository to push the tap to.
github:
owner: lfaoro
name: tap

# Git author used to commit to the repository.
# Defaults are shown.
commit_author:
name: Leonardo Faoro
email: [email protected]

# Your app's homepage.
# Default is empty.
homepage: "https://github.com/lfaoro/flares"

# Your app's description.
# Default is empty.
description: "Flares is a CloudFlare DNS backup tool"

# Setting this will prevent goreleaser to actually try to commit the updated
# formula - instead, the formula file will be stored on the dist folder only,
# leaving the responsibility of publishing it to the user.
# If set to auto, the release will not be uploaded to the homebrew tap
# in case there is an indicator for prerelease in the tag e.g. v1.0.0-rc1
# Default is false.
skip_upload: false

# So you can `brew test` your formula.
# Default is empty.
test: |
system "#{bin}/flares --version"
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Contributing
When contributing to this project; first discuss the change you wish to make via issue, email, or any other method with the maintainers before submitting changes.

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ WORKDIR /build
COPY . .
RUN apk add --update git gcc
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
go install -mod vendor -gcflags "-N -l" ./cmd/...
go install -mod vendor -gcflags "-N -l" ./cmd/flares

FROM alpine:latest
RUN apk add --update --no-cache \
ca-certificates && \
update-ca-certificates
COPY --from=builder /go/bin/ /usr/local/bin/
WORKDIR /usr/local/bin/
ENTRYPOINT ["flaredns"]
ENTRYPOINT ["flares"]
42 changes: 25 additions & 17 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
MIT License
Copyright (c) 2019 Leonardo Faoro. All rights reserved.

Copyright (c) 2018 The Flares Authors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
* Neither the name of Leonardo Faoro nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 changes: 22 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
export GO111MODULE=on
APP ?= "./cmd/flares"

run:
go run cmd/flaredns/*.go vlct.io
VERSION ?= 1.0.0
EPOCH ?= 1
MAINTAINER ?= "Community"

LDFLAGS += -X "main.date=$(shell date '+%Y-%m-%d %I:%M:%S %Z')"

install:
go install ./cmd/flaredns/.
@go install -ldflags='$(LDFLAGS)' "$(APP)"

build:
go build -o flaredns cmd/flaredns/*.go
rm flaredns
@go build -o flares "$(APP)"

tag?=""
tag:
git tag -f -a $(tag) -m "$(tag)"
git push -f origin $(tag)

release:
cd cmd/flares && \
goreleaser release --rm-dist --config=../../.goreleaser.yml

reltest:
cd cmd/flares && \
goreleaser release --snapshot --rm-dist --skip-publish --config=../../.goreleaser.yml

dep:
go mod init || :
Expand All @@ -22,6 +37,6 @@ clean:

docker:
docker build -t lfaoro/flares .
docker push lfaoro/flares
#docker push lfaoro/flares

.PHONY: install
75 changes: 41 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,75 @@
# Flares 🔥

Flares is a CloudFlare DNS backup tool: every time it runs, dumps your DNS table to the screen.

Optionally exports the data into (BIND formatted) zone files.
Flares is a CloudFlare DNS backup tool, it dumps your DNS table to the screen or exports it as BIND formatted zone
files.

[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/lfaoro/flares)](https://goreportcard.com/report/github.com/lfaoro/flares)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Flfaoro%2Fflares.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Flfaoro%2Fflares?ref=badge_shield)

![flaredns_demo](static/flaredns_demo.gif)
## Quick Start

## Quick Start - docker (painless)
### [Video Tutorial](https://asciinema.org/a/NLVa6TyQzvTEhnzZDdH1q79lO)

### Docker
```bash
# CloudFlare API key is here:
# Fetch your CloudFlare API key from here:
# https://dash.cloudflare.com/profile -> Global API Key -> View

$ export CF_API_KEY=abcdef1234567890
$ export [email protected]

$ docker run -it --rm \
-e CF_API_KEY="$CF_API_KEY" \
-e CF_API_EMAIL="$CF_API_EMAIL" \
lfaoro/flares domain1.tld domain2.tld
```

## Quick Start - compile (full control)

Golang must be installed: https://golang.org/dl/

### macOS
```bash
# flaredns
$ go get -u github.com/lfaoro/flares/cmd/flaredns
$ cd $GOPATH/src/github.com/lfaoro/flares/
# flarelogs (TODO: coming soon)
# $ go get -u github.com/lfaoro/flares/cmd/flarelogs
brew install lfaoro/tap/flares
```

### Set the CF_API_KEY and CF_API_EMAIL
### Linux (soon)
```bash
curl apionic.com/flares.sh | bash
```

### Developers
> Go installer: https://golang.org/dl/
```bash
$ flaredns auth # (TODO: coming soon) opens the dashboard at https://dash.cloudflare.com/profile
$ export CF_API_KEY=abcdef1234567890
$ export [email protected]
go get -u github.com/lfaoro/flares
make install
flares -h

make test
```

### Run the app
## Examples

```bash
$ make install
$ flaredns -h
$ flaredns domain.tld
$ flaredns domain.tld --export /tmp/tables
$ flares -h

$ flares domain1.tld
;;
;; Domain: domain1.tld
;; Exported: 2019-06-03 06:31:29
...continued

$ flares --export domain1.tld domain2.tld
BIND table for domain1.tld successfully exported
BIND table for domain2.tld successfully exported
$ ls
domain1.tld domain2.tld
```

### Run backup with Gitlab-CI
## Automation

- Copy [.gitlab-ci.yml](.gitlab-ci.yml) inside an empty gitlab project
- Use the [pipeline schedule feature](https://gitlab.com/help/user/project/pipelines/schedules)
- Each task run will store backup as artifacts
### GitLab CI/CD

- Copy [.gitlab-ci.yml](.gitlab-ci.yml) inside your repo
- Use the [pipeline schedules](https://gitlab.com/help/user/project/pipelines/schedules) feature
- Each run of the task will generate a DNS backup stored as a downloadable artifact

# Contributing

Expand All @@ -67,13 +81,6 @@ $ flaredns domain.tld --export /tmp/tables
- Push to the branch `git push origin my-new-feature`
- Create a new pull request against the master branch

## TODO

- [x] use https://github.com/spf13/cobra for the CLI interface
- [x] add `all` keyword to export all the domains available in the account
- [ ] add `auth` command, automatically opens CloudFlare dashboard
- [ ] add the flarelogs command

## License

[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Flfaoro%2Fflares.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Flfaoro%2Fflares?ref=badge_large)
10 changes: 0 additions & 10 deletions cmd/flaredns/main.go

This file was deleted.

Loading

0 comments on commit 5e10f59

Please sign in to comment.