Skip to content

Commit

Permalink
Core functionality with CLI data/alert provider (#1)
Browse files Browse the repository at this point in the history
* Core functionality with CLI data provider

* Update usage

* Update about

* Update about
  • Loading branch information
jameshowe authored May 1, 2024
1 parent 65bfb6b commit 42df94c
Show file tree
Hide file tree
Showing 30 changed files with 1,867 additions and 813 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.vscode

# go
/vertag
/wrangler

# other
dist/
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ before:
# you may remove this if you don't need go generate
- go generate ./...
builds:
- main: ./cmd/vertag/vertag.go
- main: ./cmd/wrangler/wrangler.go
env:
- CGO_ENABLED=0
goos:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# vertag Changelog
# Wrangler Changelog
4 changes: 2 additions & 2 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# vertag Maintainers
# Wrangler Maintainers

## Maintainers

| Maintainer | GitHub ID | Affiliation |
| --------------- | --------- | ----------- |
| Anthony Gibbons | [tonipepperoniuk](https://github.com/tonipepperoniuk) | [Frontier Digital](https://github.com/gofrontier-com/) |
| James Howe | [jameshowe](https://github.com/jameshowe) | [Frontier Digital](https://github.com/gofrontier-com/) |
| Craig Anderson | [cda0](https://github.com/cda0) | [Frontier Digital](https://github.com/gofrontier-com/) |
| Fraser Davidson | [frasdav](https://github.com/frasdav) | [Frontier Digital](https://github.com/gofrontier-com/) |
| Neil Cowlin | [n-cow](https://github.com/n-cow) | [Frontier Digital](https://github.com/gofrontier-com/) |
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
build:
go build cmd/vertag/vertag.go
go build cmd/wrangler/wrangler.go

install:
go install cmd/vertag/vertag.go
go install cmd/wrangler/wrangler.go

test:
go test -v ./...
222 changes: 191 additions & 31 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
.. image:: https://pkg.go.dev/badge/github.com/gofrontier-com/vertag.svg
:target: https://pkg.go.dev/github.com/gofrontier-com/vertag
.. image:: https://github.com/gofrontier-com/vertag/actions/workflows/ci.yml/badge.svg
:target: https://github.com/gofrontier-com/vertag/actions/workflows/ci.yml
.. image:: https://pkg.go.dev/badge/github.com/gofrontier-com/wrangler.svg
:target: https://pkg.go.dev/github.com/gofrontier-com/wrangler
.. image:: https://github.com/gofrontier-com/wrangler/actions/workflows/ci.yml/badge.svg
:target: https://github.com/gofrontier-com/wrangler/actions/workflows/ci.yml

=======
Vertag
=======
========
Wrangler
========

Vertag is a command line tool to manage versions of terraform modules with semver where the modules
are stored in the same repository.
Wrangler is a command line tool for cost management.

.. contents:: Table of Contents
:local:
Expand All @@ -17,41 +16,202 @@ are stored in the same repository.
About
-----

Vertag has been built to assist with the management of terraform modules that are stored in the same
repository. It is designed to be used as part of a CI/CD pipeline.
Wrangler was built to simplify cloud cost management. In the world of distributed cloud applications,
tracking costs can be challenging. With Wrangler, teams gain control and visibility over costs by
centralising budget configuration and triggering configurable actions when thresholds are reached.

--------
Download
--------
Consuming data
##############

By default Wrangler will attempt to read data from the CLI standard input in CSV format::

timestamp, resource_id, period, value, baseline, currency, category

- **timestamp** - Date/time of charge (Unix timestamp or ISO 8601 date/time)
- **resource_id** - Unique name/ID of the resource that accrued the charge (any)
- **period** - Period the charge covers (one of [``daily``, ``monthly``])
- **value** - Amount accrued for period (decimal)
- **baseline** - Optional, if specified then allows for dynamic budgeting (decimal)
- **currency** - Optional, if specified then only budgets or rules of qualifying currencies will apply (ISO-4217 code)
- **category** - Optional, if specified can be used to group budgets / rules (any)

Data can also be consumed through a `custom provider <#providers>`_. If you wish to disable the default
behaviour then you can pass the ``--no-stdin`` flag.

Some examples of the types of use-cases Wrangler can cover with the relevant data are:

Binaries and packages of the latest stable release are available at `https://github.com/gofrontier-com/vertag/releases <https://github.com/gofrontier-com/vertag/releases>`_.
- Flagging over and underspend of resources
- Forecasting future overspend
- Detecting cost anomalies (e.g. unusual spike or reduction in cost over a defined period of time)
- Automating budgets by analysing previous spend

.. _providers:

Custom providers
################

TODO

-----
Usage
-----

.. code:: bash
$ vertag --help
Vertag is the command line tool for managing terraform modules versioning
$ wrangler --help
Wrangler is a command line tool for cost management.
Usage:
wrangler [flags]
Flags:
-c, --config string configuration file (default "/Users/jameshowe/Desktop/frontier/wrangler/.wrangler.yaml")
-h, --help help for wrangler
--no-stdin disable reading data from stdin
-v, --verbose Verbose logging
--version version for wrangler
Stream data from standard input:

.. code:: bash
$ echo "..." | wrangler
Stream data from a file:

.. code:: bash
$ cat costdata.csv | wrangler
Disable streaming:

.. code:: bash
$ wrangler --no-stdin
-------------
Configuration
-------------

Examples
--------

Monthly budget

Usage:
vertag [flags]
.. code:: yaml
---
budgets:
- resource_id: my-resource
monthly_amount: 100
...
Daily budget

.. code:: yaml
---
budgets:
- resource_id: my-resource
daily_amount: 10
...
Monthly & daily budget

.. code:: yaml
---
budgets:
- resource_id: my-resource
monthly_amount: 100
daily_amount: 10
...
Currency-specific budgets

.. code:: yaml
---
budgets:
- resource_id: my-resource
monthly_amount: 100
currency: GBP
- resource_id: my-resource
monthly_amount: 140
currency: USD
...
*note - rules will only trigger for cost data matching same currency*

Budget with local rule

.. code:: yaml
---
budgets:
- resource_id: my-resource
monthly_amount: 100
rules:
- name: nearing-budget-alert
type: percentage
value: 85
...
Budget with global rule

.. code:: yaml
---
budgets:
- resource_id: my-resource
monthly_amount: 100
rules:
- name: overspend-alert
type: percentage
value: 135
...
Budget with global rule filter

.. code:: yaml
---
budgets:
- resource_id: my-resource
monthly_amount: 100
rules:
- name: infra-overspend-alert
type: percentage
value: 135
categories:
- infra
...
*note - rule will only trigger for cost data matching same categories*

Scenarios
---------

TODO

.. _trigger-rules:

Trigger rules
-------------

Fixed amount
------------

Percentage
----------

Overrun
-------

--------
Download
--------

Flags:
-e, --author-email string Email of the commiter
-n, --author-name string Name of the commiter
-d, --dry-run Email of the commiter
-h, --help Version
-m, --modules-dir string Directory of the modules
-o, --output string Output format (default "json")
-u, --remote-url string CI Remote URL
-r, --repo string Root directory of the repo
-s, --short Print just the version number
-v, --version Version
Binaries and packages of the latest stable release are available at `https://github.com/gofrontier-com/wrangler/releases <https://github.com/gofrontier-com/wrangler/releases>`_.

------------
Contributing
------------

We welcome contributions to this repository. Please see `CONTRIBUTING.md <https://github.com/gofrontier-com/vertag/tree/main/CONTRIBUTING.md>`_ for more information.
We welcome contributions to this repository. Please see `CONTRIBUTING.md <https://github.com/gofrontier-com/wrangler/tree/main/CONTRIBUTING.md>`_ for more information.
4 changes: 2 additions & 2 deletions SUPPORT.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# vertag Support
# Wrangler Support

Thanks for trying out vertag! We're setting up an IRC channel, but please raise a GitHub issue in the meantime if you've got any questions.
Thanks for trying out Wrangler! We're setting up an IRC channel, but please raise a GitHub issue in the meantime if you've got any questions.
4 changes: 2 additions & 2 deletions cmd/vertag/vertag.go → cmd/wrangler/wrangler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"os"

"github.com/gofrontier-com/go-utils/output"
"github.com/gofrontier-com/vertag/pkg/cmd/vertag"
"github.com/gofrontier-com/wrangler/pkg/cmd/wrangler"
)

var (
Expand All @@ -14,7 +14,7 @@ var (
)

func main() {
command := vertag.NewRootCmd(version, commit, date)
command := wrangler.NewRootCmd(version, commit, date)
if err := command.Execute(); err != nil {
output.PrintlnError(err)
os.Exit(1)
Expand Down
File renamed without changes.
58 changes: 30 additions & 28 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
module github.com/gofrontier-com/vertag
module github.com/gofrontier-com/wrangler

go 1.20

require (
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be
github.com/go-git/go-git/v5 v5.11.0
github.com/gofrontier-com/go-utils v0.1.0
github.com/olekukonko/tablewriter v0.0.5
github.com/spf13/cobra v1.6.1
go.hein.dev/go-version v0.1.0
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
gopkg.in/yaml.v2 v2.4.0
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/fatih/color v1.14.1 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/rivo/uniseg v0.4.6 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rs/zerolog v1.32.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/tools v0.16.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
sigs.k8s.io/yaml v1.1.0 // indirect
github.com/spf13/viper v1.18.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 42df94c

Please sign in to comment.