Skip to content

Commit

Permalink
chore: move main.go into the root of the repository
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Penner <[email protected]>
  • Loading branch information
matthewpi committed May 20, 2024
1 parent 35733a6 commit d655762
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 22 deletions.
4 changes: 1 addition & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ metadata:
report_sizes: true

builds:
- dir: ./cmd
main: .
binary: caddy-gateway
- binary: caddy-gateway
env:
- CGO_ENABLED=0
goos:
Expand Down
11 changes: 5 additions & 6 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@ COPY go.sum go.sum
RUN go mod download

# Copy the go source
COPY cmd/main.go cmd/main.go
COPY main.go main.go
COPY internal/ internal/
COPY gateway.go gateway.go

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -v -trimpath -a -o manager github.com/caddyserver/gateway/cmd
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -v -trimpath -a -o caddy-gateway github.com/caddyserver/gateway

# Use distroless as minimal base image to package the manager binary
# Use distroless as minimal base image to package the caddy-gateway binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
COPY --from=builder /workspace/caddy-gateway .
USER 65532:65532

ENTRYPOINT ["/manager"]
ENTRYPOINT ["/caddy-gateway"]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ lint-fix: ## Run golangci-lint linter and perform fixes

.PHONY: build
build: manifests generate fmt vet ## Build manager binary.
go build -o bin/manager cmd/main.go
go build -o bin/manager ./main.go

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run -v -trimpath ./cmd/main.go
go run -v -trimpath ./main.go

# If you wish to build the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
Expand Down
2 changes: 1 addition & 1 deletion internal/caddy/caddy.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/caddyserver/gateway"
gateway "github.com/caddyserver/gateway/internal"
caddyv2 "github.com/caddyserver/gateway/internal/caddyv2"
"github.com/caddyserver/gateway/internal/caddyv2/caddyhttp"
"github.com/caddyserver/gateway/internal/caddyv2/caddytls"
Expand Down
2 changes: 1 addition & 1 deletion internal/caddy/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

"github.com/caddyserver/gateway"
gateway "github.com/caddyserver/gateway/internal"
caddy "github.com/caddyserver/gateway/internal/caddyv2"
"github.com/caddyserver/gateway/internal/caddyv2/caddyhttp"
"github.com/caddyserver/gateway/internal/caddyv2/caddyhttp/headers"
Expand Down
2 changes: 1 addition & 1 deletion internal/caddy/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/caddyserver/gateway"
gateway "github.com/caddyserver/gateway/internal"
"github.com/caddyserver/gateway/internal/caddyv2/caddytls"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

"github.com/caddyserver/gateway"
gateway "github.com/caddyserver/gateway/internal"
)

// Add RBAC permissions to get CRDs, so we can verify that the gateway-api CRDs
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/caddyserver/gateway"
gateway "github.com/caddyserver/gateway/internal"
"github.com/caddyserver/gateway/internal/caddy"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/controller/gateway_class.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"

"github.com/caddyserver/gateway"
gateway "github.com/caddyserver/gateway/internal"
)

// +kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=gatewayclasses,verbs=get;list;watch
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

"github.com/caddyserver/gateway"
gateway "github.com/caddyserver/gateway/internal"
)

func isAttachable(_ context.Context, gw *gatewayv1.Gateway, route metav1.Object, parents []gatewayv1.RouteParentStatus) bool {
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/route_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/caddyserver/gateway"
gateway "github.com/caddyserver/gateway/internal"
"github.com/caddyserver/gateway/internal/routechecks"
)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/routechecks/hostnames.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package routechecks
import (
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"

"github.com/caddyserver/gateway"
gateway "github.com/caddyserver/gateway/internal"
)

func computeHosts[T ~string](gw *gatewayv1.Gateway, hostnames []T) []string {
Expand Down
2 changes: 1 addition & 1 deletion internal/routechecks/route_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/caddyserver/gateway"
gateway "github.com/caddyserver/gateway/internal"
)

type HTTPRouteInput struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/routechecks/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

"github.com/caddyserver/gateway"
gateway "github.com/caddyserver/gateway/internal"
)

func CheckAgainstCrossNamespaceBackendReferences(input Input) (bool, error) {
Expand Down
File renamed without changes.

0 comments on commit d655762

Please sign in to comment.