Skip to content

Commit

Permalink
Issue 42.dockter.2 (#44)
Browse files Browse the repository at this point in the history
* #42 Initial fix

* #42 Initial fix

* #42 Initial fix

* #42 Prepare for versioned release

* #42 Prepare for versioned release

* #42 Prepare for versioned release
  • Loading branch information
docktermj authored Mar 8, 2023
1 parent d148b0e commit 7513d9a
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 44 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

-

## [0.3.6] - 2023-03-08

### Changed in 0.3.6

- Fixed issue with Cobra, Viper, and subcommand parameters, again.

## [0.3.5] - 2023-03-07

### Changed in 0.3.5
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ ARG IMAGE_FINAL=senzing/senzingapi-runtime:3.4.2
# -----------------------------------------------------------------------------

FROM ${IMAGE_GO_BUILDER} as go_builder
ENV REFRESHED_AT 2023-03-03
ENV REFRESHED_AT 2023-03-08
LABEL Name="senzing/servegrpc-builder" \
Maintainer="support@senzing.com" \
Version="0.3.5"
Version="0.3.6"

# Build arguments.

Expand Down Expand Up @@ -54,10 +54,10 @@ RUN mkdir -p /output \
# -----------------------------------------------------------------------------

FROM ${IMAGE_FINAL} as final
ENV REFRESHED_AT 2023-03-03
ENV REFRESHED_AT 2023-03-08
LABEL Name="senzing/servegrpc" \
Maintainer="support@senzing.com" \
Version="0.3.5"
Version="0.3.6"

# Copy files from repository.

Expand Down
55 changes: 27 additions & 28 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ import (
)

var (
configurationFile string
buildVersion string = "0.0.0"
buildIteration string = "0"
buildIteration string = "0"
buildVersion string = "0.3.6"
configurationFile string
defaultDatabaseUrl string = ""
defaultEngineConfigurationJson string = ""
defaultEngineLogLevel int = 0
defaultEngineModuleName string = fmt.Sprintf("initdatabase-%d", time.Now().Unix())
defaultGrpcPort int = 8258
defaultLogLevel string = "INFO"
)

func makeVersion(version string, iteration string) string {
Expand All @@ -36,33 +42,12 @@ func makeVersion(version string, iteration string) string {
var RootCmd = &cobra.Command{
Use: "servegrpc",
Short: "Start a gRPC server for the Senzing SDK API",
Long: `For more information, visit https://github.com/Senzing/servegrpc`,
Long: `
Start a gRPC server for the Senzing SDK API.
For more information, visit https://github.com/Senzing/servegrpc
`,
PreRun: func(cobraCommand *cobra.Command, args []string) {

now := time.Now()
// Define default values for input parameters.

defaultDatabaseUrl := ""
defaultEngineConfigurationJson := ""
defaultEngineLogLevel := 0
defaultEngineModuleName := fmt.Sprintf("initdatabase-%s", now.UTC())
defaultGrpcPort := 8258
defaultLogLevel := "INFO"

// Define flags for command.

cobraCommand.Flags().BoolP("enable-g2config", "", false, "enable G2Config service [SENZING_TOOLS_ENABLE_G2CONFIG]")
cobraCommand.Flags().BoolP("enable-g2configmgr", "", false, "enable G2ConfigMgr service [SENZING_TOOLS_ENABLE_G2CONFIGMGR]")
cobraCommand.Flags().BoolP("enable-g2diagnostic", "", false, "enable G2Diagnostic service [SENZING_TOOLS_ENABLE_G2DIAGNOSTIC]")
cobraCommand.Flags().BoolP("enable-g2engine", "", false, "enable G2Config service [SENZING_TOOLS_ENABLE_G2ENGINE]")
cobraCommand.Flags().BoolP("enable-g2product", "", false, "enable G2Config service [SENZING_TOOLS_ENABLE_G2PRODUCT]")
cobraCommand.Flags().Int("engine-log-level", defaultEngineLogLevel, "log level for Senzing Engine [SENZING_TOOLS_ENGINE_LOG_LEVEL]")
cobraCommand.Flags().Int("grpc-port", defaultGrpcPort, "port used to serve gRPC [SENZING_TOOLS_GRPC_PORT]")
cobraCommand.Flags().String("database-url", defaultDatabaseUrl, "URL of database to initialize [SENZING_TOOLS_DATABASE_URL]")
cobraCommand.Flags().String("engine-configuration-json", defaultEngineConfigurationJson, "JSON string sent to Senzing's init() function [SENZING_TOOLS_ENGINE_CONFIGURATION_JSON]")
cobraCommand.Flags().String("engine-module-name", defaultEngineModuleName, "the identifier given to the Senzing engine [SENZING_TOOLS_ENGINE_MODULE_NAME]")
cobraCommand.Flags().String("log-level", defaultLogLevel, "log level of TRACE, DEBUG, INFO, WARN, ERROR, FATAL, or PANIC [SENZING_TOOLS_LOG_LEVEL]")

// Integrate with Viper.

replacer := strings.NewReplacer("-", "_")
Expand Down Expand Up @@ -155,6 +140,20 @@ func Execute() {

func init() {
cobra.OnInitialize(initConfig)

// Define flags for Cobra command.

RootCmd.Flags().BoolP("enable-g2config", "", false, "Enable G2Config service [SENZING_TOOLS_ENABLE_G2CONFIG]")
RootCmd.Flags().BoolP("enable-g2configmgr", "", false, "Enable G2ConfigMgr service [SENZING_TOOLS_ENABLE_G2CONFIGMGR]")
RootCmd.Flags().BoolP("enable-g2diagnostic", "", false, "Enable G2Diagnostic service [SENZING_TOOLS_ENABLE_G2DIAGNOSTIC]")
RootCmd.Flags().BoolP("enable-g2engine", "", false, "Enable G2Config service [SENZING_TOOLS_ENABLE_G2ENGINE]")
RootCmd.Flags().BoolP("enable-g2product", "", false, "Enable G2Config service [SENZING_TOOLS_ENABLE_G2PRODUCT]")
RootCmd.Flags().Int("engine-log-level", defaultEngineLogLevel, "Log level for Senzing Engine [SENZING_TOOLS_ENGINE_LOG_LEVEL]")
RootCmd.Flags().Int("grpc-port", defaultGrpcPort, "Port used to serve gRPC [SENZING_TOOLS_GRPC_PORT]")
RootCmd.Flags().String("database-url", defaultDatabaseUrl, "URL of database to initialize [SENZING_TOOLS_DATABASE_URL]")
RootCmd.Flags().String("engine-configuration-json", defaultEngineConfigurationJson, "JSON string sent to Senzing's init() function [SENZING_TOOLS_ENGINE_CONFIGURATION_JSON]")
RootCmd.Flags().String("engine-module-name", defaultEngineModuleName, "Identifier given to the Senzing engine [SENZING_TOOLS_ENGINE_MODULE_NAME]")
RootCmd.Flags().String("log-level", defaultLogLevel, "Log level of TRACE, DEBUG, INFO, WARN, ERROR, FATAL, or PANIC [SENZING_TOOLS_LOG_LEVEL]")
}

// initConfig reads in config file and ENV variables if set.
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand All @@ -37,7 +37,7 @@ require (
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/protobuf v1.29.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
Expand Down Expand Up @@ -495,8 +495,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.29.0 h1:44S3JjaKmLEE4YIkjzexaP+NzZsudE3Zin5Njn/pYX0=
google.golang.org/protobuf v1.29.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
12 changes: 6 additions & 6 deletions package.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ ARG IMAGE_FINAL=alpine
# -----------------------------------------------------------------------------

FROM ${IMAGE_GO_BUILDER} as go_builder
ENV REFRESHED_AT 2023-03-03
ENV REFRESHED_AT 2023-03-08
LABEL Name="senzing/servegrpc-builder" \
Maintainer="support@senzing.com" \
Version="0.3.5"
Version="0.3.6"

# Build arguments.

Expand Down Expand Up @@ -57,10 +57,10 @@ RUN mkdir -p /output \
# -----------------------------------------------------------------------------

FROM ${IMAGE_FPM_BUILDER} as fpm_builder
ENV REFRESHED_AT 2023-03-03
ENV REFRESHED_AT 2023-03-08
LABEL Name="senzing/servegrpc-fpm-builder" \
Maintainer="support@senzing.com" \
Version="0.3.5"
Version="0.3.6"

# Use arguments from prior stage.

Expand Down Expand Up @@ -101,10 +101,10 @@ RUN fpm \
# -----------------------------------------------------------------------------

FROM ${IMAGE_FINAL} as final
ENV REFRESHED_AT 2023-03-03
ENV REFRESHED_AT 2023-03-08
LABEL Name="senzing/servegrpc" \
Maintainer="support@senzing.com" \
Version="0.3.5"
Version="0.3.6"

# Use arguments from prior stage.

Expand Down

0 comments on commit 7513d9a

Please sign in to comment.