Skip to content

Commit

Permalink
restructure repo
Browse files Browse the repository at this point in the history
  • Loading branch information
scotwells committed Dec 13, 2024
1 parent efcb04a commit 8e3d1ec
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 46 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Build and Publish Docker Image

on:
push:
branches:
- main
# branches:
# - main
pull_request:

jobs:
Expand All @@ -15,6 +15,13 @@ jobs:
id-token: write

runs-on: ubuntu-latest

# Define the services that should be built.
strategy:
matrix:
service:
- datum-authorization-webhook

steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -30,7 +37,7 @@ jobs:
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/datum-cloud/datum
images: ghcr.io/datum-cloud/${{ matrix.service }}
tags: |
type=schedule
type=ref,event=branch
Expand All @@ -40,11 +47,19 @@ jobs:
type=semver,pattern={{major}}
type=sha
- name: Build and push Docker image
- name: Build ${{ matrix.service }}
id: push
uses: docker/[email protected]
with:
context: .
file: cmd/${{ matrix.service }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/datum-cloud/${{ matrix.service }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
6 changes: 3 additions & 3 deletions Dockerfile → cmd/datum-authorization-webhook/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ RUN go mod download
COPY . .

# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o datum .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o datum-authorization-webhook ./cmd/datum-authorization-webhook

# Use a minimal image for the final container
FROM gcr.io/distroless/static
WORKDIR /app
COPY --from=builder /app/datum .
ENTRYPOINT ["/app/datum"]
COPY --from=builder /app/datum-authorization-webhook .
ENTRYPOINT ["/app/datum-authorization-webhook"]
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package cmd
package app

import (
"context"
"fmt"

"buf.build/gen/go/datum-cloud/iam/grpc/go/datum/iam/v1alpha/iamv1alphagrpc"
"go.datumapis.com/datum/internal/authorization-webhook/internal/iam"
authwebhook "go.datumapis.com/datum/internal/authorization-webhook/internal/webhook"
"go.datumapis.com/datum/cmd/datum-authorization-webhook/app/internal/iam"
authwebhook "go.datumapis.com/datum/cmd/datum-authorization-webhook/app/internal/webhook"

"github.com/spf13/cobra"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cmd
package app

import "github.com/spf13/cobra"

func Webhook() *cobra.Command {
func NewWebhook() *cobra.Command {
cmd := &cobra.Command{
Use: "authorization-webhook",
Short: "An authorization webhook backed by the Datum IAM service",
Expand Down
15 changes: 15 additions & 0 deletions cmd/datum-authorization-webhook/webhook.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

import (
"fmt"
"os"

"go.datumapis.com/datum/cmd/datum-authorization-webhook/app"
)

func main() {
if err := app.NewWebhook().Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
19 changes: 0 additions & 19 deletions internal/cmd/root.go

This file was deleted.

15 changes: 0 additions & 15 deletions main.go

This file was deleted.

0 comments on commit 8e3d1ec

Please sign in to comment.