-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergey Seroukhov
authored and
Sergey Seroukhov
committed
Aug 1, 2019
1 parent
98a40c8
commit ef2db49
Showing
25 changed files
with
1,024 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/vendor | ||
/docker/Dockerfile* | ||
/docker/docker-compose*.yml | ||
/*.ps1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/dist | ||
/vendor | ||
/data/configs.test.json | ||
/data/device_configs.json | ||
/docker/id_rsa* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Go Main", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "debug", | ||
"remotePath": "", | ||
"port": 2345, | ||
"host": "127.0.0.1", | ||
"program": "${workspaceRoot}", | ||
"env": {}, | ||
"args": [], | ||
"showLog": true | ||
}, | ||
{ | ||
"name": "Go Test", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "test", | ||
"remotePath": "", | ||
"port": 2345, | ||
"host": "127.0.0.1", | ||
"program": "${file}", | ||
"env": {}, | ||
"args": [], | ||
"showLog": true | ||
} | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Gopkg.toml example | ||
# | ||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
# | ||
# [prune] | ||
# non-go = false | ||
# go-tests = true | ||
# unused-packages = true | ||
|
||
|
||
[[constraint]] | ||
branch = "master" | ||
name = "github.com/pip-services3-go/pip-services3-commons-go" | ||
|
||
[[constraint]] | ||
branch = "master" | ||
name = "github.com/pip-services3-go/pip-services3-components-go" | ||
|
||
[[constraint]] | ||
name = "github.com/stretchr/testify" | ||
version = "1.3.0" | ||
|
||
[prune] | ||
go-tests = true | ||
unused-packages = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.PHONY: all build clean install uninstall fmt simplify check run test | ||
|
||
install: | ||
@go install main.go | ||
|
||
run: install | ||
@go run main.go | ||
|
||
test: | ||
@go test ./test/... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env pwsh | ||
|
||
Set-StrictMode -Version latest | ||
$ErrorActionPreference = "Stop" | ||
|
||
# Get component data and set necessary variables | ||
$component = Get-Content -Path "component.json" | ConvertFrom-Json | ||
$repository="$($component.repository)" | ||
$buildImage="$($component.registry)/$($component.name):$($component.version)-$($component.build)-build" | ||
$container=$component.name | ||
|
||
# Get buildnumber from teamcity agent | ||
$component.build = $env:BUILD_NUMBER | ||
Set-Content -Path "component.json" -Value $($component | ConvertTo-Json) | ||
|
||
# Remove build files | ||
if (Test-Path "dist") { | ||
Remove-Item -Recurse -Force -Path "dist" | ||
} | ||
|
||
# Build docker image | ||
docker build --build-arg REPO=$repository -f docker/Dockerfile.build -t $buildImage . | ||
|
||
# Create and copy compiled files, then destroy | ||
docker create --name $container $buildImage | ||
docker cp "$($container):/go/bin" ./dist | ||
docker rm $container | ||
|
||
if (!(Test-Path ./dist) -and $env:RETRY -eq $true) { | ||
# if build failed and retries enabled run build again | ||
Write-Host "Build failed, but retries enabled, so restarting build script again..." | ||
./build.ps1 | ||
} elseif (!(Test-Path ./dist)) { | ||
Write-Host "dist folder doesn't exist in root dir. Build failed. Watch logs above." | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package build | ||
|
||
import ( | ||
cbuild "github.com/pip-services3-go/pip-services3-components-go/build" | ||
"github.com/pip-services3-go/pip-services3-components-go/cache" | ||
"github.com/pip-services3-go/pip-services3-components-go/info" | ||
"github.com/pip-services3-go/pip-services3-components-go/log" | ||
) | ||
|
||
func NewDefaultContainerFactory() *cbuild.CompositeFactory { | ||
c := cbuild.NewCompositeFactory() | ||
|
||
c.Add(info.NewDefaultInfoFactory()) | ||
c.Add(log.NewDefaultLoggerFactory()) | ||
//c.Add(count.NewDefaultCountersFactory()) | ||
//c.Add(config.NewDefaultConfigReaderFactory()) | ||
c.Add(cache.NewDefaultCacheFactory()) | ||
//c.Add(auth.NewDefaultCredentialStoreFactory()) | ||
//c.Add(connect.NewDefaultDiscoveryFactory()) | ||
c.Add(log.NewDefaultLoggerFactory()) | ||
// c.Add(test.NewDefaultTestFactory()) | ||
|
||
return c | ||
} | ||
|
||
func NewDefaultContainerFactoryFromFactories(factories ...cbuild.IFactory) *cbuild.CompositeFactory { | ||
c := NewDefaultContainerFactory() | ||
|
||
for _, factory := range factories { | ||
c.Add(factory) | ||
} | ||
|
||
return c | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env pwsh | ||
|
||
# Get component data and set necessary variables | ||
$component = Get-Content -Path "component.json" | ConvertFrom-Json | ||
$buildImage="$($component.registry)/$($component.name):$($component.version)-$($component.build)-build" | ||
$testImage="$($component.registry)/$($component.name):$($component.version)-$($component.build)-test" | ||
$rcImage="$($component.registry)/$($component.name):$($component.version)-$($component.build)-rc" | ||
|
||
# Clean up build directories | ||
Get-ChildItem -Path "." -Include "obj" -Recurse | foreach($_) { Remove-Item -Force -Recurse $_.FullName } | ||
|
||
# Remove docker images | ||
docker rmi $buildImage --force | ||
docker rmi $testImage --force | ||
docker rmi $rcImage --force | ||
docker image prune --force | ||
|
||
# Remove existed containers | ||
docker ps -a | Select-String -Pattern "Exit" | foreach($_) { docker rm $_.ToString().Split(" ")[0] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "pip-services3-container-go", | ||
"registry": "pip-services", | ||
"repository": "github.com/pip-services3-go/pip-services3-container-go", | ||
"version": "3.0.0", | ||
"build": null | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/pip-services3-go/pip-services3-commons-go/config" | ||
"github.com/pip-services3-go/pip-services3-commons-go/errors" | ||
"github.com/pip-services3-go/pip-services3-commons-go/refer" | ||
"github.com/pip-services3-go/pip-services3-commons-go/reflect" | ||
) | ||
|
||
type ComponentConfig struct { | ||
Descriptor *refer.Descriptor | ||
Type *reflect.TypeDescriptor | ||
Config *config.ConfigParams | ||
} | ||
|
||
func NewComponentConfigFromDescriptor(descriptor *refer.Descriptor, | ||
config *config.ConfigParams) *ComponentConfig { | ||
return &ComponentConfig{ | ||
Descriptor: descriptor, | ||
Config: config, | ||
} | ||
} | ||
|
||
func NewComponentConfigFromType(typ *reflect.TypeDescriptor, | ||
config *config.ConfigParams) *ComponentConfig { | ||
return &ComponentConfig{ | ||
Type: typ, | ||
Config: config, | ||
} | ||
} | ||
|
||
func ReadComponentConfigFromConfig(config *config.ConfigParams) (result *ComponentConfig, err error) { | ||
descriptor, err1 := refer.ParseDescriptorFromString(config.GetAsString("descriptor")) | ||
if err1 != nil { | ||
return nil, err1 | ||
} | ||
|
||
typ, err2 := reflect.ParseTypeDescriptorFromString(config.GetAsString("type")) | ||
if err2 != nil { | ||
return nil, err2 | ||
} | ||
|
||
if descriptor == nil && typ == nil { | ||
err = errors.NewConfigError("", "BAD_CONFIG", "Component configuration must have descriptor or type") | ||
return nil, err | ||
} | ||
|
||
return &ComponentConfig{ | ||
Descriptor: descriptor, | ||
Type: typ, | ||
Config: config, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/pip-services3-go/pip-services3-commons-go/config" | ||
) | ||
|
||
type ContainerConfig []*ComponentConfig | ||
|
||
func NewContainerConfig(components ...*ComponentConfig) ContainerConfig { | ||
return components | ||
} | ||
|
||
func NewContainerConfigFromValue(value interface{}) ContainerConfig { | ||
config := config.NewConfigParamsFromValue(value) | ||
result, _ := ReadContainerConfigFromConfig(config) | ||
return result | ||
} | ||
|
||
func ReadContainerConfigFromConfig(config *config.ConfigParams) (ContainerConfig, error) { | ||
if config == nil { | ||
return []*ComponentConfig{}, nil | ||
} | ||
|
||
names := config.GetSectionNames() | ||
result := make([]*ComponentConfig, len(names)) | ||
for i, v := range names { | ||
c := config.GetSection(v) | ||
componentConfig, err := ReadComponentConfigFromConfig(c) | ||
if err != nil { | ||
return nil, err | ||
} | ||
result[i] = componentConfig | ||
} | ||
|
||
return result, nil | ||
} |
Oops, something went wrong.