diff --git a/Dockerfile b/Dockerfile index 474deb58..0017c62a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,15 +32,15 @@ COPY pkg ./pkg COPY tools ./tools COPY hack ./hack # Build the executable binary -RUN GOOS=linux GOARCH=amd64 go build -ldflags "$(hack/get-ldflags.sh)" -o out ./... +RUN GOOS=linux GOARCH=amd64 go build -ldflags "$(hack/get-ldflags.sh)" -o out ./cmd/placeholder-name-server/... FROM alpine:latest # Install CA certs and some tools for debugging RUN apk --update --no-cache add ca-certificates bash curl WORKDIR /root/ # Copy the binary from the build-env stage -COPY --from=build-env /work/out/placeholder-name placeholder-name +COPY --from=build-env /work/out/placeholder-name-server placeholder-name-server # Document the port EXPOSE 443 # Set the command -CMD ["./placeholder-name"] +CMD ["./placeholder-name-server"] diff --git a/cmd/placeholder-name/main.go b/cmd/placeholder-name-server/main.go similarity index 76% rename from cmd/placeholder-name/main.go rename to cmd/placeholder-name-server/main.go index b816ad36..35562733 100644 --- a/cmd/placeholder-name/main.go +++ b/cmd/placeholder-name-server/main.go @@ -14,7 +14,7 @@ import ( "k8s.io/component-base/logs" "k8s.io/klog/v2" - "github.com/suzerain-io/placeholder-name/cmd/placeholder-name/app" + "github.com/suzerain-io/placeholder-name/internal/server" ) func main() { @@ -25,7 +25,7 @@ func main() { ctx := genericapiserver.SetupSignalContext() - if err := app.New(ctx, os.Args[1:], os.Stdout, os.Stderr).Run(); err != nil { + if err := server.New(ctx, os.Args[1:], os.Stdout, os.Stderr).Run(); err != nil { klog.Fatal(err) } } diff --git a/deploy/deployment.yaml b/deploy/deployment.yaml index 1b93a647..61d584e8 100644 --- a/deploy/deployment.yaml +++ b/deploy/deployment.yaml @@ -60,7 +60,7 @@ spec: #@ end imagePullPolicy: IfNotPresent command: - - ./placeholder-name + - ./placeholder-name-server args: - --config=/etc/config/placeholder-name.yaml - --downward-api-path=/etc/podinfo diff --git a/cmd/placeholder-name/app/app.go b/internal/server/server.go similarity index 96% rename from cmd/placeholder-name/app/app.go rename to internal/server/server.go index d6d6c6b9..442e4fd5 100644 --- a/cmd/placeholder-name/app/app.go +++ b/internal/server/server.go @@ -3,8 +3,8 @@ Copyright 2020 VMware, Inc. SPDX-License-Identifier: Apache-2.0 */ -// Package app is the command line entry point for placeholder-name. -package app +// Package server is the command line entry point for placeholder-name-server. +package server import ( "context" @@ -39,7 +39,7 @@ import ( "github.com/suzerain-io/placeholder-name/pkg/config" ) -// App is an object that represents the placeholder-name application. +// App is an object that represents the placeholder-name-server application. type App struct { cmd *cobra.Command @@ -68,8 +68,8 @@ func New(ctx context.Context, args []string, stdout, stderr io.Writer) *App { a.recommendedOptions.Etcd = nil // turn off etcd storage because we don't need it yet cmd := &cobra.Command{ - Use: `placeholder-name`, - Long: `placeholder-name provides a generic API for mapping an external + Use: `placeholder-name-server`, + Long: `placeholder-name-server provides a generic API for mapping an external credential from somewhere to an internal credential to be used for authenticating to the Kubernetes API.`, RunE: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/placeholder-name/app/app_test.go b/internal/server/server_test.go similarity index 89% rename from cmd/placeholder-name/app/app_test.go rename to internal/server/server_test.go index 849925da..5ae9abe8 100644 --- a/cmd/placeholder-name/app/app_test.go +++ b/internal/server/server_test.go @@ -3,7 +3,7 @@ Copyright 2020 VMware, Inc. SPDX-License-Identifier: Apache-2.0 */ -package app +package server import ( "bytes" @@ -17,19 +17,19 @@ import ( ) const knownGoodUsage = ` -placeholder-name provides a generic API for mapping an external +placeholder-name-server provides a generic API for mapping an external credential from somewhere to an internal credential to be used for authenticating to the Kubernetes API. Usage: - placeholder-name [flags] + placeholder-name-server [flags] Flags: --cluster-signing-cert-file string path to cluster signing certificate --cluster-signing-key-file string path to cluster signing private key -c, --config string path to configuration file (default "placeholder-name.yaml") --downward-api-path string path to Downward API volume mount (default "/etc/podinfo") - -h, --help help for placeholder-name + -h, --help help for placeholder-name-server --log-flush-frequency duration Maximum number of seconds between log flushes (default 5s) ` @@ -52,7 +52,7 @@ func TestCommand(t *testing.T) { { name: "OneArgFails", args: []string{"tuna"}, - wantErr: `unknown command "tuna" for "placeholder-name"`, + wantErr: `unknown command "tuna" for "placeholder-name-server"`, }, { name: "ShortConfigFlagSucceeds", @@ -68,7 +68,7 @@ func TestCommand(t *testing.T) { "--config", "some/path/to/config.yaml", "tuna", }, - wantErr: `unknown command "tuna" for "placeholder-name"`, + wantErr: `unknown command "tuna" for "placeholder-name-server"`, }, } for _, test := range tests { diff --git a/cmd/placeholder-name/app/testdata/podinfo/labels b/internal/server/testdata/podinfo/labels similarity index 100% rename from cmd/placeholder-name/app/testdata/podinfo/labels rename to internal/server/testdata/podinfo/labels diff --git a/cmd/placeholder-name/app/testdata/podinfo/namespace b/internal/server/testdata/podinfo/namespace similarity index 100% rename from cmd/placeholder-name/app/testdata/podinfo/namespace rename to internal/server/testdata/podinfo/namespace diff --git a/cmd/placeholder-name/app/testdata/valid-config.yaml b/internal/server/testdata/valid-config.yaml similarity index 100% rename from cmd/placeholder-name/app/testdata/valid-config.yaml rename to internal/server/testdata/valid-config.yaml