Skip to content

Commit

Permalink
Initial v1 work. Can detect all hard-coded apiVersions in static files
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Suderman committed Mar 25, 2020
1 parent 4730bc1 commit dff5405
Show file tree
Hide file tree
Showing 22 changed files with 1,518 additions and 8 deletions.
88 changes: 88 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
version: 2.1

orbs:
rok8s-scripts: fairwinds/rok8s-scripts@11

executors:
golang-exec:
docker:
- image: circleci/golang:1.14-stretch

references:
install_goreleaser: &install_goreleaser
run:
name: Install GoReleaser
command: |
curl -fsSLo goreleaser.deb https://github.com/goreleaser/goreleaser/releases/download/v0.94.0/goreleaser_amd64.deb
echo "8dbad6683d6fc9367e637e6eed8e01a0d63c9660 goreleaser.deb" | sha1sum -c
sudo dpkg -i goreleaser.deb
rm goreleaser.deb
e2e_config: &e2e_config
command_runner_image: quay.io/reactiveops/ci-images:v11-stretch
executor: golang-exec
pre_script: e2e/pre.sh
store-test-results: /tmp/test-results
script: e2e/test.sh
requires:
- test
filters:
branches:
only: /.*/
tags:
ignore: /.*/

jobs:
test:
working_directory: /go/src/github.com/fairwindsops/api-version-finder

docker:
- image: circleci/golang:1.14
environment:
GO111MODULE: "on"
steps:
- checkout
- run: go mod download && go mod verify
- run: go test -v ./... -coverprofile=coverage.txt -covermode=atomic
- run: bash <(curl -s https://codecov.io/bash)

release:
working_directory: /go/src/github.com/fairwindsops/api-version-finder
docker:
- image: circleci/golang:1.13
environment:
GO111MODULE: "on"
steps:
- checkout
- run: go mod download && go mod verify
- *install_goreleaser
- run: goreleaser

workflows:
version: 2
test-and-release:
jobs:
- test:
filters:
branches:
only: /.*/
#- rok8s-scripts/kubernetes_e2e_tests:
# name: e2e test kube 1.15.7
# kind_node_image: >-
# "kindest/node:v1.15.7@sha256:e2df133f80ef633c53c0200114fce2ed5e1f6947477dbc83261a6a921169488d"
# <<: *e2e_config
#- rok8s-scripts/kubernetes_e2e_tests:
# name: e2e test kube 1.16.4
# kind_node_image: >-
# "kindest/node:v1.16.4@sha256:b91a2c2317a000f3a783489dfb755064177dbc3a0b2f4147d50f04825d016f55"
# <<: *e2e_config
#- rok8s-scripts/kubernetes_e2e_tests:
# name: e2e test kube 1.17.0
# kind_node_image: >-
# "kindest/node:v1.17.0@sha256:9512edae126da271b66b990b6fff768fbb7cd786c7d39e86bdf55906352fdf62"
# <<: *e2e_config
- release:
filters:
branches:
ignore: /.*/
tags:
only: /.*/
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/api-version-finder
vendor
dist

# Output of the go coverage tool
*.out
cover-report.html
coverage.txt
cover.html

/rbac-lookup
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-json
- id: detect-aws-credentials
- id: detect-private-key
- id: trailing-whitespace
- id: check-added-large-files
args: ['--maxkb=150']
- id: check-byte-order-marker
- id: check-merge-conflict
- id: check-symlinks
- id: end-of-file-fixer
exclude: "pkg/server/testdata/notwriteable"
- id: check-executables-have-shebangs
- id: flake8
- id: no-commit-to-branch
args: [--branch, master]
- id: pretty-format-json
args: ['--autofix']
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 1.11.2
hooks:
- id: forbid-binary
- id: shellcheck
- id: git-check
- repo: https://github.com/dnephin/pre-commit-golang.git
rev: v0.3.5
hooks:
- id: go-fmt
- id: golangci-lint
- id: go-vet
- id: go-unit-tests
- id: go-build
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @sudermanjr
74 changes: 74 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
63 changes: 63 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Contributing

Issues, whether bugs, tasks, or feature requests are essential for keeping api-version-finder great. We believe it should be as easy as possible to contribute changes that get things working in your environment. There are a few guidelines that we need contributors to follow so that we can keep on top of things.

## Code of Conduct

This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). Please review this document before contributing to this project.

## Sign the CLA
Before you can contribute, you will need to sign the [Contributor License Agreement](https://cla-assistant.io/fairwindsops/api-version-finder).

## Project Structure

### CLI
api-version-finder is a relatively simple cobra cli tool that helps deal with deprecated api versions in Kubernetes. The [/cmd](/cmd) folder contains the flags and other cobra config, while the [/pkg](/pkg) folder has the various packages.

### API

This contains the various structs and helper functions to deal with Kubernetes objects and their apiVersions. It assumes that any file we care about will have a `Kind` and an `apiVersion`.

### Finder

This package is for dealing with a set of static files and analyzing the apiVersions in them. It can search through a directory and find any files that conform to the specifications of the versions package.

## Getting Started

We label issues with the ["good first issue" tag](https://github.com/FairwindsOps/api-version-finder/labels/good%20first%20issue) if we believe they'll be a good starting point for new contributors. If you're interested in working on an issue, please start a conversation on that issue, and we can help answer any questions as they come up.

## Setting Up Your Development Environment
### Prerequisites
* A properly configured Golang environment with Go 1.13 or higher

### Installation
* Clone the project with `go get github.com/fairwindsops/api-version-finder`
* Change into the api-version-finder directory which is installed at `$GOPATH/src/github.com/fairwindsops/api-version-finder`
* Use `make build` to build the binary locally.
* Use `make test` to run the tests and generate a coverage report.

## Creating a New Issue

If you've encountered an issue that is not already reported, please create an issue that contains the following:

- Clear description of the issue
- Steps to reproduce it
- Appropriate labels

## Creating a Pull Request

Each new pull request should:

- Reference any related issues
- Add tests that show the issues have been solved
- Pass existing tests and linting
- Contain a clear indication of if they're ready for review or a work in progress
- Be up to date and/or rebased on the master branch

## Creating a new release

Push a new annotated tag. This tag should contain a changelog of pertinent changes. Goreleaser will take care of the rest.

## Pre-commit

This repo contains a pre-commit file for use with [pre-commit](https://pre-commit.com/). Just run `pre-commit install` and you will have the hooks.
Loading

0 comments on commit dff5405

Please sign in to comment.