Skip to content

Commit

Permalink
Initial development (#1)
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
brettcurtis and coderabbitai[bot] authored May 18, 2024
1 parent 6efa850 commit a947d56
Show file tree
Hide file tree
Showing 13 changed files with 522 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: docker
directory: .
schedule:
interval: daily

- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
18 changes: 18 additions & 0 deletions .github/workflows/add-to-projects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Add To GitHub Projects

on:
issues:
types:
- opened
pull_request:
types:
- opened

jobs:
add-to-osinfra-project:
name: Open Source Infrastructure (as Code)
uses: osinfra-io/github-misc-called-workflows/.github/workflows/[email protected]
with:
project_id: 1
secrets:
add_to_project_pat: ${{ secrets.ADD_TO_PROJECT_PAT }}
52 changes: 52 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Docker Build and Push

on:
release:
types: [published]

permissions:
contents: read
packages: write

jobs:
build-and-push:
name: Build and Push GKE Info Go
runs-on: ubuntu-latest
env:
VERSION: ${{ github.event.release.tag_name }}

steps:
# Checkout
# https://github.com/marketplace/actions/checkout

- name: Checkout
uses: actions/checkout@v4

# Docker Buildx
# https://github.com/marketplace/actions/docker-setup-buildx

- name: Set up Docker Buildx
uses: docker/[email protected]

# Docker Login
# https://github.com/marketplace/actions/docker-login

- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Build and Push Docker to GitHub Container Registry
# https://github.com/marketplace/actions/build-and-push-docker-images

- name: Build and Push GitHub Container Registry
uses: docker/[email protected]
with:
tags: |
ghcr.io/osinfra-io/gke-info-go:${{ env.VERSION }}
ghcr.io/osinfra-io/gke-info-go:latest
cache-from: type=registry,ref=ghcr.io/osinfra-io/gke-info-go:latest
cache-to: type=inline
push: true
56 changes: 56 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Docker Build and Test

on:
workflow_dispatch:
pull_request:
paths-ignore:
- "**.md"

permissions:
contents: read
packages: write

jobs:
build-and-test:
name: Build and Test
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest

steps:
# Checkout
# https://github.com/marketplace/actions/checkout

- name: Checkout
uses: actions/checkout@v4

# Docker Buildx
# https://github.com/marketplace/actions/docker-setup-buildx

- name: Set up Docker Buildx
uses: docker/[email protected]

# Docker Login
# https://github.com/marketplace/actions/docker-login

- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Build and Test Docker images
# https://github.com/marketplace/actions/build-and-push-docker-images

- name: Build
uses: docker/[email protected]
with:
tags: |
ghcr.io/osinfra-io/gke-info-go:test
cache-from: type=gha
cache-to: type=gha,mode=max
load: true

- name: Test
run: |
docker run --rm ghcr.io/osinfra-io/gke-info-go:test go version
10 changes: 10 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Dependabot Approve and Merge

on: pull_request_target

jobs:
dependabot:
name: Dependabot
uses: osinfra-io/github-misc-called-workflows/.github/workflows/[email protected]
secrets:
pr_approve_and_merge_pat: ${{ secrets.PR_APPROVE_AND_MERGE_PAT }}
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# .gitignore
# https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

# Datadog Static Analysis
static-analysis.datadog.yml


# Other Files
*.log
*.bak
*.swp
*.tmp
*.gz
*.tgz
*.tar
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-symlinks
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM golang:1.22.3

ARG DD_GIT_REPOSITORY_URL
ARG DD_GIT_COMMIT_SHA
ENV DD_GIT_REPOSITORY_URL=${DD_GIT_REPOSITORY_URL}
ENV DD_GIT_COMMIT_SHA=${DD_GIT_COMMIT_SHA}

WORKDIR /app

COPY main.go .

RUN go mod init gke-status
RUN go mod tidy
RUN go build -o main .

EXPOSE 8080

CMD ["./main"]
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# GKE Info Go

[![Docker Build and Test](https://github.com/osinfra-io/gke-info-go/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/osinfra-io/gke-info-go/actions/workflows/build-and-test.yml)

## Usage

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: gke-info-go
namespace: gke-info
spec:
replicas: 1
selector:
matchLabels:
app: gke-info-go
version: v1
template:
metadata:
labels:
app: gke-info-go
version: v1
spec:
containers:
- image: ghcr.io/osinfra-io/gke-info-go:latest
imagePullPolicy: IfNotPresent
name: gke-info-go
ports:
- containerPort: 8080
imagePullSecrets:
- name: github-container-registry-key

---

apiVersion: v1
kind: Service
metadata:
name: gke-info-go
namespace: gke-info
labels:
app: gke-info-go
spec:
ports:
- name: http
port: 8080
targetPort: 8080
selector:
app: gke-info-go

```

After deploying the above, you can check the status of the cluster by running:

```bash
kubectl port-forward --namespace gke-info $(kubectl get pod --namespace gke-info --selector="app=gke-info-go" --output jsonpath='{.items[0].metadata.name}') 8080:8080
```

Open your browser to <http://localhost:8080/cluster-name> and you should see the name of the cluster.
18 changes: 18 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module gke-status

go 1.21.1

require gopkg.in/DataDog/dd-trace-go.v1 v1.63.1

require (
github.com/DataDog/datadog-go/v5 v5.3.0 // indirect
github.com/DataDog/gostackparse v0.7.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/google/pprof v0.0.0-20230817174616-7a8ec2ada47b // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/richardartoul/molecule v1.0.1-0.20221107223329-32cfee06a052 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
)
Loading

0 comments on commit a947d56

Please sign in to comment.