Skip to content

Commit

Permalink
Bump senzing-factory/github-action-install-senzing-api from 2 to 3 (#72)
Browse files Browse the repository at this point in the history
* Bump senzing-factory/github-action-install-senzing-api from 2 to 3

Bumps [senzing-factory/github-action-install-senzing-api](https://github.com/senzing-factory/github-action-install-senzing-api) from 2 to 3.
- [Release notes](https://github.com/senzing-factory/github-action-install-senzing-api/releases)
- [Changelog](https://github.com/senzing-factory/github-action-install-senzing-api/blob/main/CHANGELOG.md)
- [Commits](senzing-factory/github-action-install-senzing-api@v2...v3)

---
updated-dependencies:
- dependency-name: senzing-factory/github-action-install-senzing-api
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fixed issues

* Update docker image

* Disable Darwing testing

* Disable remove g2

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Dockter <michael@dockter.com>
  • Loading branch information
dependabot[bot] and docktermj authored May 9, 2024
1 parent bdf2356 commit 0e8bdc1
Show file tree
Hide file tree
Showing 18 changed files with 133 additions and 136 deletions.
1 change: 1 addition & 0 deletions .github/workflows/go-proxy-pull.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ permissions:
jobs:
go-proxy-pull:
runs-on: ubuntu-latest

steps:
- name: pull new module version
uses: andrewslotin/go-proxy-pull-action@v1.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ on: [push]
env:
DYLD_LIBRARY_PATH: /opt/senzing/g2/lib:/opt/senzing/g2/lib/macos
LD_LIBRARY_PATH: /opt/senzing/g2/lib:/opt/senzing/g2/lib/macos
SENZING_TOOLS_DATABASE_URL: 'sqlite3://na:na@/tmp/sqlite/G2C.db'
SENZING_TOOLS_DATABASE_URL: "sqlite3://na:na@/tmp/sqlite/G2C.db"

permissions:
contents: read

jobs:
go-test-darwin:
name: 'go test with Senzing: ${{ matrix.senzingapi-version }}; OS: ${{ matrix.os }}; Go: ${{ matrix.go }}'
name: "go test with Senzing: ${{ matrix.senzingapi-version }}; OS: ${{ matrix.os }}; Go: ${{ matrix.go }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
go: ['1.21']
go: ["1.21"]
os: [macos-latest]
senzingapi-version: [production-v3]
senzingapi-version: [staging-v4]

steps:
- name: checkout repository
Expand All @@ -32,7 +32,7 @@ jobs:
go-version: ${{ matrix.go }}

- name: install Senzing API
uses: senzing-factory/github-action-install-senzing-api@v2
uses: senzing-factory/github-action-install-senzing-api@v3
with:
senzingapi-version: ${{ matrix.senzingapi-version }}

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/go-test-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ on: [push]

env:
LD_LIBRARY_PATH: /opt/senzing/g2/lib
SENZING_TOOLS_DATABASE_URL: 'sqlite3://na:na@/tmp/sqlite/G2C.db'
SENZING_TOOLS_DATABASE_URL: "sqlite3://na:na@/tmp/sqlite/G2C.db"

permissions:
contents: read

jobs:
go-test-linux:
name: 'go test with Senzing: ${{ matrix.senzingapi-version }}; OS: ${{ matrix.os }}; Go: ${{ matrix.go }}'
name: "go test with Senzing: ${{ matrix.senzingapi-version }}; OS: ${{ matrix.os }}; Go: ${{ matrix.go }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
go: ['1.21']
go: ["1.21"]
os: [ubuntu-latest]
senzingapi-version: [production-v3]
senzingapi-version: [staging-v4]

steps:
- name: checkout repository
Expand All @@ -31,9 +31,9 @@ jobs:
go-version: ${{ matrix.go }}

- name: install Senzing API
uses: senzing-factory/github-action-install-senzing-api@v2
uses: senzing-factory/github-action-install-senzing-api@v3
with:
senzingapi-version: ${{ matrix.senzingapi-version }}
senzingapi-runtime-version: ${{ matrix.senzingapi-version }}

- name: copy /etc files
run: sudo cp testdata/senzing-license/g2.lic /etc/opt/senzing/g2.lic
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/go-test-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ permissions:

jobs:
go-test-windows:
name: 'go test with Senzing: ${{ matrix.senzingapi-version }}; OS: ${{ matrix.os }}; Go: ${{ matrix.go }}'
name: "go test with Senzing: ${{ matrix.senzingapi-version }}; OS: ${{ matrix.os }}; Go: ${{ matrix.go }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
go: ['1.21']
go: ["1.21"]
os: [windows-latest]
senzingapi-version: [production-v3]
senzingapi-version: [staging-v4]

steps:
- name: checkout repository
Expand All @@ -30,7 +30,7 @@ jobs:
go-version: ${{ matrix.go }}

- name: install Senzing API
uses: senzing-factory/github-action-install-senzing-api@v2
uses: senzing-factory/github-action-install-senzing-api@v3
with:
senzingapi-version: ${{ matrix.senzingapi-version }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gosec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
GO111MODULE: on

steps:
- name: checkout source
- name: checkout repository
uses: actions/checkout@v4

- name: run Gosec Security Scanner
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/make-go-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
make-go-tag:
name: make a vM.m.P tag
runs-on: ubuntu-latest

steps:
- name: checkout repository
uses: actions/checkout@v4
Expand Down
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.2.0] - 2024-05-09

### Changed in 0.2.0

- Updated to Senzing V4

## [0.1.1] - 2024-01-29

### Changed in 0.1.1
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# -----------------------------------------------------------------------------

ARG IMAGE_GO_BUILDER=golang:1.21.4-bullseye
ARG IMAGE_FINAL=senzing/senzingapi-runtime:3.8.0
ARG IMAGE_FINAL=senzing/senzingapi-runtime-staging:latest

# -----------------------------------------------------------------------------
# Stage: senzingapi_runtime
Expand Down Expand Up @@ -43,7 +43,7 @@ RUN make build
# Copy binaries to /output.

RUN mkdir -p /output \
&& cp -R ${GOPATH}/src/check-self/target/* /output/
&& cp -R ${GOPATH}/src/check-self/target/* /output/

# -----------------------------------------------------------------------------
# Stage: final
Expand Down
14 changes: 7 additions & 7 deletions checkself/checkengineconfigurationjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import (
"strings"

"github.com/senzing-garage/go-cmdhelping/option"
"github.com/senzing-garage/go-common/engineconfigurationjsonparser"
"github.com/senzing-garage/go-common/g2engineconfigurationjson"
"github.com/senzing-garage/go-helpers/engineconfigurationjson"
"github.com/senzing-garage/go-helpers/engineconfigurationjsonparser"
)

// ----------------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------------

func (checkself *CheckSelfImpl) buildAndCheckEngineConfigurationJson(ctx context.Context, reportChecks []string, reportInfo []string, reportErrors []string) ([]string, []string, []string, error) {
engineConfigurationJson, err := g2engineconfigurationjson.BuildSimpleSystemConfigurationJsonUsingEnvVars()
engineConfigurationJson, err := engineconfigurationjson.BuildSimpleSystemConfigurationJsonUsingEnvVars()
if err != nil {
reportErrors = append(reportErrors, fmt.Sprintf("Could not build engine configuration json. %s", err.Error()))
return reportChecks, reportInfo, reportErrors, nil
Expand Down Expand Up @@ -98,15 +98,15 @@ func (checkself *CheckSelfImpl) CheckEngineConfigurationJson(ctx context.Context

// Short-circuit exit.

if len(checkself.EngineConfigurationJson) == 0 {
if len(checkself.Settings) == 0 {
return checkself.buildAndCheckEngineConfigurationJson(ctx, reportChecks, reportInfo, reportErrors)
}

// Verify that JSON string is syntactically correct.

parsedEngineConfigurationJson, err := engineconfigurationjsonparser.New(checkself.EngineConfigurationJson)
parsedEngineConfigurationJson, err := engineconfigurationjsonparser.New(checkself.Settings)
if err != nil {
normalizedValue := strings.ReplaceAll(strings.ReplaceAll(checkself.EngineConfigurationJson, "\n", " "), " ", "")
normalizedValue := strings.ReplaceAll(strings.ReplaceAll(checkself.Settings, "\n", " "), " ", "")
reportChecks = append(reportChecks, fmt.Sprintf("%s = %s", option.EngineConfigurationJson.Envar, normalizedValue))
reportErrors = append(reportErrors, fmt.Sprintf("%s - %s", option.EngineConfigurationJson.Envar, err.Error()))
return reportChecks, reportInfo, reportErrors, nil
Expand All @@ -133,5 +133,5 @@ func (checkself *CheckSelfImpl) CheckEngineConfigurationJson(ctx context.Context

// Perform check.

return checkself.checkEngineConfigurationJson(ctx, checkself.EngineConfigurationJson, reportChecks, reportInfo, reportErrors)
return checkself.checkEngineConfigurationJson(ctx, checkself.Settings, reportChecks, reportInfo, reportErrors)
}
6 changes: 3 additions & 3 deletions checkself/checklicense.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ func (checkself *CheckSelfImpl) CheckLicense(ctx context.Context, reportChecks [

// Get license

g2Product, err := checkself.getG2product(ctx)
szProduct, err := checkself.getSzProduct(ctx)
if err != nil {
reportErrors = append(reportErrors, fmt.Sprintf("Could not create g2Product. Error %s", err.Error()))
reportErrors = append(reportErrors, fmt.Sprintf("Could not create szProduct. Error %s", err.Error()))
return reportChecks, reportInfo, reportErrors, nil
}

license, err := g2Product.License(ctx)
license, err := szProduct.GetLicense(ctx)
if err != nil {
reportErrors = append(reportErrors, fmt.Sprintf("Could not get license information. Error %s", err.Error()))
return reportChecks, reportInfo, reportErrors, nil
Expand Down
96 changes: 44 additions & 52 deletions checkself/checkself.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"strings"
"sync"

"github.com/senzing-garage/g2-sdk-go/g2api"
"github.com/senzing-garage/go-common/engineconfigurationjsonparser"
"github.com/senzing-garage/go-common/g2engineconfigurationjson"
"github.com/senzing-garage/go-sdk-abstract-factory/factory"
"github.com/senzing-garage/go-helpers/engineconfigurationjson"
"github.com/senzing-garage/go-helpers/engineconfigurationjsonparser"
"github.com/senzing-garage/go-sdk-abstract-factory/szfactorycreator"
"github.com/senzing-garage/sz-sdk-go/sz"
"google.golang.org/grpc"
)

Expand All @@ -20,20 +20,11 @@ import (

// CheckSelfImpl is the basic checker.
type CheckSelfImpl struct {
// g2configSingleton g2api.G2config
// g2configSyncOnce sync.Once
ConfigPath string
DatabaseUrl string
EngineConfigurationJson string
EngineLogLevel string // TODO:
ErrorLicenseDaysLeft string
ErrorLicenseRecordsPercent string
g2configmgrSingleton g2api.G2configmgr
g2configmgrSyncOnce sync.Once
g2factorySingleton factory.SdkAbstractFactory
g2factorySyncOnce sync.Once
g2productSingleton g2api.G2product
g2productSyncOnce sync.Once
GrpcDialOptions []grpc.DialOption // TODO:
GrpcUrl string // TODO:
InputUrl string // TODO:
Expand All @@ -42,9 +33,16 @@ type CheckSelfImpl struct {
ObserverUrl string // TODO:
ResourcePath string
SenzingDirectory string // TODO:
SenzingModuleName string
SenzingInstanceName string
SenzingVerboseLogging int64
Settings string
SupportPath string
szConfigManagerSingleton sz.SzConfigManager
szConfigManagerSyncOnce sync.Once
szFactorySingleton sz.SzAbstractFactory
szFactorySyncOnce sync.Once
szProductSingleton sz.SzProduct
szProductSyncOnce sync.Once
}

type ProductLicenseResponse struct {
Expand All @@ -62,7 +60,7 @@ type ProductLicenseResponse struct {
// Variables
// ----------------------------------------------------------------------------

var defaultModuleName string = "check-self"
var defaultInstanceName string = "check-self"

// ----------------------------------------------------------------------------
// Internal functions
Expand Down Expand Up @@ -95,83 +93,77 @@ func (checkself *CheckSelfImpl) getDatabaseUrl(ctx context.Context) (string, err
return checkself.DatabaseUrl, nil
}

if len(checkself.EngineConfigurationJson) == 0 {
if len(checkself.Settings) == 0 {
return "", fmt.Errorf("neither DatabaseUrl nor EngineConfigurationJson set")
}

// Pull database from Senzing engine configuration json.
// TODO: This code only returns one database. Need to handle the multi-database case.

parsedEngineConfigurationJson, err := engineconfigurationjsonparser.New(checkself.EngineConfigurationJson)
parsedEngineConfigurationJson, err := engineconfigurationjsonparser.New(checkself.Settings)
if err != nil {
return "", fmt.Errorf("unable to parse EngineConfigurationJson: %s", checkself.EngineConfigurationJson)
return "", fmt.Errorf("unable to parse EngineConfigurationJson: %s", checkself.Settings)
}

databaseUrls, err := parsedEngineConfigurationJson.GetDatabaseUrls(ctx)
if err != nil {
return "", fmt.Errorf("unable to extract databases from EngineConfigurationJson: %s", checkself.EngineConfigurationJson)
return "", fmt.Errorf("unable to extract databases from EngineConfigurationJson: %s", checkself.Settings)
}
if len(databaseUrls) == 0 {
return "", fmt.Errorf("no databases found in EngineConfigurationJson: %s", checkself.EngineConfigurationJson)
return "", fmt.Errorf("no databases found in EngineConfigurationJson: %s", checkself.Settings)
}
return databaseUrls[0], nil
}

func (checkself *CheckSelfImpl) getEngineConfigurationJson(ctx context.Context) string {
func (checkself *CheckSelfImpl) getSettings(ctx context.Context) string {
_ = ctx
var err error = nil
result := checkself.EngineConfigurationJson
result := checkself.Settings
if len(result) == 0 {
result, err = g2engineconfigurationjson.BuildSimpleSystemConfigurationJsonUsingEnvVars()
result, err = engineconfigurationjson.BuildSimpleSystemConfigurationJsonUsingEnvVars()
if err != nil {
panic(err.Error())
}
}
return result
}

func (checkself *CheckSelfImpl) getModuleName(ctx context.Context) string {
result := checkself.SenzingModuleName
func (checkself *CheckSelfImpl) getInstanceName(ctx context.Context) string {
_ = ctx
result := checkself.SenzingInstanceName
if len(result) == 0 {
result = defaultModuleName
result = defaultInstanceName
}
return result
}

// Create a G2Configmgr singleton and return it.
func (checkself *CheckSelfImpl) getG2configmgr(ctx context.Context) (g2api.G2configmgr, error) {
// Create a SzConfigManager singleton and return it.
func (checkself *CheckSelfImpl) getSzConfigManager(ctx context.Context) (sz.SzConfigManager, error) {
var err error = nil
checkself.g2configmgrSyncOnce.Do(func() {
checkself.g2configmgrSingleton, err = checkself.getG2Factory(ctx).GetG2configmgr(ctx)
if err != nil {
return
}
if checkself.g2configmgrSingleton.GetSdkId(ctx) == "base" {
err = checkself.g2configmgrSingleton.Init(ctx, checkself.getModuleName(ctx), checkself.getEngineConfigurationJson(ctx), checkself.SenzingVerboseLogging)
}
checkself.szConfigManagerSyncOnce.Do(func() {
checkself.szConfigManagerSingleton, err = checkself.getSzFactory(ctx).CreateSzConfigManager(ctx)
})
return checkself.g2configmgrSingleton, err
return checkself.szConfigManagerSingleton, err
}

func (checkself *CheckSelfImpl) getG2Factory(ctx context.Context) factory.SdkAbstractFactory {
checkself.g2factorySyncOnce.Do(func() {
checkself.g2factorySingleton = &factory.SdkAbstractFactoryImpl{}
func (checkself *CheckSelfImpl) getSzFactory(ctx context.Context) sz.SzAbstractFactory {
var err error = nil
checkself.szFactorySyncOnce.Do(func() {
checkself.szFactorySingleton, err = szfactorycreator.CreateCoreAbstractFactory(checkself.getInstanceName(ctx), checkself.getSettings(ctx), checkself.SenzingVerboseLogging, sz.SZ_INITIALIZE_WITH_DEFAULT_CONFIGURATION)
})
return checkself.g2factorySingleton
if err != nil {
panic(err.Error())
}
return checkself.szFactorySingleton
}

// Create a G2Configmgr singleton and return it.
func (checkself *CheckSelfImpl) getG2product(ctx context.Context) (g2api.G2product, error) {
// Create a SzProduct singleton and return it.
func (checkself *CheckSelfImpl) getSzProduct(ctx context.Context) (sz.SzProduct, error) {
var err error = nil
checkself.g2productSyncOnce.Do(func() {
checkself.g2productSingleton, err = checkself.getG2Factory(ctx).GetG2product(ctx)
if err != nil {
return
}
if checkself.g2configmgrSingleton.GetSdkId(ctx) == "base" {
err = checkself.g2productSingleton.Init(ctx, checkself.getModuleName(ctx), checkself.getEngineConfigurationJson(ctx), checkself.SenzingVerboseLogging)
}
checkself.szProductSyncOnce.Do(func() {
checkself.szProductSingleton, err = checkself.getSzFactory(ctx).CreateSzProduct(ctx)
})
return checkself.g2productSingleton, err
return checkself.szProductSingleton, err
}

// ----------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 0e8bdc1

Please sign in to comment.