Skip to content

Commit

Permalink
feat: release v0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
srevinsaju committed Sep 28, 2021
0 parents commit f576cf8
Show file tree
Hide file tree
Showing 24 changed files with 1,743 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/cmd/go-cat/infra.json
/cmd/go-cat/go-cat
/.idea
/cmd/go-cat/.go-cat.queue.db.json
34 changes: 34 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2021 Sorcero, Inc.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

image: golang:latest
variables:
REPO_NAME: gitlab.com/sorcero/community/go-cat

before_script:
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
- cd $GOPATH/src/$REPO_NAME

stages:
- test
- build
- deploy

format:
stage: test
script:
- go fmt $(go list ./... | grep -v /vendor/)
- go vet $(go list ./... | grep -v /vendor/)

compile:
stage: build
script:
- cd cmd/go-cat
- go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/go-cat
artifacts:
paths:
- go-cat
373 changes: 373 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

94 changes: 94 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
go-cat
======
`go-cat` is a Go command line tool which helps to keep a track
of infrastructure across multiple clouds in a single git repository.
It helps to add multiple components with their API endpoints, with the
time it was last deployed on, and the commit SHA. This makes tracking
huge infrastructure trees easier on the long run.

The project is in early alpha, and under active development.

Installation ✨
---------------

```bash
cd cmd/go-cat
go build .
./go-cat --help
```

Usage 🤔
--------

The `go-cat upsert` command mutates the json file and regenerates a new
`README.md` with a markdown table containing information. API consumers
can make use of `infra.json` to dynamically check from command line about the
information about the latest deployment.

The `go-cat add` command adds infrastructure to queue, which can be then pushed to git
repository using `go-cat push`. This feature is useful for batch updates to
infrastructure, in one transaction.

Workflow 🔧
----------
A general implementation workflow in an infrastructure repository
would be
```bash

# do infrastructure changes
terraform apply

terraform output -format=json > infra_info.json

go-cat upsert \
--name company1-api1 --commit-sha=1c32fb0 \
--cloud=GCP --cloud-project-id=my-awesome-project-41313 \
--type=run.googleapis.com \
--subsystem=company1 \
--deployment-link=https://example.com \
--git.url=https://gitlab.com/something/xxx.git \
--git.username=username \
--git.password=mysupersecretpassword

```

The `git.url`, `git.username` and `git.password` can also be configured using
environment variables `GO_CAT_GIT_URL`, `GO_CAT_GIT_USERNAME`, `GO_CAT_GIT_PASSWORD`
respectively.

To remove any component from the infrastructure catalog, `go-cat` now
supports a `remove` subcommand, which helps us remove components using all
the power of regex.

```bash
# to remove only one component
go-cat remove --id 'gcp/project1/subsystem/component'
# this will remove component named 'component', belonging to 'subsystem', in project 'project1' deployed on GCP.

# to remove all components, subsystems, projects of a cloud
go-cat remove --id 'gcp/*'

# to remove all components which are called 'api' across all clouds
go-cat remove --id '.*/api'

# to remove a specific subsystem across all cloud projects
go-cat remove --id 'gcp/.*/subsystem/component'
```

Code Quality 🔍
------------
Make sure you adhere to Go formatting guidelines when
contributing to this repository

```bash
go fmt
```

Why go? 🐭
----------
Because, its just one binary, and hence a happier DevOps Engineer.
Read more [here](https://medium.com/@pavanbelagatti/go-lang-devops-a-match-made-in-heaven-a24d5de45e26)

License ⚖️
-----------
This software is licensed under the [Mozilla Public License v2.0](./LICENSE)
Loading

0 comments on commit f576cf8

Please sign in to comment.