Skip to content

Commit df2aa70

Browse files
committed
initial revision
Signed-off-by: Markus Blaschke <mblaschke82@gmail.com>
0 parents  commit df2aa70

File tree

14 files changed

+611
-0
lines changed

14 files changed

+611
-0
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
/azure-debug-info

.editorconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
end_of_line = lf
10+
insert_final_newline = true
11+
indent_style = space
12+
indent_size = 4
13+
14+
[Makefile]
15+
indent_style = tab
16+
17+
[*.yml]
18+
indent_size = 2
19+
20+
[*.yaml]
21+
indent_size = 2
22+
23+
[*.conf]
24+
indent_size = 2
25+
26+
[*.go]
27+
indent_style = tab
28+
indent_size = 4

.github/workflows/ci-docker.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: "CI: docker build"
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
7+
build:
8+
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Build the Docker image
14+
run: docker build . --file Dockerfile --tag webdevops/azure-debug-info:$(date +%s)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: "Release: docker"
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
tags:
8+
- '*.*.*'
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Docker meta
16+
id: docker_meta
17+
uses: crazy-max/ghaction-docker-meta@v1
18+
with:
19+
images: webdevops/azure-debug-info,quay.io/webdevops/azure-debug-info
20+
#tag-sha: true
21+
22+
- name: Set up QEMU
23+
uses: docker/setup-qemu-action@v1
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v1
27+
28+
- name: Login to DockerHub
29+
uses: docker/login-action@v1
30+
with:
31+
username: ${{ secrets.DOCKERHUB_USERNAME }}
32+
password: ${{ secrets.DOCKERHUB_TOKEN }}
33+
34+
- name: Login to Quay
35+
uses: docker/login-action@v1
36+
with:
37+
registry: quay.io
38+
username: ${{ secrets.QUAY_USERNAME }}
39+
password: ${{ secrets.QUAY_TOKEN }}
40+
41+
- name: Build and push
42+
uses: docker/build-push-action@v2
43+
with:
44+
context: .
45+
file: ./Dockerfile
46+
platforms: linux/amd64,linux/arm,linux/arm64,linux/ppc64le
47+
push: ${{ github.event_name != 'pull_request' }}
48+
tags: ${{ steps.docker_meta.outputs.tags }}
49+
labels: ${{ steps.docker_meta.outputs.labels }}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "Scheduled: docker"
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 * * 1'
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Docker meta
13+
id: docker_meta
14+
uses: crazy-max/ghaction-docker-meta@v1
15+
with:
16+
images: webdevops/azure-debug-info,quay.io/webdevops/azure-debug-info
17+
#tag-sha: true
18+
19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v1
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v1
24+
25+
- name: Login to DockerHub
26+
uses: docker/login-action@v1
27+
with:
28+
username: ${{ secrets.DOCKERHUB_USERNAME }}
29+
password: ${{ secrets.DOCKERHUB_TOKEN }}
30+
31+
- name: Login to Quay
32+
uses: docker/login-action@v1
33+
with:
34+
registry: quay.io
35+
username: ${{ secrets.QUAY_USERNAME }}
36+
password: ${{ secrets.QUAY_TOKEN }}
37+
38+
- name: Build and push
39+
uses: docker/build-push-action@v2
40+
with:
41+
context: .
42+
file: ./Dockerfile
43+
platforms: linux/amd64,linux/arm,linux/arm64,linux/ppc64le
44+
push: ${{ github.event_name != 'pull_request' }}
45+
tags: ${{ steps.docker_meta.outputs.tags }}
46+
labels: ${{ steps.docker_meta.outputs.labels }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
/azure-debug-info

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM golang:1.17 as build
2+
3+
WORKDIR /go/src/github.com/webdevops/azure-debug-info
4+
5+
# Get deps (cached)
6+
COPY ./go.mod /go/src/github.com/webdevops/azure-debug-info
7+
COPY ./go.sum /go/src/github.com/webdevops/azure-debug-info
8+
COPY ./Makefile /go/src/github.com/webdevops/azure-debug-info
9+
RUN make dependencies
10+
11+
# Compile
12+
COPY ./ /go/src/github.com/webdevops/azure-debug-info
13+
RUN make test
14+
RUN make lint
15+
RUN make build
16+
RUN ./azure-debug-info --help
17+
18+
#############################################
19+
# FINAL IMAGE
20+
#############################################
21+
FROM gcr.io/distroless/static
22+
ENV LOG_JSON=1
23+
COPY --from=build /go/src/github.com/webdevops/azure-debug-info/azure-debug-info /
24+
USER 1000:1000
25+
ENTRYPOINT ["/azure-debug-info"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 WebDevOps
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
PROJECT_NAME := azure-debug-info
2+
GIT_TAG := $(shell git describe --dirty --tags --always)
3+
GIT_COMMIT := $(shell git rev-parse --short HEAD)
4+
LDFLAGS := -X "main.gitTag=$(GIT_TAG)" -X "main.gitCommit=$(GIT_COMMIT)" -extldflags "-static"
5+
6+
FIRST_GOPATH := $(firstword $(subst :, ,$(shell go env GOPATH)))
7+
GOLANGCI_LINT_BIN := $(FIRST_GOPATH)/bin/golangci-lint
8+
9+
.PHONY: all
10+
all: build
11+
12+
.PHONY: clean
13+
clean:
14+
git clean -Xfd .
15+
16+
.PHONY: build
17+
build:
18+
CGO_ENABLED=0 go build -a -ldflags '$(LDFLAGS)' -o $(PROJECT_NAME) .
19+
20+
.PHONY: vendor
21+
vendor:
22+
go mod tidy
23+
go mod vendor
24+
go mod verify
25+
26+
.PHONY: image
27+
image: build
28+
docker build -t $(PROJECT_NAME):$(GIT_TAG) .
29+
30+
build-push-development:
31+
docker build -t webdevops/$(PROJECT_NAME):development . && docker push webdevops/$(PROJECT_NAME):development
32+
33+
.PHONY: test
34+
test:
35+
go test ./...
36+
37+
.PHONY: lint
38+
lint: $(GOLANGCI_LINT_BIN)
39+
$(GOLANGCI_LINT_BIN) run -E exportloopref,gofmt --timeout=10m
40+
41+
.PHONY: dependencies
42+
dependencies: $(GOLANGCI_LINT_BIN)
43+
44+
$(GOLANGCI_LINT_BIN):
45+
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(FIRST_GOPATH)/bin v1.32.2

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Azure debug info
2+
==============================
3+
4+
[![license](https://img.shields.io/github/license/webdevops/azure-debug-info.svg)](https://github.com/webdevops/azure-debug-info/blob/master/LICENSE)
5+
[![DockerHub](https://img.shields.io/badge/DockerHub-webdevops%2Fazure--debug--info-blue)](https://hub.docker.com/r/webdevops/azure-debug-info/)
6+
[![Quay.io](https://img.shields.io/badge/Quay.io-webdevops%2Fazure--debug--info-blue)](https://quay.io/repository/webdevops/azure-debug-info)
7+
8+
Application to get details about assigned ServicePrincipal (eg. MSI/aad-pod-identity) and
9+
lists which Azure Subscriptions and Azure ResourceGroups it can find.
10+
11+
## Features
12+
13+
- logs ServicePrincipal information
14+
- MSI/aad-pod-identity support
15+
- logs all visible Azure Subscriptions
16+
- logs all visible Azure ResourceGroups
17+
18+
Configuration
19+
-------------
20+
21+
```
22+
Usage:
23+
azure-debug-info [OPTIONS]
24+
25+
Application Options:
26+
--debug debug mode [$DEBUG]
27+
-v, --verbose verbose mode [$VERBOSE]
28+
--log.json Switch log output to json format [$LOG_JSON]
29+
--azure-environment= Azure environment name (default: AZUREPUBLICCLOUD) [$AZURE_ENVIRONMENT]
30+
31+
Help Options:
32+
-h, --help Show this help message
33+
```
34+
35+
for Azure API authentication (using ENV vars) see https://github.com/Azure/azure-sdk-for-go#authentication

0 commit comments

Comments
 (0)