Skip to content

Commit

Permalink
Move server binaries to /cmd directory (#2027)
Browse files Browse the repository at this point in the history
Also moves /server/main.go to /cmd/internal/serverutil, because this part
of the "server" package is fairly specific to those binaries.
  • Loading branch information
Rob Percival authored Jan 16, 2020
1 parent e07600f commit 44b7cab
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 23 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

Not yet released; provisionally v1.4.0 (may change).

### Server Binaries

The `trillian_log_server`, `trillian_log_signer` and `trillian_map_server`
binaries have moved from `github.com/google/trillian/server/` to
`github.com/google/trillian/cmd`. A subset of the `server` package has also
moved and now resides in `github.com/google/trillian/cmd/internal/serverutil`.

### Bazel Changes
Python support is disabled unless we hear that the community cares about this
being re-enabled. This was broken by a downstream change and without a signal
Expand Down
4 changes: 2 additions & 2 deletions server/main.go → cmd/internal/serverutil/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package server holds code for running Trillian servers.
package server
// Package serverutil holds code for running Trillian servers.
package serverutil

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/golang/protobuf/proto"
"github.com/google/trillian"
"github.com/google/trillian/cmd"
"github.com/google/trillian/cmd/internal/serverutil"
"github.com/google/trillian/crypto/keys/der"
"github.com/google/trillian/crypto/keyspb"
"github.com/google/trillian/extension"
Expand Down Expand Up @@ -68,8 +69,8 @@ var (
quotaDryRun = flag.Bool("quota_dry_run", false, "If true no requests are blocked due to lack of tokens")

treeGCEnabled = flag.Bool("tree_gc", true, "If true, tree garbage collection (hard-deletion) is periodically performed")
treeDeleteThreshold = flag.Duration("tree_delete_threshold", server.DefaultTreeDeleteThreshold, "Minimum period a tree has to remain deleted before being hard-deleted")
treeDeleteMinRunInterval = flag.Duration("tree_delete_min_run_interval", server.DefaultTreeDeleteMinInterval, "Minimum interval between tree garbage collection sweeps. Actual runs happen randomly between [minInterval,2*minInterval).")
treeDeleteThreshold = flag.Duration("tree_delete_threshold", serverutil.DefaultTreeDeleteThreshold, "Minimum period a tree has to remain deleted before being hard-deleted")
treeDeleteMinRunInterval = flag.Duration("tree_delete_min_run_interval", serverutil.DefaultTreeDeleteMinInterval, "Minimum interval between tree garbage collection sweeps. Actual runs happen randomly between [minInterval,2*minInterval).")

tracing = flag.Bool("tracing", false, "If true opencensus Stackdriver tracing will be enabled. See https://opencensus.io/.")
tracingProjectID = flag.String("tracing_project_id", "", "project ID to pass to stackdriver. Can be empty for GCP, consult docs for other platforms.")
Expand Down Expand Up @@ -119,10 +120,10 @@ func main() {
}

// Announce our endpoints to etcd if so configured.
unannounce := server.AnnounceSelf(ctx, client, *etcdService, *rpcEndpoint)
unannounce := serverutil.AnnounceSelf(ctx, client, *etcdService, *rpcEndpoint)
defer unannounce()
if *httpEndpoint != "" {
unannounceHTTP := server.AnnounceSelf(ctx, client, *etcdHTTPService, *httpEndpoint)
unannounceHTTP := serverutil.AnnounceSelf(ctx, client, *etcdHTTPService, *httpEndpoint)
defer unannounceHTTP()
}

Expand All @@ -148,7 +149,7 @@ func main() {
defer pprof.StopCPUProfile()
}

m := server.Main{
m := serverutil.Main{
RPCEndpoint: *rpcEndpoint,
HTTPEndpoint: *httpEndpoint,
TLSCertFile: *tlsCertFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/golang/glog"
"github.com/google/trillian/cmd"
"github.com/google/trillian/cmd/internal/serverutil"
"github.com/google/trillian/extension"
"github.com/google/trillian/log"
"github.com/google/trillian/monitoring"
Expand All @@ -43,6 +44,7 @@ import (
"google.golang.org/grpc"

tpb "github.com/google/trillian"

// Register key ProtoHandlers
_ "github.com/google/trillian/crypto/keys/der/proto"
_ "github.com/google/trillian/crypto/keys/pem/proto"
Expand Down Expand Up @@ -148,7 +150,7 @@ func main() {
// Start HTTP server (optional)
if *httpEndpoint != "" {
// Announce our endpoint to etcd if so configured.
unannounceHTTP := server.AnnounceSelf(ctx, client, *etcdHTTPService, *httpEndpoint)
unannounceHTTP := serverutil.AnnounceSelf(ctx, client, *etcdHTTPService, *httpEndpoint)
defer unannounceHTTP()
}

Expand Down Expand Up @@ -180,7 +182,7 @@ func main() {
defer pprof.StopCPUProfile()
}

m := server.Main{
m := serverutil.Main{
RPCEndpoint: *rpcEndpoint,
HTTPEndpoint: *httpEndpoint,
TLSCertFile: *tlsCertFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/golang/protobuf/proto"
"github.com/google/trillian"
"github.com/google/trillian/cmd"
"github.com/google/trillian/cmd/internal/serverutil"
"github.com/google/trillian/crypto/keys/der"
"github.com/google/trillian/crypto/keyspb"
"github.com/google/trillian/extension"
Expand Down Expand Up @@ -64,8 +65,8 @@ var (
quotaDryRun = flag.Bool("quota_dry_run", false, "If true no requests are blocked due to lack of tokens")

treeGCEnabled = flag.Bool("tree_gc", true, "If true, tree garbage collection (hard-deletion) is periodically performed")
treeDeleteThreshold = flag.Duration("tree_delete_threshold", server.DefaultTreeDeleteThreshold, "Minimum period a tree has to remain deleted before being hard-deleted")
treeDeleteMinRunInterval = flag.Duration("tree_delete_min_run_interval", server.DefaultTreeDeleteMinInterval, "Minimum interval between tree garbage collection sweeps. Actual runs happen randomly between [minInterval,2*minInterval).")
treeDeleteThreshold = flag.Duration("tree_delete_threshold", serverutil.DefaultTreeDeleteThreshold, "Minimum period a tree has to remain deleted before being hard-deleted")
treeDeleteMinRunInterval = flag.Duration("tree_delete_min_run_interval", serverutil.DefaultTreeDeleteMinInterval, "Minimum interval between tree garbage collection sweeps. Actual runs happen randomly between [minInterval,2*minInterval).")

tracing = flag.Bool("tracing", false, "If true opencensus Stackdriver tracing will be enabled. See https://opencensus.io/.")
tracingProjectID = flag.String("tracing_project_id", "", "project ID to pass to Stackdriver client. Can be empty for GCP, consult docs for other platforms.")
Expand Down Expand Up @@ -138,7 +139,7 @@ func main() {
defer pprof.StopCPUProfile()
}

m := server.Main{
m := serverutil.Main{
RPCEndpoint: *rpcEndpoint,
HTTPEndpoint: *httpEndpoint,
TLSCertFile: *tlsCertFile,
Expand Down
2 changes: 1 addition & 1 deletion examples/ct/ctmapper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ which have that domain in their subject/SAN fields.
# contents of storage/mysql/schema/storage.sql
yes | scripts/resetdb.sh

go build ./server/trillian_map_server
go build ./cmd/trillian_map_server
go build ./examples/ct/ctmapper/mapper
go build ./examples/ct/ctmapper/lookup

Expand Down
2 changes: 1 addition & 1 deletion examples/deployment/aws/terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ mkdir -p /go
export GOPATH=/go
# Install Trillian
go get github.com/google/trillian/server/trillian_log_server
go get github.com/google/trillian/cmd/trillian_log_server
# Setup the DB
cd /go/src/github.com/google/trillian
Expand Down
4 changes: 2 additions & 2 deletions examples/deployment/docker/log_server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ RUN go mod download
COPY . .

# Build the server.
RUN go get ./server/trillian_log_server
RUN go get ./cmd/trillian_log_server
# Run the licensing tool and save licenses, copyright notices, etc.
RUN go run github.com/google/go-licenses save ./server/trillian_log_server --save_path /THIRD_PARTY_NOTICES
RUN go run github.com/google/go-licenses save ./cmd/trillian_log_server --save_path /THIRD_PARTY_NOTICES

# Make a minimal image.
FROM gcr.io/distroless/base
Expand Down
4 changes: 2 additions & 2 deletions examples/deployment/docker/log_signer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ RUN go mod download
COPY . .

# Build the signer.
RUN go get ./server/trillian_log_signer
RUN go get ./cmd/trillian_log_signer
# Run the licensing tool and save licenses, copyright notices, etc.
RUN go run github.com/google/go-licenses save ./server/trillian_log_signer --save_path /THIRD_PARTY_NOTICES
RUN go run github.com/google/go-licenses save ./cmd/trillian_log_signer --save_path /THIRD_PARTY_NOTICES

# Make a minimal image.
FROM gcr.io/distroless/base
Expand Down
4 changes: 2 additions & 2 deletions examples/deployment/docker/map_server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ RUN go mod download
COPY . .

# Build the server.
RUN go get ./server/trillian_map_server
RUN go get ./cmd/trillian_map_server
# Run the licensing tool and save licenses, copyright notices, etc.
RUN go run github.com/google/go-licenses save ./server/trillian_map_server --save_path /THIRD_PARTY_NOTICES
RUN go run github.com/google/go-licenses save ./cmd/trillian_map_server --save_path /THIRD_PARTY_NOTICES

# Make a minimal image.
FROM gcr.io/distroless/base
Expand Down
6 changes: 3 additions & 3 deletions integration/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ log_prep_test() {
local log_signer_count=${2:-1}

echo "Building Trillian log code"
go build ${GOFLAGS} github.com/google/trillian/server/trillian_log_server/
go build ${GOFLAGS} github.com/google/trillian/server/trillian_log_signer/
go build ${GOFLAGS} github.com/google/trillian/cmd/trillian_log_server/
go build ${GOFLAGS} github.com/google/trillian/cmd/trillian_log_signer/

# Wipe the test database
yes | bash "${TRILLIAN_PATH}/scripts/resetdb.sh"
Expand Down Expand Up @@ -281,7 +281,7 @@ map_prep_test() {
local rpc_server_count=${1:-1}

echo "Building Trillian map code"
go build ${GOFLAGS} github.com/google/trillian/server/trillian_map_server/
go build ${GOFLAGS} github.com/google/trillian/cmd/trillian_map_server/

# Wipe the test database
yes | bash "${TRILLIAN_PATH}/scripts/resetdb.sh"
Expand Down

0 comments on commit 44b7cab

Please sign in to comment.