rewrite
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
0678e72908
commit
78f0ae14d7
2
Makefile
2
Makefile
@ -1,6 +1,6 @@
|
||||
.PHONY: build
|
||||
build:
|
||||
go build -o bin/app -mod=readonly ./main.go
|
||||
go build -o bin/app -mod=readonly git.unistack.org/unistack-org/pkgdash/cmd/pkgdash
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
|
@ -2,34 +2,181 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
appconfig "git.unistack.org/unistack-org/pkgdash/internal/config"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/handler"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/service/client_git"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v4"
|
||||
yamlcodec "go.unistack.org/micro-codec-yaml/v4"
|
||||
envconfig "go.unistack.org/micro-config-env/v4"
|
||||
fileconfig "go.unistack.org/micro-config-file/v4"
|
||||
vaultconfig "go.unistack.org/micro-config-vault/v4"
|
||||
zlogger "go.unistack.org/micro-logger-zerolog/v4"
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
healthhandler "go.unistack.org/micro-server-http/v4/handler/health"
|
||||
meterhandler "go.unistack.org/micro-server-http/v4/handler/meter"
|
||||
"go.unistack.org/micro/v4"
|
||||
"go.unistack.org/micro/v4/config"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/unistack-org/pkgdash/service"
|
||||
"go.unistack.org/micro/v4/options"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
rutil "go.unistack.org/micro/v4/util/reflect"
|
||||
)
|
||||
|
||||
const appName = "pkgdash"
|
||||
|
||||
var (
|
||||
BuildDate string = "now" // filled when build
|
||||
AppVersion string = "latest" // filled when build
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
|
||||
logger.DefaultLogger = zlogger.NewLogger(zlogger.ReportCaller(), logger.WithLevel(logger.DebugLevel), logger.WithCallerSkipCount(3))
|
||||
if err := logger.DefaultLogger.Init(); err != nil {
|
||||
logger.Fatalf(ctx, "failed to init logger")
|
||||
}
|
||||
|
||||
go func() {
|
||||
sig := <-ch
|
||||
logger.Infof(ctx, "handle signal %v, exiting", sig)
|
||||
cancel()
|
||||
cfg := appconfig.NewConfig(appName, AppVersion) // create new empty config
|
||||
vc := vaultconfig.NewConfig(
|
||||
config.AllowFail(true), // that may be not exists
|
||||
config.Struct(cfg), // load from vault
|
||||
options.Codec(jsoncodec.NewCodec()), // vault config in json
|
||||
config.BeforeLoad(func(ctx context.Context, c config.Config) error {
|
||||
return c.Init(
|
||||
vaultconfig.HTTPClient(&http.Client{
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
},
|
||||
}),
|
||||
vaultconfig.Address(cfg.Vault.Addr),
|
||||
vaultconfig.Timeout(5*time.Second),
|
||||
vaultconfig.Token(cfg.Vault.Token),
|
||||
vaultconfig.Path(cfg.Vault.Path),
|
||||
)
|
||||
}),
|
||||
)
|
||||
|
||||
if err := config.Load(ctx,
|
||||
[]config.Config{
|
||||
config.NewConfig( // load from defaults
|
||||
config.Struct(cfg), // pass config struct
|
||||
),
|
||||
fileconfig.NewConfig( // load from file
|
||||
config.AllowFail(true), // that may be not exists
|
||||
config.Struct(cfg), // pass config struct
|
||||
options.Codec(yamlcodec.NewCodec()), // file config in json
|
||||
fileconfig.Path("./local.yaml"), // nearby file
|
||||
),
|
||||
envconfig.NewConfig( // load from environment
|
||||
config.Struct(cfg), // pass config struct
|
||||
),
|
||||
vc,
|
||||
}, config.LoadOverride(true),
|
||||
); err != nil {
|
||||
logger.Fatalf(ctx, "failed to load config: %v", err)
|
||||
}
|
||||
|
||||
if err := config.Validate(ctx, cfg); err != nil {
|
||||
logger.Fatalf(ctx, "failed to validate config: %v", err)
|
||||
}
|
||||
|
||||
svc := micro.NewService()
|
||||
|
||||
if err := svc.Init(
|
||||
micro.Name(cfg.Server.Name),
|
||||
micro.Version(cfg.Server.Version),
|
||||
); err != nil {
|
||||
logger.Fatalf(ctx, "failed to init service: %v", err)
|
||||
}
|
||||
|
||||
if err := svc.Server("http").Init(
|
||||
options.Address(cfg.Server.Addr),
|
||||
options.Name(cfg.Server.Name),
|
||||
server.Version(cfg.Server.Version),
|
||||
); err != nil {
|
||||
logger.Fatalf(ctx, "failed to init service: %v", err)
|
||||
}
|
||||
|
||||
h := handler.NewHandler(svc, client_git.NewClient(5))
|
||||
if err := h.Init(svc.Options().Context); err != nil {
|
||||
logger.Fatalf(ctx, "failed to init handler: %v", err)
|
||||
}
|
||||
|
||||
log := logger.NewLogger(
|
||||
logger.WithLevel(logger.ParseLevel(cfg.Server.LoggerLevel)),
|
||||
logger.WithCallerSkipCount(3),
|
||||
)
|
||||
if err := svc.Init(micro.Logger(log)); err != nil {
|
||||
logger.Fatalf(ctx, "failed to init service: %v", err)
|
||||
}
|
||||
|
||||
if err := pb.RegisterPkgdashServiceServer(svc.Server("http"), h); err != nil {
|
||||
logger.Fatalf(ctx, "failed to register handler: %v", err)
|
||||
}
|
||||
|
||||
intsvc := httpsrv.NewServer(
|
||||
options.Codecs("application/json", jsoncodec.NewCodec()),
|
||||
options.Address(cfg.Meter.Addr),
|
||||
options.Context(ctx),
|
||||
)
|
||||
|
||||
if err := intsvc.Init(); err != nil {
|
||||
logger.Fatalf(ctx, "failed to init http srv: %v", err)
|
||||
}
|
||||
|
||||
if err := healthhandler.RegisterHealthServiceServer(intsvc, healthhandler.NewHandler()); err != nil {
|
||||
logger.Fatalf(ctx, "failed to set http handler: %v", err)
|
||||
}
|
||||
|
||||
if err := meterhandler.RegisterMeterServiceServer(intsvc, meterhandler.NewHandler()); err != nil {
|
||||
logger.Fatalf(ctx, "failed to set http handler: %v", err)
|
||||
}
|
||||
|
||||
if err := intsvc.Start(); err != nil {
|
||||
logger.Fatalf(ctx, "failed to run http srv: %v", err)
|
||||
}
|
||||
|
||||
cw, err := vc.Watch(ctx, config.WatchCoalesce(true), config.WatchInterval(1*time.Second, 5*time.Second))
|
||||
if err != nil {
|
||||
logger.Fatalf(ctx, "failed to watch config: %v", err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := cw.Stop(); err != nil {
|
||||
logger.Error(ctx, err)
|
||||
}
|
||||
}()
|
||||
|
||||
svc, err := service.NewService(ctx)
|
||||
go func() {
|
||||
for {
|
||||
changes, err := cw.Next()
|
||||
if err != nil {
|
||||
logger.Fatalf(ctx, "failed to create service: %v", err)
|
||||
logger.Errorf(ctx, "failed to get config update: %v", err)
|
||||
}
|
||||
|
||||
// start server
|
||||
if err = svc.Run(); err != nil {
|
||||
logger.Fatal(ctx, err)
|
||||
for k, v := range changes {
|
||||
if err = rutil.SetFieldByPath(cfg, v, k); err != nil {
|
||||
logger.Errorf(ctx, "failed to set config update: %v", err)
|
||||
break
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
for k := range changes {
|
||||
switch k {
|
||||
case "Server.LoggerLevel":
|
||||
if lvl, ok := changes[k].(string); ok {
|
||||
logger.Infof(ctx, "logger level changed to %s", lvl)
|
||||
logger.DefaultLogger.Level(logger.ParseLevel(lvl))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"go.unistack.org/unistack-org/pkgdash/internal"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal"
|
||||
"io"
|
||||
"net/url"
|
||||
"os"
|
||||
|
@ -1,22 +0,0 @@
|
||||
package config
|
||||
|
||||
type App struct {
|
||||
Name string
|
||||
Version string
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
App *App
|
||||
Address string `flag:"name=pkgdash.address,desc='listen address',default='127.0.0.1:8080'"`
|
||||
StorageDSN map[string]string `flag:"name=storage.dsn,desc='components storage dsn',default='all=sqlite+file:database.db'"`
|
||||
LogLevel string `flag:"name=logger.level,desc='logging level',default='info'"`
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
return &Config{
|
||||
App: &App{
|
||||
Name: ServiceName,
|
||||
Version: ServiceVersion,
|
||||
},
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package config
|
||||
|
||||
var (
|
||||
ServiceName = "pkgdash"
|
||||
ServiceVersion = "0.0.1"
|
||||
)
|
46
go.mod
46
go.mod
@ -1,4 +1,4 @@
|
||||
module go.unistack.org/unistack-org/pkgdash
|
||||
module git.unistack.org/unistack-org/pkgdash
|
||||
|
||||
go 1.20
|
||||
|
||||
@ -13,32 +13,38 @@ require (
|
||||
github.com/pkg/errors v0.9.1
|
||||
go.unistack.org/micro-config-flag/v4 v4.0.2
|
||||
go.unistack.org/micro-proto/v4 v4.0.1
|
||||
go.unistack.org/micro-server-http/v4 v4.0.9
|
||||
go.unistack.org/micro/v4 v4.0.6
|
||||
go.unistack.org/micro-server-http/v4 v4.0.11
|
||||
go.unistack.org/micro/v4 v4.0.7
|
||||
go.unistack.org/protoc-gen-go-micro/v4 v4.0.6
|
||||
golang.org/x/mod v0.12.0
|
||||
golang.org/x/sync v0.3.0
|
||||
google.golang.org/protobuf v1.31.0
|
||||
)
|
||||
|
||||
require go.unistack.org/micro-client-http/v4 v4.0.2
|
||||
|
||||
require (
|
||||
go.unistack.org/micro-client-http/v4 v4.0.2
|
||||
dario.cat/mergo v1.0.0 // indirect
|
||||
github.com/Microsoft/go-winio v0.6.1 // indirect
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect
|
||||
github.com/acomagu/bufpipe v1.0.4 // indirect
|
||||
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
|
||||
github.com/cloudflare/circl v1.3.3 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/emirpasic/gods v1.18.1 // indirect
|
||||
github.com/fatih/structtag v1.2.0 // indirect
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.4.1 // indirect
|
||||
github.com/go-jose/go-jose/v3 v3.0.0 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/google/gnostic v0.6.9 // indirect
|
||||
github.com/hashicorp/errwrap v1.0.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.0 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
|
||||
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
|
||||
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 // indirect
|
||||
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
|
||||
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/hashicorp/vault/api v1.9.2 // indirect
|
||||
github.com/iancoleman/strcase v0.2.0 // indirect
|
||||
github.com/imdario/mergo v0.3.16 // indirect
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||
@ -53,21 +59,29 @@ require (
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
||||
github.com/kevinburke/ssh_config v1.2.0 // indirect
|
||||
github.com/lyft/protoc-gen-star/v2 v2.0.3 // indirect
|
||||
github.com/mattn/go-isatty v0.0.18 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
|
||||
github.com/pjbgf/sha1cd v0.3.0 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/rs/zerolog v1.30.0 // indirect
|
||||
github.com/ryanuber/go-glob v1.0.0 // indirect
|
||||
github.com/sergi/go-diff v1.1.0 // indirect
|
||||
github.com/skeema/knownhosts v1.2.0 // indirect
|
||||
github.com/spf13/afero v1.3.3 // indirect
|
||||
github.com/stretchr/testify v1.8.1 // indirect
|
||||
github.com/stretchr/testify v1.8.3 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.3 // indirect
|
||||
go.uber.org/atomic v1.6.0 // indirect
|
||||
golang.org/x/crypto v0.11.0 // indirect
|
||||
go.unistack.org/micro-config-vault/v4 v4.0.2 // indirect
|
||||
go.unistack.org/micro-logger-zerolog/v4 v4.0.3 // indirect
|
||||
golang.org/x/crypto v0.12.0 // indirect
|
||||
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
|
||||
golang.org/x/net v0.12.0 // indirect
|
||||
golang.org/x/sys v0.10.0 // indirect
|
||||
golang.org/x/text v0.11.0 // indirect
|
||||
golang.org/x/net v0.14.0 // indirect
|
||||
golang.org/x/sys v0.11.0 // indirect
|
||||
golang.org/x/text v0.12.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
golang.org/x/tools v0.11.0 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
74
go.sum
74
go.sum
@ -111,6 +111,7 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd
|
||||
github.com/apache/arrow/go/arrow v0.0.0-20210818145353-234c94e4ce64/go.mod h1:2qMFB56yOP3KzkB3PbYZ4AlUFg3a88F67TIx5lB/WwY=
|
||||
github.com/apache/arrow/go/arrow v0.0.0-20211013220434-5962184e7a30/go.mod h1:Q7yQnSMnLvcXlZ8RV+jwz/6y1rQTqbX6C82SndT52Zs=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
|
||||
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
|
||||
github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0=
|
||||
@ -161,6 +162,8 @@ github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8n
|
||||
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50=
|
||||
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
|
||||
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
|
||||
github.com/cenkalti/backoff/v3 v3.2.2 h1:cfUAAO3yvKMYKPrvhDuHSwQnhZNk/RMHKdZqKTxfm6M=
|
||||
github.com/cenkalti/backoff/v3 v3.2.2/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs=
|
||||
github.com/cenkalti/backoff/v4 v4.0.2/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
@ -285,6 +288,8 @@ github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7
|
||||
github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
|
||||
github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
|
||||
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
@ -383,6 +388,8 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||
github.com/go-jose/go-jose/v3 v3.0.0 h1:s6rrhirfEP/CGIoc6p+PZAeogN2SxKav6Wp7+dyMWVo=
|
||||
github.com/go-jose/go-jose/v3 v3.0.0/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||
@ -561,13 +568,34 @@ github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMW
|
||||
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
|
||||
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
|
||||
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
|
||||
github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI=
|
||||
github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA=
|
||||
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.4 h1:ZQgVdpTdAL7WpMIwLzCfbalOcSUdkDZnpUv3/+BxzFA=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
|
||||
github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc=
|
||||
github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
|
||||
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 h1:UpiO20jno/eV1eVZcxqWnUohyKRe1g8FPV/xH1s/2qs=
|
||||
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8=
|
||||
github.com/hashicorp/go-secure-stdlib/strutil v0.1.1/go.mod h1:gKOamz3EwoIoJq7mlMIRBpVTAUn8qPCrEclOKKWhD3U=
|
||||
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 h1:kes8mmyCpxJsI7FTwtzRqEy9CdjCtrXrXGuOpxEA7Ts=
|
||||
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2/go.mod h1:Gou2R9+il93BqX25LAKCLuM+y9U2T4hlwvT1yprcna4=
|
||||
github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc=
|
||||
github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hashicorp/vault/api v1.9.2 h1:YjkZLJ7K3inKgMZ0wzCU9OHqc+UqMQyXsPXnf3Cl2as=
|
||||
github.com/hashicorp/vault/api v1.9.2/go.mod h1:jo5Y/ET+hNyz+JnKDt8XLAdKs+AM0G5W0Vp1IrFI8N8=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
|
||||
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
|
||||
@ -725,6 +753,9 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO
|
||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-ieproxy v0.0.1/go.mod h1:pYabZ6IHcRpFh7vIaLfK7rdcWgFEb3SFJ6/gNWuh88E=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
@ -733,8 +764,12 @@ github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
|
||||
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
|
||||
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
@ -745,9 +780,15 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
||||
github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
|
||||
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible/go.mod h1:8AuVvqP/mXw1px98n46wfvcGfQ4ci2FwoAjKYxuo3Z4=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A=
|
||||
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
|
||||
github.com/moby/sys/mountinfo v0.4.0/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A=
|
||||
@ -837,6 +878,7 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
||||
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA=
|
||||
github.com/prometheus/client_golang v0.0.0-20180209125602-c332b6f63c06/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
@ -878,10 +920,19 @@ github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
|
||||
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
|
||||
github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w=
|
||||
github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
|
||||
github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c=
|
||||
github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w=
|
||||
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
|
||||
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
|
||||
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4=
|
||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||
github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo=
|
||||
@ -943,6 +994,7 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
|
||||
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
|
||||
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
|
||||
@ -1017,12 +1069,20 @@ go.unistack.org/micro-client-http/v4 v4.0.2 h1:0xsm2RCRWMfb1moeXQQ220uz52XE0R/PZ
|
||||
go.unistack.org/micro-client-http/v4 v4.0.2/go.mod h1:Z9QT/upeqrp/rXVkL0lk6AzrkTdes0W3QlFlZ+ytkqM=
|
||||
go.unistack.org/micro-config-flag/v4 v4.0.2 h1:qoDpT/H8a8TYZS9ucoNC0bLhNdp+UFlhnRWOuqIKAyo=
|
||||
go.unistack.org/micro-config-flag/v4 v4.0.2/go.mod h1:s0AYvz8rRtMHG2tkXoSmF8xFuHG12x3v1NERdMHDdiQ=
|
||||
go.unistack.org/micro-config-vault/v4 v4.0.2 h1:QhDdtVJhQYmJZqAhsLRdnDZSZSzBunWX9a5l/WNKWNY=
|
||||
go.unistack.org/micro-config-vault/v4 v4.0.2/go.mod h1:0gWQVkncMwaG0wZPqC98HhS6AYOcXR0lmPG/roR6AcM=
|
||||
go.unistack.org/micro-logger-zerolog/v4 v4.0.2 h1:uKj/ZRiyEyiarImCm5Q3F6FvSvombZXB5aW4UGC2wVw=
|
||||
go.unistack.org/micro-logger-zerolog/v4 v4.0.2/go.mod h1:EOtcMZ5WfBe9sUoYkWPurnY18uaUaeKDlMdSdaaqYz0=
|
||||
go.unistack.org/micro-logger-zerolog/v4 v4.0.3 h1:ao6jGMo8jJG9WcOE738eqrWeabQaqpHMrLx+IniRDpI=
|
||||
go.unistack.org/micro-logger-zerolog/v4 v4.0.3/go.mod h1:w5iq5eT/ZUAczueU5lsChJK/evwofGcs3gz5rZwyivQ=
|
||||
go.unistack.org/micro-proto/v4 v4.0.1 h1:2RKHgtCOOcAFgKsnngGK5bqM/6MWXOjVCdw03dbuoF8=
|
||||
go.unistack.org/micro-proto/v4 v4.0.1/go.mod h1:ArmK7o+uFvxSY3dbJhKBBX4Pm1rhWdLEFf3LxBrMtec=
|
||||
go.unistack.org/micro-server-http/v4 v4.0.9 h1:ye7LVVJSXlvE1TBvEuk4m3iZrAJk0rzs6vD2/qO/o2w=
|
||||
go.unistack.org/micro-server-http/v4 v4.0.9/go.mod h1:Cu4utVz2u98fychmjA2Ls6clXrja0sqH6Xu/JTamf7Y=
|
||||
go.unistack.org/micro/v4 v4.0.6 h1:YFWvTh3VwyOd6NHYTQcf47n2TF5+p/EhpnbuBQX3qhk=
|
||||
go.unistack.org/micro/v4 v4.0.6/go.mod h1:bVEYTlPi0EsdgZZt311bIroDg9ict7ky3C87dSCCAGk=
|
||||
go.unistack.org/micro/v4 v4.0.7 h1:2lwtZlHcSwgkahhFbkI4x1lOS79lw8uLHtcEhlFF+AM=
|
||||
go.unistack.org/micro/v4 v4.0.7/go.mod h1:bVEYTlPi0EsdgZZt311bIroDg9ict7ky3C87dSCCAGk=
|
||||
go.unistack.org/protoc-gen-go-micro/v4 v4.0.6 h1:qe6huziuXqRnsgvDSiaT1DR20iL676w37PMkdBEjvEk=
|
||||
go.unistack.org/protoc-gen-go-micro/v4 v4.0.6/go.mod h1:9bsKAlESlPXPBSmY/NDLL//smZbhnEMrnWyG+M8zVFA=
|
||||
golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
@ -1055,6 +1115,8 @@ golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2Uz
|
||||
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
||||
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
|
||||
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
|
||||
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
|
||||
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
|
||||
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@ -1169,6 +1231,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
|
||||
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
|
||||
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
|
||||
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
|
||||
golang.org/x/oauth2 v0.0.0-20180227000427-d7d64896b5ff/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
@ -1201,6 +1265,7 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
|
||||
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sys v0.0.0-20180224232135-f6cff0780e54/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@ -1294,16 +1359,20 @@ golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210818153620-00dd8d7831e7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
|
||||
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
@ -1311,6 +1380,7 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
||||
golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c=
|
||||
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@ -1325,11 +1395,15 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
|
||||
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
|
||||
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
|
||||
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
|
@ -1,80 +0,0 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
pb "go.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
badRequest = `Bad Requet`
|
||||
internalError = `Internal Error`
|
||||
notFound = `Source Not Found`
|
||||
)
|
||||
|
||||
const (
|
||||
internalErrorCode = "1"
|
||||
badRequestCode = "2"
|
||||
notFoundErrorCode = "3"
|
||||
)
|
||||
|
||||
type UnmarshalError struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func (e *UnmarshalError) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
func (e *UnmarshalError) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
|
||||
func NewUnmarshalError(err error) error {
|
||||
return errors.WithStack(&UnmarshalError{err: err})
|
||||
}
|
||||
|
||||
func NewInternalError(err error) *pb.ErrorRsp {
|
||||
return &pb.ErrorRsp{
|
||||
Error: &pb.Error{
|
||||
Code: internalErrorCode,
|
||||
Title: internalError,
|
||||
Uuid: uuid.New().String(),
|
||||
Details: err.Error(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type ParametersMissingError struct {
|
||||
Err error
|
||||
}
|
||||
|
||||
func (e *ParametersMissingError) Error() string {
|
||||
return e.Err.Error()
|
||||
}
|
||||
|
||||
func NewParametersMissingError(err error) error {
|
||||
return errors.WithStack(&ParametersMissingError{Err: err})
|
||||
}
|
||||
|
||||
func NewNotFoundError(err error) *pb.ErrorRsp {
|
||||
return &pb.ErrorRsp{
|
||||
Error: &pb.Error{
|
||||
Code: notFoundErrorCode,
|
||||
Title: notFound,
|
||||
Uuid: uuid.New().String(),
|
||||
Details: err.Error(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func NewValidationError(err error) *pb.ErrorRsp {
|
||||
return &pb.ErrorRsp{
|
||||
Error: &pb.Error{
|
||||
Code: badRequestCode,
|
||||
Title: badRequest,
|
||||
Uuid: uuid.New().String(),
|
||||
Details: err.Error(),
|
||||
},
|
||||
}
|
||||
}
|
@ -1,185 +0,0 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
"go.unistack.org/micro/v4"
|
||||
pb "go.unistack.org/unistack-org/pkgdash/proto"
|
||||
cligit "go.unistack.org/unistack-org/pkgdash/service/client_git"
|
||||
"go.unistack.org/unistack-org/pkgdash/storage"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
svc micro.Service
|
||||
store storage.Storage
|
||||
|
||||
protojson.MarshalOptions
|
||||
protojson.UnmarshalOptions
|
||||
|
||||
git cligit.Client
|
||||
chanUrl chan *pb.AddPackageReq
|
||||
}
|
||||
|
||||
func (h *Handler) ListPackage(ctx context.Context, _ *emptypb.Empty, rsp *pb.ListPackageRsp) error {
|
||||
logger := h.svc.Logger()
|
||||
logger.Debug(ctx, "Start getListPackage")
|
||||
|
||||
dbRsp, err := h.store.ListPackage(ctx)
|
||||
if err != nil {
|
||||
logger.Errorf(ctx, "error db response: %v", err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
|
||||
return httpsrv.SetError(NewInternalError(err))
|
||||
}
|
||||
|
||||
//rsp = new(pb.ListPackageRsp)
|
||||
rsp.Packages = dbRsp.Decode()
|
||||
|
||||
logger.Debug(ctx, "Success finish getListPackage")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Handler) UpdatePackage(ctx context.Context, req *pb.UpdatePackageReq, rsp *pb.UpdatePackageRsp) error {
|
||||
logger := h.svc.Logger()
|
||||
logger.Debug(ctx, "Start UpdatePackage")
|
||||
|
||||
if err := req.Validate(); err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
|
||||
return httpsrv.SetError(NewValidationError(err))
|
||||
}
|
||||
|
||||
if err := h.store.UpdatePackage(ctx, req); err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
|
||||
return httpsrv.SetError(NewInternalError(err))
|
||||
}
|
||||
|
||||
rsp.Id = req.Id
|
||||
|
||||
logger.Debug(ctx, "Success finish UpdatePackage")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Handler) AddComment(ctx context.Context, req *pb.AddCommentReq, rsp *pb.AddCommentRsp) error {
|
||||
logger := h.svc.Logger()
|
||||
logger.Debug(ctx, "Start AddComment")
|
||||
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
|
||||
return httpsrv.SetError(NewValidationError(err))
|
||||
}
|
||||
|
||||
if rsp.Id, err = h.store.AddComment(ctx, req); err != nil {
|
||||
logger.Error(ctx, err)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
httpsrv.SetRspCode(ctx, http.StatusNotFound)
|
||||
return httpsrv.SetError(NewNotFoundError(err))
|
||||
}
|
||||
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
|
||||
return httpsrv.SetError(NewInternalError(err))
|
||||
}
|
||||
|
||||
logger.Debug(ctx, "Success finish addComment")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Handler) AddPackage(ctx context.Context, req *pb.AddPackageReq, rsp *pb.AddPackageRsp) error {
|
||||
logger := h.svc.Logger()
|
||||
logger.Debug(ctx, "Start AddPackage")
|
||||
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
|
||||
return httpsrv.SetError(NewValidationError(err))
|
||||
}
|
||||
|
||||
if h.git.IsClose() {
|
||||
logger.Error(ctx, "chan is closed")
|
||||
} else {
|
||||
h.chanUrl <- req
|
||||
}
|
||||
|
||||
rsp.Status = "Sent"
|
||||
|
||||
logger.Debug(ctx, "Success finish addPackage")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Handler) GetModule(ctx context.Context, req *pb.GetModuleReq, rsp *pb.GetModuleRsp) error {
|
||||
logger := h.svc.Logger()
|
||||
logger.Debug(ctx, "Start GetModule")
|
||||
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
|
||||
return httpsrv.SetError(NewValidationError(err))
|
||||
}
|
||||
|
||||
modules, err := h.store.GetModule(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
|
||||
return httpsrv.SetError(NewInternalError(err))
|
||||
}
|
||||
|
||||
rsp.Modules = modules.Decode()
|
||||
|
||||
logger.Debug(ctx, "Success finish getModule")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Handler) GetComments(ctx context.Context, req *pb.GetCommentsReq, rsp *pb.GetCommentsRsp) error {
|
||||
logger := h.svc.Logger()
|
||||
logger.Debug(ctx, "Start GetModule")
|
||||
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
|
||||
return httpsrv.SetError(NewValidationError(err))
|
||||
}
|
||||
|
||||
comments, err := h.store.GetComment(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
|
||||
return httpsrv.SetError(NewInternalError(err))
|
||||
}
|
||||
|
||||
rsp.Comments = comments.Decode()
|
||||
|
||||
logger.Debug(ctx, "Success finish getModule")
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHandler(svc micro.Service, client cligit.Client) *Handler {
|
||||
h := &Handler{
|
||||
svc: svc,
|
||||
git: client,
|
||||
}
|
||||
h.EmitUnpopulated = true
|
||||
h.UseProtoNames = false
|
||||
return h
|
||||
}
|
||||
|
||||
func (h *Handler) Init(ctx context.Context) error {
|
||||
store, err := storage.FromContext(h.svc.Options().Context)
|
||||
if err != nil {
|
||||
return errors.New("missing storage")
|
||||
}
|
||||
|
||||
h.chanUrl = h.git.Run(ctx, store)
|
||||
|
||||
h.store = store
|
||||
|
||||
return nil
|
||||
}
|
64
internal/config/config.go
Normal file
64
internal/config/config.go
Normal file
@ -0,0 +1,64 @@
|
||||
package config
|
||||
|
||||
import "time"
|
||||
|
||||
type AppConfig struct{}
|
||||
|
||||
type ServerConfig struct {
|
||||
Name string `json:"name" yaml:"name"`
|
||||
Version string `json:"-" yaml:"-"`
|
||||
Addr string `json:"addr" yaml:"addr" default:":9090"`
|
||||
Crt string `json:"crt" yaml:"crt"`
|
||||
Key string `json:"key" yaml:"key"`
|
||||
ID string `json:"-" yaml:"-" default:"micro:generate uuid"`
|
||||
LoggerLevel string `json:"logger_level" yaml:"logger_level"`
|
||||
}
|
||||
|
||||
type TracerConfig struct {
|
||||
Metadata map[string]string `json:"metadata" yaml:"metadata"`
|
||||
AgentHost string `env:"JAEGER_AGENT_HOST" json:"host" yaml:"host" default:"127.0.0.1"`
|
||||
AgentPort string `env:"JAEGER_AGENT_PORT" json:"port" yaml:"port" default:"6831"`
|
||||
Collector string `env:"JAEGER_ENDPOINT,TRACER_ENDPOINT" json:"endpoint" yaml:"endpoint"`
|
||||
}
|
||||
|
||||
type VaultConfig struct {
|
||||
Addr string `env:"VAULT_ADDR" json:"addr" yaml:"addr" default:"http://127.0.0.1:8200"`
|
||||
Token string `env:"VAULT_TOKEN" json:"-" yaml:"-"`
|
||||
Path string `env:"VAULT_PATH" json:"-" yaml:"-" default:"apigw/data/authn"`
|
||||
}
|
||||
|
||||
type MeterConfig struct {
|
||||
Addr string `json:"addr" yaml:"addr" default:"0.0.0.0:8080"`
|
||||
Path string `json:"path" yaml:"path" default:"/metrics"`
|
||||
}
|
||||
|
||||
type DatabaseConfig struct {
|
||||
DSN string `json:"dsn" yaml:"dsn"`
|
||||
Type string `json:"-" yaml:"-"`
|
||||
Migrate string `json:"-" yaml:"-"`
|
||||
ConnStr string `json:"-" yaml:"-"`
|
||||
MaxOpenConns int `json:"-" yaml:"-"`
|
||||
MaxIdleConns int `json:"-" yaml:"-"`
|
||||
ConnMaxLifetime time.Duration `json:"-" yaml:"-"`
|
||||
ConnMaxIdleTime time.Duration `json:"-" yaml:"-"`
|
||||
MigrateForce bool `json:"-" yaml:"-"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
App *AppConfig `json:"app" yaml:"app"`
|
||||
Database *DatabaseConfig `json:"database" yaml:"database"`
|
||||
Server *ServerConfig `json:"server" yaml:"server"`
|
||||
Meter *MeterConfig `json:"meter" yaml:"meter"`
|
||||
Vault *VaultConfig `json:"-" yaml:"-"`
|
||||
Tracer *TracerConfig `json:"tracer" yaml:"tracer"`
|
||||
}
|
||||
|
||||
func NewConfig(name, version string) *Config {
|
||||
return &Config{
|
||||
App: &AppConfig{},
|
||||
Server: &ServerConfig{Name: name, Version: version},
|
||||
Tracer: &TracerConfig{},
|
||||
Meter: &MeterConfig{},
|
||||
Vault: &VaultConfig{},
|
||||
}
|
||||
}
|
40
internal/handler/comments_create.go
Normal file
40
internal/handler/comments_create.go
Normal file
@ -0,0 +1,40 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/models"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
func (h *Handler) CommentsCreate(ctx context.Context, req *pb.CommentsCreateReq, rsp *pb.CommentsCreateRsp) error {
|
||||
logger := h.svc.Logger()
|
||||
logger.Debug(ctx, "Start AddComment")
|
||||
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
|
||||
return httpsrv.SetError(NewValidationError(err))
|
||||
}
|
||||
|
||||
var com *models.Comment
|
||||
if com, err = h.store.CommentsCreate(ctx, req); err != nil {
|
||||
logger.Error(ctx, err)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
httpsrv.SetRspCode(ctx, http.StatusNotFound)
|
||||
return httpsrv.SetError(NewNotFoundError(err))
|
||||
}
|
||||
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
|
||||
return httpsrv.SetError(NewInternalError(err))
|
||||
}
|
||||
|
||||
rsp.Comment = models.NewComment(com)
|
||||
|
||||
logger.Debug(ctx, "Success finish addComment")
|
||||
return nil
|
||||
}
|
36
internal/handler/comments_delete.go
Normal file
36
internal/handler/comments_delete.go
Normal file
@ -0,0 +1,36 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
func (h *Handler) CommentsDelete(ctx context.Context, req *pb.CommentsDeleteReq, rsp *pb.CommentsDeleteRsp) error {
|
||||
logger := h.svc.Logger()
|
||||
logger.Debug(ctx, "Start AddComment")
|
||||
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
|
||||
return httpsrv.SetError(NewValidationError(err))
|
||||
}
|
||||
|
||||
if err = h.store.CommentsDelete(ctx, req); err != nil {
|
||||
logger.Error(ctx, err)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
httpsrv.SetRspCode(ctx, http.StatusNotFound)
|
||||
return httpsrv.SetError(NewNotFoundError(err))
|
||||
}
|
||||
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
|
||||
return httpsrv.SetError(NewInternalError(err))
|
||||
}
|
||||
|
||||
logger.Debug(ctx, "Success finish addComment")
|
||||
return nil
|
||||
}
|
36
internal/handler/comments_list.go
Normal file
36
internal/handler/comments_list.go
Normal file
@ -0,0 +1,36 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/models"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
func (h *Handler) CommentsList(ctx context.Context, req *pb.CommentsListReq, rsp *pb.CommentsListRsp) error {
|
||||
logger := h.svc.Logger()
|
||||
logger.Debug(ctx, "Start GetModule")
|
||||
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
|
||||
return httpsrv.SetError(NewValidationError(err))
|
||||
}
|
||||
|
||||
comments, err := h.store.CommentsList(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
|
||||
return httpsrv.SetError(NewInternalError(err))
|
||||
}
|
||||
|
||||
for _, com := range comments {
|
||||
rsp.Comments = append(rsp.Comments, models.NewComment(com))
|
||||
}
|
||||
|
||||
logger.Debug(ctx, "Success finish getModule")
|
||||
return nil
|
||||
}
|
11
internal/handler/comments_lookup.go
Normal file
11
internal/handler/comments_lookup.go
Normal file
@ -0,0 +1,11 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
func (h *Handler) CommentsLookup(ctx context.Context, req *pb.CommentsLookupReq, rsp *pb.CommentsLookupRsp) error {
|
||||
return nil
|
||||
}
|
76
internal/handler/handler.go
Normal file
76
internal/handler/handler.go
Normal file
@ -0,0 +1,76 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"go.unistack.org/micro/v4"
|
||||
cligit "git.unistack.org/unistack-org/pkgdash/internal/service/client_git"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/storage"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
svc micro.Service
|
||||
store storage.Storage
|
||||
|
||||
protojson.MarshalOptions
|
||||
protojson.UnmarshalOptions
|
||||
|
||||
git cligit.Client
|
||||
chanUrl chan *pb.PackagesCreateReq
|
||||
}
|
||||
|
||||
func NewNotFoundError(err error) *pb.ErrorRsp {
|
||||
return &pb.ErrorRsp{
|
||||
Code: strconv.Itoa(http.StatusBadRequest),
|
||||
Title: "NotFound",
|
||||
Uuid: uuid.New().String(),
|
||||
Details: err.Error(),
|
||||
}
|
||||
}
|
||||
|
||||
func NewInternalError(err error) *pb.ErrorRsp {
|
||||
return &pb.ErrorRsp{
|
||||
Code: strconv.Itoa(http.StatusInternalServerError),
|
||||
Title: "InternalServerError",
|
||||
Uuid: uuid.New().String(),
|
||||
Details: err.Error(),
|
||||
}
|
||||
}
|
||||
|
||||
func NewValidationError(err error) *pb.ErrorRsp {
|
||||
return &pb.ErrorRsp{
|
||||
Code: strconv.Itoa(http.StatusBadRequest),
|
||||
Title: "BadRequest",
|
||||
Uuid: uuid.New().String(),
|
||||
Details: err.Error(),
|
||||
}
|
||||
}
|
||||
|
||||
func NewHandler(svc micro.Service, client cligit.Client) *Handler {
|
||||
h := &Handler{
|
||||
svc: svc,
|
||||
git: client,
|
||||
}
|
||||
h.EmitUnpopulated = true
|
||||
h.UseProtoNames = false
|
||||
return h
|
||||
}
|
||||
|
||||
func (h *Handler) Init(ctx context.Context) error {
|
||||
store, err := storage.FromContext(h.svc.Options().Context)
|
||||
if err != nil {
|
||||
return errors.New("missing storage")
|
||||
}
|
||||
|
||||
h.chanUrl = h.git.Run(ctx, store)
|
||||
|
||||
h.store = store
|
||||
|
||||
return nil
|
||||
}
|
35
internal/handler/modules_list.go
Normal file
35
internal/handler/modules_list.go
Normal file
@ -0,0 +1,35 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/models"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
func (h *Handler) ModulesList(ctx context.Context, req *pb.ModulesListReq, rsp *pb.ModulesListRsp) error {
|
||||
logger := h.svc.Logger()
|
||||
logger.Debug(ctx, "Start GetModule")
|
||||
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
|
||||
return httpsrv.SetError(NewValidationError(err))
|
||||
}
|
||||
|
||||
modules, err := h.store.ModulesList(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
|
||||
return httpsrv.SetError(NewInternalError(err))
|
||||
}
|
||||
|
||||
for _, mod := range modules {
|
||||
rsp.Modules = append(rsp.Modules, models.NewModule(mod))
|
||||
}
|
||||
logger.Debug(ctx, "Success finish getModule")
|
||||
return nil
|
||||
}
|
32
internal/handler/packages_create.go
Normal file
32
internal/handler/packages_create.go
Normal file
@ -0,0 +1,32 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
func (h *Handler) PackagesCreate(ctx context.Context, req *pb.PackagesCreateReq, rsp *pb.PackagesCreateRsp) error {
|
||||
logger := h.svc.Logger()
|
||||
logger.Debug(ctx, "Start AddPackage")
|
||||
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
|
||||
return httpsrv.SetError(NewValidationError(err))
|
||||
}
|
||||
|
||||
if h.git.IsClose() {
|
||||
logger.Error(ctx, "chan is closed")
|
||||
} else {
|
||||
h.chanUrl <- req
|
||||
}
|
||||
|
||||
rsp.Status = "Sent"
|
||||
|
||||
logger.Debug(ctx, "Success finish addPackage")
|
||||
return nil
|
||||
}
|
29
internal/handler/packages_delete.go
Normal file
29
internal/handler/packages_delete.go
Normal file
@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
func (h *Handler) PackagesDelete(ctx context.Context, req *pb.PackagesDeleteReq, rsp *pb.PackagesDeleteRsp) error {
|
||||
logger := h.svc.Logger()
|
||||
logger.Debug(ctx, "Start UpdatePackage")
|
||||
|
||||
if err := req.Validate(); err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
|
||||
return httpsrv.SetError(NewValidationError(err))
|
||||
}
|
||||
|
||||
if err := h.store.PackagesDelete(ctx, req); err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
|
||||
return httpsrv.SetError(NewInternalError(err))
|
||||
}
|
||||
|
||||
logger.Debug(ctx, "Success finish UpdatePackage")
|
||||
return nil
|
||||
}
|
28
internal/handler/packages_list.go
Normal file
28
internal/handler/packages_list.go
Normal file
@ -0,0 +1,28 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/models"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
func (h *Handler) PackagesList(ctx context.Context, req *pb.PackagesListReq, rsp *pb.PackagesListRsp) error {
|
||||
logger := h.svc.Logger()
|
||||
logger.Debug(ctx, "Start getListPackage")
|
||||
|
||||
packages, err := h.store.PackagesList(ctx, req)
|
||||
if err != nil {
|
||||
logger.Errorf(ctx, "error db response: %v", err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
|
||||
return httpsrv.SetError(NewInternalError(err))
|
||||
}
|
||||
|
||||
for _, pkg := range packages {
|
||||
rsp.Packages = append(rsp.Packages, models.NewPackage(pkg))
|
||||
}
|
||||
logger.Debug(ctx, "Success finish getListPackage")
|
||||
return nil
|
||||
}
|
31
internal/handler/packages_update.go
Normal file
31
internal/handler/packages_update.go
Normal file
@ -0,0 +1,31 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
func (h *Handler) PackagesUpdate(ctx context.Context, req *pb.PackagesUpdateReq, rsp *pb.PackagesUpdateRsp) error {
|
||||
logger := h.svc.Logger()
|
||||
logger.Debug(ctx, "Start UpdatePackage")
|
||||
|
||||
if err := req.Validate(); err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
|
||||
return httpsrv.SetError(NewValidationError(err))
|
||||
}
|
||||
|
||||
if err := h.store.PackagesUpdate(ctx, req); err != nil {
|
||||
logger.Error(ctx, err)
|
||||
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
|
||||
return httpsrv.SetError(NewInternalError(err))
|
||||
}
|
||||
|
||||
// rsp.Id = req.Id
|
||||
|
||||
logger.Debug(ctx, "Success finish UpdatePackage")
|
||||
return nil
|
||||
}
|
78
internal/models/models.go
Normal file
78
internal/models/models.go
Normal file
@ -0,0 +1,78 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
type Package struct {
|
||||
Name string `db:"name" json:"name"`
|
||||
URL string `db:"url" json:"url"`
|
||||
Modules []uint64 `db:"modules" json:"modules"`
|
||||
Issues []uint64 `db:"issues" json:"issues,omitempty"`
|
||||
Comments []uint64 `db:"comments" json:"comments,omitempty"`
|
||||
ID uint64 `db:"id" json:"id"`
|
||||
Created time.Time `db:"created" json:"created"`
|
||||
Updated time.Time `db:"updated" json:"updated,omitempty"`
|
||||
}
|
||||
|
||||
func NewPackage(pkg *Package) *pb.Package {
|
||||
return &pb.Package{
|
||||
Name: pkg.Name,
|
||||
Url: pkg.URL,
|
||||
Modules: pkg.Modules,
|
||||
Issues: pkg.Issues,
|
||||
Comments: pkg.Comments,
|
||||
Id: pkg.ID,
|
||||
Created: timestamppb.New(pkg.Created),
|
||||
Updated: timestamppb.New(pkg.Updated),
|
||||
}
|
||||
}
|
||||
|
||||
type Module struct {
|
||||
Name string `db:"name"`
|
||||
Version string `db:"version"`
|
||||
LastVersion string `db:"last_version"`
|
||||
ID uint64 `db:"id"`
|
||||
Package uint64 `db:"package"`
|
||||
Created time.Time `db:"created" json:"created"`
|
||||
Updated time.Time `db:"updated" json:"updated,omitempty"`
|
||||
}
|
||||
|
||||
func NewModule(mod *Module) *pb.Module {
|
||||
return &pb.Module{
|
||||
Name: mod.Name,
|
||||
Version: mod.Version,
|
||||
LastVersion: mod.LastVersion,
|
||||
Package: mod.Package,
|
||||
Id: mod.ID,
|
||||
Created: timestamppb.New(mod.Created),
|
||||
Updated: timestamppb.New(mod.Updated),
|
||||
}
|
||||
}
|
||||
|
||||
type Issue struct {
|
||||
Desc string `db:"desc"`
|
||||
Modules []int64 `db:"modules"`
|
||||
ID uint64 `db:"id"`
|
||||
Status uint64 `db:"status"`
|
||||
Package int64 `db:"package"`
|
||||
}
|
||||
|
||||
type Comment struct {
|
||||
Created time.Time `db:"created" json:"created"`
|
||||
Updated time.Time `db:"updated" json:"updated,omitempty"`
|
||||
Text string `db:"value" json:"text"`
|
||||
ID uint64 `db:"id" json:"id"`
|
||||
}
|
||||
|
||||
func NewComment(com *Comment) *pb.Comment {
|
||||
return &pb.Comment{
|
||||
Id: com.ID,
|
||||
Text: com.Text,
|
||||
Created: timestamppb.New(com.Created),
|
||||
Updated: timestamppb.New(com.Updated),
|
||||
}
|
||||
}
|
@ -15,35 +15,35 @@ import (
|
||||
"github.com/go-git/go-git/v5/storage/memory"
|
||||
"github.com/pkg/errors"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/unistack-org/pkgdash/internal"
|
||||
"go.unistack.org/unistack-org/pkgdash/models"
|
||||
pb "go.unistack.org/unistack-org/pkgdash/proto"
|
||||
"go.unistack.org/unistack-org/pkgdash/storage"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/models"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/storage"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
"golang.org/x/mod/modfile"
|
||||
"golang.org/x/mod/module"
|
||||
)
|
||||
|
||||
type Client interface {
|
||||
Run(ctx context.Context, st storage.Storage) chan *pb.AddPackageReq
|
||||
Run(ctx context.Context, st storage.Storage) chan *pb.PackagesCreateReq
|
||||
IsClose() bool
|
||||
Done() <-chan struct{}
|
||||
}
|
||||
|
||||
type client struct {
|
||||
worker chan *pb.AddPackageReq
|
||||
worker chan *pb.PackagesCreateReq
|
||||
closed bool
|
||||
lock chan struct{}
|
||||
}
|
||||
|
||||
func NewClient(cap uint) Client {
|
||||
return &client{
|
||||
make(chan *pb.AddPackageReq, cap),
|
||||
make(chan *pb.PackagesCreateReq, cap),
|
||||
false,
|
||||
make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *client) Run(ctx context.Context, st storage.Storage) chan *pb.AddPackageReq {
|
||||
func (c *client) Run(ctx context.Context, st storage.Storage) chan *pb.PackagesCreateReq {
|
||||
go func() {
|
||||
defer close(c.worker)
|
||||
for {
|
||||
@ -71,7 +71,7 @@ func (c *client) Done() <-chan struct{} {
|
||||
return c.lock
|
||||
}
|
||||
|
||||
func runner(ctx context.Context, st storage.Storage, req *pb.AddPackageReq) {
|
||||
func runner(ctx context.Context, st storage.Storage, req *pb.PackagesCreateReq) {
|
||||
modules, err := getGoModule(ctx, req.Url)
|
||||
if err != nil {
|
||||
logger.Error(ctx, err)
|
||||
@ -85,7 +85,7 @@ func runner(ctx context.Context, st storage.Storage, req *pb.AddPackageReq) {
|
||||
return
|
||||
}
|
||||
|
||||
if err = st.AddPackage(ctx, req); err != nil {
|
||||
if err = st.PackagesCreate(ctx, req); err != nil {
|
||||
logger.Error(ctx, err)
|
||||
}
|
||||
}
|
@ -5,16 +5,17 @@ import (
|
||||
"database/sql"
|
||||
"embed"
|
||||
"fmt"
|
||||
pb "go.unistack.org/unistack-org/pkgdash/proto"
|
||||
"go.unistack.org/unistack-org/pkgdash/storage"
|
||||
"go.unistack.org/unistack-org/pkgdash/storage/postgres"
|
||||
"go.unistack.org/unistack-org/pkgdash/storage/sqlite"
|
||||
"testing"
|
||||
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/storage"
|
||||
// "git.unistack.org/unistack-org/pkgdash/internal/storage/postgres"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/storage/sqlite"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
func TestClientPG(t *testing.T) {
|
||||
dsn := fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=disable", "test", "123", "localhost", "5432", "postgres")
|
||||
conn, err := sql.Open("postgres", dsn)
|
||||
dsn := fmt.Sprintf("file:///database.db")
|
||||
conn, err := sql.Open("sqlite", dsn)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -23,7 +24,7 @@ func TestClientPG(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fucntion := postgres.NewStorage()
|
||||
fucntion := sqlite.NewStorage()
|
||||
st := fucntion(conn, embed.FS{})
|
||||
s, ok := st.(storage.Storage)
|
||||
if !ok {
|
@ -3,7 +3,10 @@ package service
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
httpsrv "go.unistack.org/micro-server-http/v4" // TODO
|
||||
"go.unistack.org/micro/v4"
|
||||
"go.unistack.org/micro/v4/config"
|
||||
microcfg "go.unistack.org/micro/v4/config"
|
||||
@ -11,19 +14,17 @@ import (
|
||||
"go.unistack.org/micro/v4/options"
|
||||
"go.unistack.org/micro/v4/register"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
intcfg "go.unistack.org/unistack-org/pkgdash/config"
|
||||
"go.unistack.org/unistack-org/pkgdash/handler"
|
||||
pb "go.unistack.org/unistack-org/pkgdash/proto"
|
||||
"go.unistack.org/unistack-org/pkgdash/service/client_git"
|
||||
"go.unistack.org/unistack-org/pkgdash/storage"
|
||||
"net/url"
|
||||
"strings"
|
||||
intcfg "git.unistack.org/unistack-org/pkgdash/config"
|
||||
"git.unistack.org/unistack-org/pkgdash/handler"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
"git.unistack.org/unistack-org/pkgdash/service/client_git"
|
||||
"git.unistack.org/unistack-org/pkgdash/storage"
|
||||
)
|
||||
|
||||
func NewService(ctx context.Context) (micro.Service, error) {
|
||||
var reg register.Register
|
||||
|
||||
cfg := intcfg.NewConfig()
|
||||
cfg := intcfg.NewConfig(ServiceName, Service)
|
||||
|
||||
cs := microcfg.NewConfig(config.Struct(cfg))
|
||||
|
||||
@ -105,6 +106,26 @@ func NewService(ctx context.Context) (micro.Service, error) {
|
||||
logger.Fatalf(ctx, "failed to register handler: %v", err)
|
||||
}
|
||||
|
||||
intsvc := httpsrv.NewServer(
|
||||
server.Codec("application/json", jsoncodec.NewCodec()),
|
||||
server.Address(cfg.Meter.Addr), server.Context(ctx),
|
||||
)
|
||||
|
||||
if err := intsvc.Init(); err != nil {
|
||||
logger.Fatalf(ctx, "failed to init http srv: %v", err)
|
||||
}
|
||||
|
||||
if err := healthhandler.RegisterHealthServiceServer(intsvc, healthhandler.NewHandler()); err != nil {
|
||||
logger.Fatalf(ctx, "failed to set http handler: %v", err)
|
||||
}
|
||||
if err := meterhandler.RegisterMeterServiceServer(intsvc, meterhandler.NewHandler()); err != nil {
|
||||
logger.Fatalf(ctx, "failed to set http handler: %v", err)
|
||||
}
|
||||
|
||||
if err := intsvc.Start(); err != nil {
|
||||
logger.Fatalf(ctx, "failed to run http srv: %v", err)
|
||||
}
|
||||
|
||||
return svc, nil
|
||||
}
|
||||
|
@ -7,8 +7,9 @@ create table if not exists dashboard (
|
||||
create table if not exists comment (
|
||||
id serial not null unique primary key ,
|
||||
"text" text ,
|
||||
package integer not null,
|
||||
created timestamp not null default current_timestamp ,
|
||||
updated timestamp
|
||||
updated timestamp default current_timestamp
|
||||
);
|
||||
|
||||
create table if not exists module (
|
@ -7,8 +7,9 @@ create table if not exists dashboard (
|
||||
create table if not exists comment (
|
||||
id integer primary key autoincrement not null ,
|
||||
"text" text ,
|
||||
package integer not null,
|
||||
created timestamp not null default current_timestamp ,
|
||||
updated timestamp
|
||||
updated timestamp default current_timestamp
|
||||
);
|
||||
|
||||
create table if not exists module (
|
@ -13,9 +13,9 @@ import (
|
||||
"github.com/golang-migrate/migrate/v4/source/iofs"
|
||||
"github.com/lib/pq"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/unistack-org/pkgdash/config"
|
||||
"go.unistack.org/unistack-org/pkgdash/models"
|
||||
pb "go.unistack.org/unistack-org/pkgdash/proto"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/config"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/models"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -85,11 +85,11 @@ func (s *Postgres) MigrateDown() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Postgres) UpdatePackage(ctx context.Context, req *pb.UpdatePackageReq) error {
|
||||
func (s *Postgres) PackagesUpdate(ctx context.Context, req *pb.PackagesUpdateReq) error {
|
||||
panic("need implement")
|
||||
}
|
||||
|
||||
func (s *Postgres) ListPackage(ctx context.Context) (models.ListPackage, error) {
|
||||
func (s *Postgres) PackagesList(ctx context.Context, req *pb.PackagesListReq) (models.ListPackage, error) {
|
||||
rows, err := s.db.QueryContext(ctx, queryListPackage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -118,7 +118,7 @@ func (s *Postgres) ListPackage(ctx context.Context) (models.ListPackage, error)
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *Postgres) AddComment(ctx context.Context, req *pb.AddCommentReq) error {
|
||||
func (s *Postgres) CommentsCreate(ctx context.Context, req *pb.CommentsCreateReq) error {
|
||||
tx, err := s.db.BeginTx(ctx, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -134,7 +134,7 @@ func (s *Postgres) AddComment(ctx context.Context, req *pb.AddCommentReq) error
|
||||
}
|
||||
}()
|
||||
|
||||
res, err := tx.ExecContext(ctx, queryAddComment, req.Text, req.IdPackage)
|
||||
res, err := tx.ExecContext(ctx, queryAddComment, req.Text, req.PackageId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -148,7 +148,7 @@ func (s *Postgres) AddComment(ctx context.Context, req *pb.AddCommentReq) error
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Postgres) AddPackage(ctx context.Context, req *pb.AddPackageReq) error {
|
||||
func (s *Postgres) PackagesCreate(ctx context.Context, req *pb.PackagesCreateReq) error {
|
||||
tx, err := s.db.BeginTx(ctx, nil)
|
||||
if err != nil {
|
||||
return err
|
@ -2,8 +2,9 @@ package postgres
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go.unistack.org/unistack-org/pkgdash/models"
|
||||
"testing"
|
||||
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/models"
|
||||
)
|
||||
|
||||
func TestGenerate(t *testing.T) {
|
@ -1,23 +1,22 @@
|
||||
package sqlite
|
||||
|
||||
const (
|
||||
queryListPackage = `
|
||||
select
|
||||
queryPackagesList = `select
|
||||
id,
|
||||
name,
|
||||
url,
|
||||
comments
|
||||
--modules,
|
||||
--issues,
|
||||
modules,
|
||||
issues,
|
||||
from package;
|
||||
`
|
||||
queryAddComment = `
|
||||
queryCommentsCreate = `
|
||||
insert into comment(text) values ($1) returning id;
|
||||
update package
|
||||
set comments = json_insert(comments, '$[#]', ( select last_insert_rowid() as id from comment ))
|
||||
where id = $2 ;
|
||||
`
|
||||
queryAddPackage = `
|
||||
queryPackagesCreate = `
|
||||
insert into package(name, url, modules) values ($1, $2, $3);
|
||||
`
|
||||
queryInsMsgGetIDs = `
|
||||
@ -25,13 +24,11 @@ insert into module(name, version, last_version) values
|
||||
%s
|
||||
returning id;
|
||||
`
|
||||
queryGetModule = `
|
||||
select id, name, version, last_version from module
|
||||
where id in %s ;
|
||||
queryModulesList = `
|
||||
select id, name, version, last_version, created, updated from modules;
|
||||
`
|
||||
|
||||
queryGetComments = `
|
||||
select id, text, created, updated from comment
|
||||
where id in %s ;
|
||||
queryCommentsList = `
|
||||
select id, text, created, updated from comments;
|
||||
`
|
||||
)
|
@ -14,9 +14,8 @@ import (
|
||||
"github.com/lib/pq"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/unistack-org/pkgdash/config"
|
||||
"go.unistack.org/unistack-org/pkgdash/models"
|
||||
pb "go.unistack.org/unistack-org/pkgdash/proto"
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/models"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -37,7 +36,7 @@ func NewStorage() func(*sql.DB, embed.FS) interface{} {
|
||||
func (s *Sqlite) MigrateUp() error {
|
||||
driver, err := sqlite.WithInstance(s.db, &sqlite.Config{
|
||||
MigrationsTable: sqlite.DefaultMigrationsTable,
|
||||
DatabaseName: config.ServiceName,
|
||||
DatabaseName: "pkgdash",
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@ -48,7 +47,7 @@ func (s *Sqlite) MigrateUp() error {
|
||||
}
|
||||
|
||||
// TODO: pass own logger
|
||||
m, err := migrate.NewWithInstance("fs", source, config.ServiceName, driver)
|
||||
m, err := migrate.NewWithInstance("fs", source, "pkgdash", driver)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -63,7 +62,7 @@ func (s *Sqlite) MigrateUp() error {
|
||||
func (s *Sqlite) MigrateDown() error {
|
||||
driver, err := sqlite.WithInstance(s.db, &sqlite.Config{
|
||||
MigrationsTable: sqlite.DefaultMigrationsTable,
|
||||
DatabaseName: config.ServiceName,
|
||||
DatabaseName: "pkgdash",
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@ -74,7 +73,7 @@ func (s *Sqlite) MigrateDown() error {
|
||||
}
|
||||
|
||||
// TODO: pass own logger
|
||||
m, err := migrate.NewWithInstance("fs", source, config.ServiceName, driver)
|
||||
m, err := migrate.NewWithInstance("fs", source, "pkgdash", driver)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -86,40 +85,44 @@ func (s *Sqlite) MigrateDown() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Sqlite) UpdatePackage(ctx context.Context, req *pb.UpdatePackageReq) error {
|
||||
func (s *Sqlite) PackagesUpdate(ctx context.Context, req *pb.PackagesUpdateReq) error {
|
||||
panic("need implement")
|
||||
}
|
||||
|
||||
func (s *Sqlite) ListPackage(ctx context.Context) (models.ListPackage, error) {
|
||||
rows, err := s.db.QueryContext(ctx, queryListPackage)
|
||||
func (s *Sqlite) PackagesList(ctx context.Context, req *pb.PackagesListReq) ([]*models.Package, error) {
|
||||
var packages []*models.Package
|
||||
|
||||
rows, err := s.db.QueryContext(ctx, queryPackagesList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err = rows.Close(); err != nil {
|
||||
return
|
||||
}
|
||||
err = rows.Err()
|
||||
}()
|
||||
|
||||
result := make([]*models.Package, 0)
|
||||
for rows.Next() {
|
||||
tmp := &models.Package{}
|
||||
for ; rows.Err() == nil; rows.Next() {
|
||||
pkg := &models.Package{}
|
||||
if err = rows.Scan(
|
||||
&tmp.ID,
|
||||
&tmp.Name,
|
||||
&tmp.URL,
|
||||
pq.Array(&tmp.Comments),
|
||||
&pkg.ID,
|
||||
&pkg.Name,
|
||||
&pkg.URL,
|
||||
&pkg.Comments,
|
||||
); err != nil {
|
||||
_ = rows.Close()
|
||||
return nil, err
|
||||
}
|
||||
packages = append(packages, pkg)
|
||||
}
|
||||
|
||||
return result, err
|
||||
if err = rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (s *Sqlite) AddComment(ctx context.Context, req *pb.AddCommentReq) (id uint64, err error) {
|
||||
if err = rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return packages, err
|
||||
}
|
||||
|
||||
func (s *Sqlite) CommentsCreate(ctx context.Context, req *pb.CommentsCreateReq) (id uint64, err error) {
|
||||
tx, err := s.db.BeginTx(ctx, nil)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -135,14 +138,14 @@ func (s *Sqlite) AddComment(ctx context.Context, req *pb.AddCommentReq) (id uint
|
||||
}
|
||||
}()
|
||||
|
||||
if err = tx.QueryRowContext(ctx, queryAddComment, req.Text, req.IdPackage).Scan(&id); err != nil {
|
||||
if err = tx.QueryRowContext(ctx, queryCommentsCreate, req.Text, req.PackageId).Scan(&id); err != nil {
|
||||
return id, err
|
||||
}
|
||||
|
||||
return id, err
|
||||
}
|
||||
|
||||
func (s *Sqlite) AddPackage(ctx context.Context, req *pb.AddPackageReq) error {
|
||||
func (s *Sqlite) PackagesCreate(ctx context.Context, req *pb.PackagesCreateReq) error {
|
||||
tx, err := s.db.BeginTx(ctx, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -158,7 +161,7 @@ func (s *Sqlite) AddPackage(ctx context.Context, req *pb.AddPackageReq) error {
|
||||
}
|
||||
}()
|
||||
|
||||
res, err := tx.ExecContext(ctx, queryAddPackage, req.Name, req.Url, pq.Array(req.Modules))
|
||||
res, err := tx.ExecContext(ctx, queryPackagesCreate, req.Name, req.Url, pq.Array(req.Modules))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -213,15 +216,11 @@ func (s *Sqlite) InsertButchModules(ctx context.Context, req []models.Module) ([
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *Sqlite) GetModule(ctx context.Context, req *pb.GetModuleReq) (result models.ListModule, err error) {
|
||||
query := ""
|
||||
if len(req.Id) < 1 {
|
||||
query = fmt.Sprintf(queryGetModule, "() or 1=1")
|
||||
} else {
|
||||
query = fmt.Sprintf(queryGetModule, generateArrayIneq(len(req.Id)))
|
||||
}
|
||||
func (s *Sqlite) GetModule(ctx context.Context, req *pb.ModulesListReq) ([]*models.Module, error) {
|
||||
var err error
|
||||
var modules []*models.Module
|
||||
|
||||
rows, err := s.db.QueryContext(ctx, query, convertSliceUInt(req.Id...)...)
|
||||
rows, err := s.db.QueryContext(ctx, queryModulesList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -232,27 +231,35 @@ func (s *Sqlite) GetModule(ctx context.Context, req *pb.GetModuleReq) (result mo
|
||||
err = rows.Err()
|
||||
}()
|
||||
|
||||
for rows.Next() {
|
||||
tmp := &models.Module{}
|
||||
for ; rows.Err() == nil; rows.Next() {
|
||||
mod := &models.Module{}
|
||||
if err = rows.Scan(
|
||||
&tmp.ID,
|
||||
&tmp.Name,
|
||||
&tmp.Version,
|
||||
&tmp.LastVersion,
|
||||
&mod.ID,
|
||||
&mod.Name,
|
||||
&mod.Version,
|
||||
&mod.LastVersion,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result = append(result, tmp)
|
||||
modules = append(modules, mod)
|
||||
}
|
||||
|
||||
return result, err
|
||||
if err = rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (s *Sqlite) GetComment(ctx context.Context, req *pb.GetCommentsReq) (result models.ListComment, err error) {
|
||||
query := fmt.Sprintf(queryGetComments, generateArrayIneq(len(req.Id)))
|
||||
if err = rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rows, err := s.db.QueryContext(ctx, query, convertSliceUInt(req.Id...)...)
|
||||
return modules, nil
|
||||
}
|
||||
|
||||
func (s *Sqlite) CommentsList(ctx context.Context, req *pb.CommentsListReq) ([]*models.Comment, error) {
|
||||
var comments []*models.Comment
|
||||
|
||||
rows, err := s.db.QueryContext(ctx, queryCommentsList, req.PackageId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -262,21 +269,30 @@ func (s *Sqlite) GetComment(ctx context.Context, req *pb.GetCommentsReq) (result
|
||||
}
|
||||
err = rows.Err()
|
||||
}()
|
||||
for rows.Next() {
|
||||
tmp := &models.Comment{}
|
||||
for ; rows.Err() == nil; rows.Next() {
|
||||
com := &models.Comment{}
|
||||
if err = rows.Scan(
|
||||
&tmp.ID,
|
||||
&tmp.Text,
|
||||
&tmp.Created,
|
||||
&tmp.Updated,
|
||||
&com.ID,
|
||||
&com.Text,
|
||||
&com.Created,
|
||||
&com.Updated,
|
||||
); err != nil {
|
||||
_ = rows.Close()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result = append(result, tmp)
|
||||
comments = append(comments, com)
|
||||
}
|
||||
|
||||
return result, err
|
||||
if err = rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return comments, nil
|
||||
}
|
||||
|
||||
func convertSliceUInt(arg ...uint64) []interface{} {
|
69
internal/storage/storage.go
Normal file
69
internal/storage/storage.go
Normal file
@ -0,0 +1,69 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"embed"
|
||||
"errors"
|
||||
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/models"
|
||||
// "git.unistack.org/unistack-org/pkgdash/internal/storage/postgres"
|
||||
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/storage/sqlite"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
//go:embed migrations
|
||||
var fs embed.FS
|
||||
|
||||
var storages = map[string]func(*sql.DB, embed.FS) interface{}{
|
||||
//"postgres": postgres.NewStorage(),
|
||||
"sqlite": sqlite.NewStorage(),
|
||||
}
|
||||
|
||||
type contextKey string
|
||||
|
||||
var storeIdent = contextKey("store")
|
||||
|
||||
type Migrate interface {
|
||||
MigrateUp() error
|
||||
MigrateDown() error
|
||||
}
|
||||
|
||||
type Storage interface {
|
||||
Migrate
|
||||
PackagesCreate(ctx context.Context, req *pb.PackagesCreateReq) error
|
||||
PackagesList(ctx context.Context, req *pb.PackagesListReq) ([]*models.Package, error)
|
||||
PackagesUpdate(ctx context.Context, req *pb.PackagesUpdateReq) error
|
||||
PackagesDelete(ctx context.Context, req *pb.PackagesDeleteReq) error
|
||||
CommentsCreate(ctx context.Context, req *pb.CommentsCreateReq) (*models.Comment, error)
|
||||
CommentsDelete(ctx context.Context, req *pb.CommentsDeleteReq) error
|
||||
CommentsList(ctx context.Context, req *pb.CommentsListReq) ([]*models.Comment, error)
|
||||
InsertButchModules(ctx context.Context, req []models.Module) ([]uint64, error)
|
||||
ModulesList(ctx context.Context, req *pb.ModulesListReq) ([]*models.Module, error)
|
||||
}
|
||||
|
||||
func NewStorage(name string, db *sql.DB) (Storage, error) {
|
||||
function, ok := storages[name]
|
||||
if !ok {
|
||||
return nil, errors.New("incorrect name store")
|
||||
}
|
||||
store := function(db, fs)
|
||||
database, ok := store.(Storage)
|
||||
if !ok {
|
||||
return nil, errors.New("dont implements interface Storage")
|
||||
}
|
||||
return database, nil
|
||||
}
|
||||
|
||||
func InContext(ctx context.Context, val Storage) context.Context {
|
||||
return context.WithValue(ctx, storeIdent, val)
|
||||
}
|
||||
|
||||
func FromContext(ctx context.Context) (Storage, error) {
|
||||
if store, ok := ctx.Value(storeIdent).(Storage); !ok {
|
||||
return nil, errors.New("empty store")
|
||||
} else {
|
||||
return store, nil
|
||||
}
|
||||
}
|
@ -4,9 +4,10 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
pb "go.unistack.org/unistack-org/pkgdash/proto"
|
||||
"go.unistack.org/unistack-org/pkgdash/storage/sqlite"
|
||||
"testing"
|
||||
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/storage/sqlite"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
func TestGetModule(t *testing.T) {
|
@ -1,45 +0,0 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
_ "database/sql"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgtype"
|
||||
)
|
||||
|
||||
type Package struct {
|
||||
ID uint64 `db:"id" json:"id"` // package id
|
||||
Name string `db:"name" json:"name"` // service name, last component path
|
||||
URL string `db:"url" json:"url"` // scm url
|
||||
Modules []uint64 `db:"modules" json:"modules"` // parsed go.mod modules
|
||||
Issues []uint64 `db:"issues" json:"issues,omitempty"` // issues list
|
||||
Comments []uint64 `db:"comments" json:"comments,omitempty"`
|
||||
}
|
||||
|
||||
type Module struct {
|
||||
ID uint64 `db:"id"`
|
||||
Name string `db:"name"` // module name
|
||||
Version string `db:"version"` // module
|
||||
Package uint64 `db:"package"`
|
||||
LastVersion string `db:"last_version"`
|
||||
}
|
||||
|
||||
type Issue struct {
|
||||
ID uint64 `db:"id"`
|
||||
Status uint64 `db:"status"`
|
||||
Desc string `db:"desc"`
|
||||
Package int64 `db:"package"`
|
||||
Modules []int64 `db:"modules"`
|
||||
}
|
||||
|
||||
type Comment struct {
|
||||
ID uint64 `db:"id" json:"id"`
|
||||
Text string `db:"value" json:"text"`
|
||||
Created pgtype.Date `db:"created" json:"created"`
|
||||
Updated pgtype.Date `db:"updated" json:"updated,omitempty"`
|
||||
}
|
||||
|
||||
type Dashboard struct {
|
||||
ID uint64 `db:"id"`
|
||||
Uuid uuid.UUID `db:"uuid"`
|
||||
Packages []uint64 `db:"package"`
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/jackc/pgtype"
|
||||
pb "go.unistack.org/unistack-org/pkgdash/proto"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ListPackage []*Package
|
||||
|
||||
func (l ListPackage) Decode() []*pb.Package {
|
||||
result := make([]*pb.Package, 0, len(l))
|
||||
|
||||
for i := range l {
|
||||
temp := &pb.Package{
|
||||
Id: l[i].ID,
|
||||
Name: l[i].Name,
|
||||
Url: l[i].URL,
|
||||
Modules: l[i].Modules,
|
||||
Issues: l[i].Issues,
|
||||
Comments: l[i].Comments,
|
||||
}
|
||||
|
||||
result = append(result, temp)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
type ListModule []*Module
|
||||
|
||||
func (l ListModule) Decode() []*pb.Module {
|
||||
result := make([]*pb.Module, 0, len(l))
|
||||
for i := range l {
|
||||
temp := &pb.Module{
|
||||
Id: l[i].ID,
|
||||
Name: l[i].Name,
|
||||
Version: l[i].Version,
|
||||
LastVersion: l[i].LastVersion,
|
||||
}
|
||||
|
||||
result = append(result, temp)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
type ListComment []*Comment
|
||||
|
||||
func (l ListComment) Decode() []*pb.Comment {
|
||||
result := make([]*pb.Comment, 0, len(l))
|
||||
for i := range l {
|
||||
temp := &pb.Comment{
|
||||
Id: l[i].ID,
|
||||
//Package: l[i].,
|
||||
Text: l[i].Text,
|
||||
}
|
||||
|
||||
if l[i].Created.Status == pgtype.Present {
|
||||
temp.Created = l[i].Created.Time.Format(time.DateTime)
|
||||
}
|
||||
|
||||
if l[i].Updated.Status == pgtype.Present {
|
||||
temp.Updated = l[i].Updated.Time.Format(time.DateTime)
|
||||
}
|
||||
|
||||
result = append(result, temp)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
@ -5,87 +5,11 @@ info:
|
||||
title: PkgdashService API
|
||||
version: 0.0.1
|
||||
paths:
|
||||
/v1/comment:
|
||||
/v1/comments/{id}/comments:
|
||||
get:
|
||||
tags:
|
||||
- PkgdashService
|
||||
operationId: GetComments
|
||||
parameters:
|
||||
- name: id
|
||||
in: query
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: integer
|
||||
format: uint64
|
||||
responses:
|
||||
default:
|
||||
description: Default
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorRsp'
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GetCommentsRsp'
|
||||
/v1/module:
|
||||
get:
|
||||
tags:
|
||||
- PkgdashService
|
||||
operationId: GetModule
|
||||
parameters:
|
||||
- name: id
|
||||
in: query
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: integer
|
||||
format: uint64
|
||||
responses:
|
||||
default:
|
||||
description: Default
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorRsp'
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GetModuleRsp'
|
||||
/v1/package:
|
||||
post:
|
||||
tags:
|
||||
- PkgdashService
|
||||
operationId: AddPackage
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/AddPackageReq'
|
||||
required: true
|
||||
responses:
|
||||
default:
|
||||
description: Default
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorRsp'
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/AddPackageRsp'
|
||||
/v1/package/{id}:
|
||||
post:
|
||||
tags:
|
||||
- PkgdashService
|
||||
operationId: UpdateInfo
|
||||
operationId: CommentsLookup
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
@ -93,12 +17,11 @@ paths:
|
||||
schema:
|
||||
type: integer
|
||||
format: uint64
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
- name: package_id
|
||||
in: query
|
||||
schema:
|
||||
$ref: '#/components/schemas/UpdatePackageReq'
|
||||
required: true
|
||||
type: integer
|
||||
format: uint64
|
||||
responses:
|
||||
default:
|
||||
description: Default
|
||||
@ -111,24 +34,12 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UpdatePackageRsp'
|
||||
/v1/package/{pkg}/comment:
|
||||
post:
|
||||
$ref: '#/components/schemas/CommentsLookupRsp'
|
||||
/v1/modules:
|
||||
get:
|
||||
tags:
|
||||
- PkgdashService
|
||||
operationId: AddComment
|
||||
parameters:
|
||||
- name: pkg
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/AddCommentReq'
|
||||
required: true
|
||||
operationId: ModulesList
|
||||
responses:
|
||||
default:
|
||||
description: Default
|
||||
@ -141,12 +52,12 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/AddCommentRsp'
|
||||
$ref: '#/components/schemas/ModulesListRsp'
|
||||
/v1/packages:
|
||||
get:
|
||||
tags:
|
||||
- PkgdashService
|
||||
operationId: ListPackage
|
||||
operationId: PackagesList
|
||||
responses:
|
||||
default:
|
||||
description: Default
|
||||
@ -159,40 +70,173 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ListPackageRsp'
|
||||
$ref: '#/components/schemas/PackagesListRsp'
|
||||
post:
|
||||
tags:
|
||||
- PkgdashService
|
||||
operationId: PackagesCreate
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/PackagesCreateReq'
|
||||
required: true
|
||||
responses:
|
||||
default:
|
||||
description: Default
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorRsp'
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/PackagesCreateRsp'
|
||||
/v1/packages/{id}:
|
||||
put:
|
||||
tags:
|
||||
- PkgdashService
|
||||
operationId: PackagesUpdate
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: uint64
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/PackagesUpdateReq'
|
||||
required: true
|
||||
responses:
|
||||
default:
|
||||
description: Default
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorRsp'
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/PackagesUpdateRsp'
|
||||
delete:
|
||||
tags:
|
||||
- PkgdashService
|
||||
operationId: PackagesDelete
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: uint64
|
||||
responses:
|
||||
default:
|
||||
description: Default
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorRsp'
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/PackagesDeleteRsp'
|
||||
/v1/packages/{package_id}/comments:
|
||||
get:
|
||||
tags:
|
||||
- PkgdashService
|
||||
operationId: CommentsList
|
||||
parameters:
|
||||
- name: package_id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: uint64
|
||||
responses:
|
||||
default:
|
||||
description: Default
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorRsp'
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CommentsListRsp'
|
||||
post:
|
||||
tags:
|
||||
- PkgdashService
|
||||
operationId: CommentsCreate
|
||||
parameters:
|
||||
- name: package_id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: uint64
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CommentsCreateReq'
|
||||
required: true
|
||||
responses:
|
||||
default:
|
||||
description: Default
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorRsp'
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CommentsCreateRsp'
|
||||
/v1/packages/{package_id}/comments/{id}:
|
||||
delete:
|
||||
tags:
|
||||
- PkgdashService
|
||||
operationId: CommentsDelete
|
||||
parameters:
|
||||
- name: package_id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: uint64
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: uint64
|
||||
responses:
|
||||
default:
|
||||
description: Default
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorRsp'
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CommentsDeleteRsp'
|
||||
components:
|
||||
schemas:
|
||||
AddCommentReq:
|
||||
type: object
|
||||
properties:
|
||||
idPackage:
|
||||
type: integer
|
||||
format: uint64
|
||||
text:
|
||||
type: string
|
||||
AddCommentRsp:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: uint64
|
||||
AddPackageReq:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
modules:
|
||||
type: array
|
||||
items:
|
||||
type: integer
|
||||
format: uint64
|
||||
AddPackageRsp:
|
||||
type: object
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
Comment:
|
||||
type: object
|
||||
properties:
|
||||
@ -206,9 +250,39 @@ components:
|
||||
type: string
|
||||
created:
|
||||
type: string
|
||||
format: RFC3339
|
||||
updated:
|
||||
type: string
|
||||
Error:
|
||||
format: RFC3339
|
||||
CommentsCreateReq:
|
||||
type: object
|
||||
properties:
|
||||
package_id:
|
||||
type: integer
|
||||
format: uint64
|
||||
text:
|
||||
type: string
|
||||
CommentsCreateRsp:
|
||||
type: object
|
||||
properties:
|
||||
comment:
|
||||
$ref: '#/components/schemas/Comment'
|
||||
CommentsDeleteRsp:
|
||||
type: object
|
||||
properties: {}
|
||||
CommentsListRsp:
|
||||
type: object
|
||||
properties:
|
||||
comments:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Comment'
|
||||
CommentsLookupRsp:
|
||||
type: object
|
||||
properties:
|
||||
comment:
|
||||
$ref: '#/components/schemas/Comment'
|
||||
ErrorRsp:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
@ -219,32 +293,6 @@ components:
|
||||
type: string
|
||||
details:
|
||||
type: string
|
||||
ErrorRsp:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
$ref: '#/components/schemas/Error'
|
||||
GetCommentsRsp:
|
||||
type: object
|
||||
properties:
|
||||
comments:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Comment'
|
||||
GetModuleRsp:
|
||||
type: object
|
||||
properties:
|
||||
modules:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Module'
|
||||
ListPackageRsp:
|
||||
type: object
|
||||
properties:
|
||||
packages:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Package'
|
||||
Module:
|
||||
type: object
|
||||
properties:
|
||||
@ -260,6 +308,19 @@ components:
|
||||
format: uint64
|
||||
last_version:
|
||||
type: string
|
||||
created:
|
||||
type: string
|
||||
format: RFC3339
|
||||
updated:
|
||||
type: string
|
||||
format: RFC3339
|
||||
ModulesListRsp:
|
||||
type: object
|
||||
properties:
|
||||
modules:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Module'
|
||||
Package:
|
||||
type: object
|
||||
properties:
|
||||
@ -285,7 +346,40 @@ components:
|
||||
items:
|
||||
type: integer
|
||||
format: uint64
|
||||
UpdatePackageReq:
|
||||
created:
|
||||
type: string
|
||||
format: RFC3339
|
||||
updated:
|
||||
type: string
|
||||
format: RFC3339
|
||||
PackagesCreateReq:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
modules:
|
||||
type: array
|
||||
items:
|
||||
type: integer
|
||||
format: uint64
|
||||
PackagesCreateRsp:
|
||||
type: object
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
PackagesDeleteRsp:
|
||||
type: object
|
||||
properties: {}
|
||||
PackagesListRsp:
|
||||
type: object
|
||||
properties:
|
||||
packages:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Package'
|
||||
PackagesUpdateReq:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
@ -305,11 +399,10 @@ components:
|
||||
items:
|
||||
type: integer
|
||||
format: uint64
|
||||
UpdatePackageRsp:
|
||||
PackagesUpdateRsp:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: uint64
|
||||
package:
|
||||
$ref: '#/components/schemas/Package'
|
||||
tags:
|
||||
- name: PkgdashService
|
||||
|
1533
proto/pkgdash.pb.go
1533
proto/pkgdash.pb.go
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -2,17 +2,17 @@ syntax = "proto3";
|
||||
|
||||
package pkgdash;
|
||||
|
||||
option go_package = "go.unistack.org/unistack-org/pkgdash/proto;pkgdashpb";
|
||||
|
||||
import "api/annotations.proto";
|
||||
import "openapiv3/annotations.proto";
|
||||
import "validate/validate.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "go.unistack.org/unistack-org/pkgdash/proto;pkgdashpb";
|
||||
|
||||
service PkgdashService {
|
||||
rpc ListPackage(google.protobuf.Empty) returns (ListPackageRsp) {
|
||||
rpc PackagesCreate(PackagesCreateReq) returns (PackagesCreateRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "ListPackage";
|
||||
operation_id: "PackagesCreate";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
@ -20,84 +20,113 @@ service PkgdashService {
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
get: "/v1/packages";
|
||||
};
|
||||
};
|
||||
rpc UpdatePackage(UpdatePackageReq) returns (UpdatePackageRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "UpdateInfo";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
post: "/v1/package/{id}";
|
||||
post: "/v1/packages";
|
||||
body: "*";
|
||||
};
|
||||
};
|
||||
rpc AddComment(AddCommentReq) returns (AddCommentRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "AddComment";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
post: "/v1/package/{pkg}/comment";
|
||||
body: "*";
|
||||
};
|
||||
};
|
||||
rpc AddPackage(AddPackageReq) returns (AddPackageRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "AddPackage";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
post: "/v1/package";
|
||||
body: "*";
|
||||
};
|
||||
};
|
||||
rpc GetModule(GetModuleReq) returns (GetModuleRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "GetModule";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
get: "/v1/module";
|
||||
};
|
||||
};
|
||||
rpc GetComments(GetCommentsReq) returns (GetCommentsRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "GetComments";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
get: "/v1/comment";
|
||||
};
|
||||
}
|
||||
rpc PackagesDelete(PackagesDeleteReq) returns (PackagesDeleteRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "PackagesDelete";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {delete: "/v1/packages/{id}"};
|
||||
}
|
||||
rpc PackagesList(PackagesListReq) returns (PackagesListRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "PackagesList";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {get: "/v1/packages"};
|
||||
}
|
||||
rpc PackagesUpdate(PackagesUpdateReq) returns (PackagesUpdateRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "PackagesUpdate";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
put: "/v1/packages/{id}";
|
||||
body: "*";
|
||||
};
|
||||
}
|
||||
rpc CommentsCreate(CommentsCreateReq) returns (CommentsCreateRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "CommentsCreate";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
post: "/v1/packages/{package_id}/comments";
|
||||
body: "*";
|
||||
};
|
||||
}
|
||||
rpc CommentsLookup(CommentsLookupReq) returns (CommentsLookupRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "CommentsLookup";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
get: "/v1/comments/{id}/comments";
|
||||
additional_bindings {get: "/v1/comments/{package_id}/comments/{id}"};
|
||||
};
|
||||
}
|
||||
rpc CommentsList(CommentsListReq) returns (CommentsListRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "CommentsList";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {get: "/v1/packages/{package_id}/comments"};
|
||||
}
|
||||
rpc CommentsDelete(CommentsDeleteReq) returns (CommentsDeleteRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "CommentsDelete";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
delete: "/v1/packages/{package_id}/comments/{id}";
|
||||
additional_bindings {delete: "/v1/comments/{id}"};
|
||||
};
|
||||
}
|
||||
rpc ModulesList(ModulesListReq) returns (ModulesListRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "ModulesList";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {get: "/v1/modules"};
|
||||
}
|
||||
}
|
||||
|
||||
message ErrorRsp {
|
||||
Error error = 1 [json_name = "error"];
|
||||
}
|
||||
|
||||
message Error {
|
||||
string code = 1 [json_name = "code"];
|
||||
string title = 2 [json_name = "title"];
|
||||
string uuid = 3 [json_name = "uuid"];
|
||||
@ -111,7 +140,9 @@ message Package {
|
||||
repeated uint64 modules = 4;
|
||||
repeated uint64 issues = 5;
|
||||
repeated uint64 comments = 6;
|
||||
};
|
||||
google.protobuf.Timestamp created = 7;
|
||||
google.protobuf.Timestamp updated = 8;
|
||||
}
|
||||
|
||||
message Module {
|
||||
uint64 id = 1 [(validate.rules).uint64.gt = 0];
|
||||
@ -119,6 +150,8 @@ message Module {
|
||||
string version = 3 [(validate.rules).string.min_len = 1];
|
||||
uint64 package = 4 [(validate.rules).uint64.gt = 0];
|
||||
string last_version = 5 [(validate.rules).string.min_len = 1];
|
||||
google.protobuf.Timestamp created = 6;
|
||||
google.protobuf.Timestamp updated = 7;
|
||||
}
|
||||
|
||||
message Issue {
|
||||
@ -127,75 +160,90 @@ message Issue {
|
||||
string desc = 3 [(validate.rules).string.min_len = 1];
|
||||
uint64 package = 4 [(validate.rules).uint64.gt = 0];
|
||||
repeated uint64 modules = 5;
|
||||
google.protobuf.Timestamp created = 6;
|
||||
google.protobuf.Timestamp updated = 7;
|
||||
}
|
||||
|
||||
message Comment {
|
||||
uint64 id = 1 [(validate.rules).uint64.gt = 0];
|
||||
uint64 package = 2 [(validate.rules).uint64.gt = 0];
|
||||
string text = 3;
|
||||
string created = 4 ;
|
||||
string updated = 5 ;
|
||||
google.protobuf.Timestamp created = 4;
|
||||
google.protobuf.Timestamp updated = 5;
|
||||
}
|
||||
|
||||
message ListPackageReq {}
|
||||
message ListPackageRsp{
|
||||
message CommentsDeleteReq {
|
||||
uint64 id = 1 [json_name = "id"];
|
||||
uint64 package_id = 2 [json_name = "package_id"];
|
||||
}
|
||||
|
||||
message CommentsDeleteRsp {}
|
||||
|
||||
message PackagesDeleteReq {
|
||||
uint64 id = 1 [json_name = "id"];
|
||||
}
|
||||
|
||||
message PackagesDeleteRsp {}
|
||||
|
||||
message PackagesListReq {}
|
||||
|
||||
message PackagesListRsp {
|
||||
repeated Package packages = 1;
|
||||
}
|
||||
|
||||
message UpdatePackageReq {
|
||||
message PackagesUpdateReq {
|
||||
uint64 id = 1 [(validate.rules).uint64.gt = 0];
|
||||
string name = 2 [(validate.rules).string.min_len = 1];
|
||||
string url = 3 [(validate.rules).string.min_len = 1];
|
||||
repeated uint64 modules = 4;
|
||||
repeated uint64 issues = 5;
|
||||
}
|
||||
message UpdatePackageRsp {
|
||||
uint64 id = 1 [(validate.rules).uint64.gt = 0];
|
||||
|
||||
message PackagesUpdateRsp {
|
||||
Package package = 1 [json_name = "package"];
|
||||
}
|
||||
|
||||
message CommentReq {
|
||||
uint64 pkg = 1 [(validate.rules).uint64.gt = 0];
|
||||
message CommentsCreateReq {
|
||||
uint64 package_id = 1 [
|
||||
json_name = "package_id",
|
||||
(validate.rules).uint64.gt = 0
|
||||
];
|
||||
string text = 2;
|
||||
}
|
||||
|
||||
message AddCommentReq {
|
||||
uint64 idPackage = 1 [(validate.rules).uint64.gt = 0];
|
||||
string text = 2;
|
||||
message CommentsCreateRsp {
|
||||
Comment comment = 1 [json_name = "comment"];
|
||||
}
|
||||
|
||||
message AddCommentRsp {
|
||||
uint64 id = 1 [(validate.rules).uint64.gt = 0];
|
||||
}
|
||||
|
||||
message AddPackageReq {
|
||||
message PackagesCreateReq {
|
||||
string name = 1 [(validate.rules).string.min_len = 1];
|
||||
string url = 2 [(validate.rules).string.min_len = 1];
|
||||
repeated uint64 modules = 3;
|
||||
}
|
||||
|
||||
message AddPackageRsp{
|
||||
message PackagesCreateRsp {
|
||||
string status = 1 [(validate.rules).string.min_len = 1];
|
||||
}
|
||||
|
||||
message GetModuleReq {
|
||||
repeated uint64 id = 1 ;
|
||||
}
|
||||
message GetModuleRsp {
|
||||
message ModulesListReq {}
|
||||
|
||||
message ModulesListRsp {
|
||||
repeated Module modules = 1;
|
||||
}
|
||||
|
||||
message GetCommentsReq {
|
||||
repeated uint64 id = 1 [(validate.rules).repeated = {
|
||||
unique: true
|
||||
min_items: 1
|
||||
items: {
|
||||
uint64: {
|
||||
gt: 0
|
||||
}
|
||||
}
|
||||
}] ;
|
||||
message CommentsListReq {
|
||||
uint64 package_id = 1 [json_name = "package_id"];
|
||||
}
|
||||
|
||||
message GetCommentsRsp {
|
||||
repeated Comment comments = 1;
|
||||
message CommentsListRsp {
|
||||
repeated Comment comments = 1 [json_name = "comments"];
|
||||
}
|
||||
|
||||
message CommentsLookupReq {
|
||||
uint64 id = 1 [json_name = "id"];
|
||||
uint64 package_id = 2 [json_name = "package_id"];
|
||||
}
|
||||
|
||||
message CommentsLookupRsp {
|
||||
Comment comment = 1 [json_name = "comment"];
|
||||
}
|
@ -10,7 +10,6 @@ import (
|
||||
context "context"
|
||||
_ "go.unistack.org/micro/v4/client"
|
||||
options "go.unistack.org/micro/v4/options"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -18,19 +17,25 @@ var (
|
||||
)
|
||||
|
||||
type PkgdashServiceClient interface {
|
||||
ListPackage(ctx context.Context, req *emptypb.Empty, opts ...options.Option) (*ListPackageRsp, error)
|
||||
UpdatePackage(ctx context.Context, req *UpdatePackageReq, opts ...options.Option) (*UpdatePackageRsp, error)
|
||||
AddComment(ctx context.Context, req *AddCommentReq, opts ...options.Option) (*AddCommentRsp, error)
|
||||
AddPackage(ctx context.Context, req *AddPackageReq, opts ...options.Option) (*AddPackageRsp, error)
|
||||
GetModule(ctx context.Context, req *GetModuleReq, opts ...options.Option) (*GetModuleRsp, error)
|
||||
GetComments(ctx context.Context, req *GetCommentsReq, opts ...options.Option) (*GetCommentsRsp, error)
|
||||
PackagesCreate(ctx context.Context, req *PackagesCreateReq, opts ...options.Option) (*PackagesCreateRsp, error)
|
||||
PackagesDelete(ctx context.Context, req *PackagesDeleteReq, opts ...options.Option) (*PackagesDeleteRsp, error)
|
||||
PackagesList(ctx context.Context, req *PackagesListReq, opts ...options.Option) (*PackagesListRsp, error)
|
||||
PackagesUpdate(ctx context.Context, req *PackagesUpdateReq, opts ...options.Option) (*PackagesUpdateRsp, error)
|
||||
CommentsCreate(ctx context.Context, req *CommentsCreateReq, opts ...options.Option) (*CommentsCreateRsp, error)
|
||||
CommentsLookup(ctx context.Context, req *CommentsLookupReq, opts ...options.Option) (*CommentsLookupRsp, error)
|
||||
CommentsList(ctx context.Context, req *CommentsListReq, opts ...options.Option) (*CommentsListRsp, error)
|
||||
CommentsDelete(ctx context.Context, req *CommentsDeleteReq, opts ...options.Option) (*CommentsDeleteRsp, error)
|
||||
ModulesList(ctx context.Context, req *ModulesListReq, opts ...options.Option) (*ModulesListRsp, error)
|
||||
}
|
||||
|
||||
type PkgdashServiceServer interface {
|
||||
ListPackage(ctx context.Context, req *emptypb.Empty, rsp *ListPackageRsp) error
|
||||
UpdatePackage(ctx context.Context, req *UpdatePackageReq, rsp *UpdatePackageRsp) error
|
||||
AddComment(ctx context.Context, req *AddCommentReq, rsp *AddCommentRsp) error
|
||||
AddPackage(ctx context.Context, req *AddPackageReq, rsp *AddPackageRsp) error
|
||||
GetModule(ctx context.Context, req *GetModuleReq, rsp *GetModuleRsp) error
|
||||
GetComments(ctx context.Context, req *GetCommentsReq, rsp *GetCommentsRsp) error
|
||||
PackagesCreate(ctx context.Context, req *PackagesCreateReq, rsp *PackagesCreateRsp) error
|
||||
PackagesDelete(ctx context.Context, req *PackagesDeleteReq, rsp *PackagesDeleteRsp) error
|
||||
PackagesList(ctx context.Context, req *PackagesListReq, rsp *PackagesListRsp) error
|
||||
PackagesUpdate(ctx context.Context, req *PackagesUpdateReq, rsp *PackagesUpdateRsp) error
|
||||
CommentsCreate(ctx context.Context, req *CommentsCreateReq, rsp *CommentsCreateRsp) error
|
||||
CommentsLookup(ctx context.Context, req *CommentsLookupReq, rsp *CommentsLookupRsp) error
|
||||
CommentsList(ctx context.Context, req *CommentsListReq, rsp *CommentsListRsp) error
|
||||
CommentsDelete(ctx context.Context, req *CommentsDeleteReq, rsp *CommentsDeleteRsp) error
|
||||
ModulesList(ctx context.Context, req *ModulesListReq, rsp *ModulesListRsp) error
|
||||
}
|
||||
|
@ -11,50 +11,84 @@ import (
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
options "go.unistack.org/micro/v4/options"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
http "net/http"
|
||||
)
|
||||
|
||||
var (
|
||||
PkgdashServiceServerEndpoints = []v4.EndpointMetadata{
|
||||
{
|
||||
Name: "PkgdashService.ListPackage",
|
||||
Name: "PkgdashService.PackagesCreate",
|
||||
Path: "/v1/packages",
|
||||
Method: "POST",
|
||||
Body: "*",
|
||||
Stream: false,
|
||||
},
|
||||
{
|
||||
Name: "PkgdashService.PackagesDelete",
|
||||
Path: "/v1/packages/{id}",
|
||||
Method: "DELETE",
|
||||
Body: "",
|
||||
Stream: false,
|
||||
},
|
||||
{
|
||||
Name: "PkgdashService.PackagesList",
|
||||
Path: "/v1/packages",
|
||||
Method: "GET",
|
||||
Body: "",
|
||||
Stream: false,
|
||||
},
|
||||
{
|
||||
Name: "PkgdashService.UpdatePackage",
|
||||
Path: "/v1/package/{id}",
|
||||
Name: "PkgdashService.PackagesUpdate",
|
||||
Path: "/v1/packages/{id}",
|
||||
Method: "PUT",
|
||||
Body: "*",
|
||||
Stream: false,
|
||||
},
|
||||
{
|
||||
Name: "PkgdashService.CommentsCreate",
|
||||
Path: "/v1/packages/{package_id}/comments",
|
||||
Method: "POST",
|
||||
Body: "*",
|
||||
Stream: false,
|
||||
},
|
||||
{
|
||||
Name: "PkgdashService.AddComment",
|
||||
Path: "/v1/package/{pkg}/comment",
|
||||
Method: "POST",
|
||||
Body: "*",
|
||||
Stream: false,
|
||||
},
|
||||
{
|
||||
Name: "PkgdashService.AddPackage",
|
||||
Path: "/v1/package",
|
||||
Method: "POST",
|
||||
Body: "*",
|
||||
Stream: false,
|
||||
},
|
||||
{
|
||||
Name: "PkgdashService.GetModule",
|
||||
Path: "/v1/module",
|
||||
Name: "PkgdashService.CommentsLookup",
|
||||
Path: "/v1/comments/{id}/comments",
|
||||
Method: "GET",
|
||||
Body: "",
|
||||
Stream: false,
|
||||
},
|
||||
{
|
||||
Name: "PkgdashService.GetComments",
|
||||
Path: "/v1/comment",
|
||||
Name: "PkgdashService.CommentsLookup",
|
||||
Path: "/v1/comments/{package_id}/comments/{id}",
|
||||
Method: "GET",
|
||||
Body: "",
|
||||
Stream: false,
|
||||
},
|
||||
{
|
||||
Name: "PkgdashService.CommentsList",
|
||||
Path: "/v1/packages/{package_id}/comments",
|
||||
Method: "GET",
|
||||
Body: "",
|
||||
Stream: false,
|
||||
},
|
||||
{
|
||||
Name: "PkgdashService.CommentsDelete",
|
||||
Path: "/v1/packages/{package_id}/comments/{id}",
|
||||
Method: "DELETE",
|
||||
Body: "",
|
||||
Stream: false,
|
||||
},
|
||||
{
|
||||
Name: "PkgdashService.CommentsDelete",
|
||||
Path: "/v1/comments/{id}",
|
||||
Method: "DELETE",
|
||||
Body: "",
|
||||
Stream: false,
|
||||
},
|
||||
{
|
||||
Name: "PkgdashService.ModulesList",
|
||||
Path: "/v1/modules",
|
||||
Method: "GET",
|
||||
Body: "",
|
||||
Stream: false,
|
||||
@ -71,7 +105,44 @@ func NewPkgdashServiceClient(name string, c client.Client) PkgdashServiceClient
|
||||
return &pkgdashServiceClient{c: c, name: name}
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) ListPackage(ctx context.Context, req *emptypb.Empty, opts ...options.Option) (*ListPackageRsp, error) {
|
||||
func (c *pkgdashServiceClient) PackagesCreate(ctx context.Context, req *PackagesCreateReq, opts ...options.Option) (*PackagesCreateRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
v41.ErrorMap(errmap),
|
||||
)
|
||||
opts = append(opts,
|
||||
v41.Method(http.MethodPost),
|
||||
v41.Path("/v1/packages"),
|
||||
v41.Body("*"),
|
||||
)
|
||||
rsp := &PackagesCreateRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.PackagesCreate", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) PackagesDelete(ctx context.Context, req *PackagesDeleteReq, opts ...options.Option) (*PackagesDeleteRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
v41.ErrorMap(errmap),
|
||||
)
|
||||
opts = append(opts,
|
||||
v41.Method(http.MethodDelete),
|
||||
v41.Path("/v1/packages/{id}"),
|
||||
)
|
||||
rsp := &PackagesDeleteRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.PackagesDelete", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) PackagesList(ctx context.Context, req *PackagesListReq, opts ...options.Option) (*PackagesListRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
@ -81,15 +152,34 @@ func (c *pkgdashServiceClient) ListPackage(ctx context.Context, req *emptypb.Emp
|
||||
v41.Method(http.MethodGet),
|
||||
v41.Path("/v1/packages"),
|
||||
)
|
||||
rsp := &ListPackageRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.ListPackage", req), rsp, opts...)
|
||||
rsp := &PackagesListRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.PackagesList", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) UpdatePackage(ctx context.Context, req *UpdatePackageReq, opts ...options.Option) (*UpdatePackageRsp, error) {
|
||||
func (c *pkgdashServiceClient) PackagesUpdate(ctx context.Context, req *PackagesUpdateReq, opts ...options.Option) (*PackagesUpdateRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
v41.ErrorMap(errmap),
|
||||
)
|
||||
opts = append(opts,
|
||||
v41.Method(http.MethodPut),
|
||||
v41.Path("/v1/packages/{id}"),
|
||||
v41.Body("*"),
|
||||
)
|
||||
rsp := &PackagesUpdateRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.PackagesUpdate", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) CommentsCreate(ctx context.Context, req *CommentsCreateReq, opts ...options.Option) (*CommentsCreateRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
@ -97,56 +187,18 @@ func (c *pkgdashServiceClient) UpdatePackage(ctx context.Context, req *UpdatePac
|
||||
)
|
||||
opts = append(opts,
|
||||
v41.Method(http.MethodPost),
|
||||
v41.Path("/v1/package/{id}"),
|
||||
v41.Path("/v1/packages/{package_id}/comments"),
|
||||
v41.Body("*"),
|
||||
)
|
||||
rsp := &UpdatePackageRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.UpdatePackage", req), rsp, opts...)
|
||||
rsp := &CommentsCreateRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.CommentsCreate", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) AddComment(ctx context.Context, req *AddCommentReq, opts ...options.Option) (*AddCommentRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
v41.ErrorMap(errmap),
|
||||
)
|
||||
opts = append(opts,
|
||||
v41.Method(http.MethodPost),
|
||||
v41.Path("/v1/package/{pkg}/comment"),
|
||||
v41.Body("*"),
|
||||
)
|
||||
rsp := &AddCommentRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.AddComment", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) AddPackage(ctx context.Context, req *AddPackageReq, opts ...options.Option) (*AddPackageRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
v41.ErrorMap(errmap),
|
||||
)
|
||||
opts = append(opts,
|
||||
v41.Method(http.MethodPost),
|
||||
v41.Path("/v1/package"),
|
||||
v41.Body("*"),
|
||||
)
|
||||
rsp := &AddPackageRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.AddPackage", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) GetModule(ctx context.Context, req *GetModuleReq, opts ...options.Option) (*GetModuleRsp, error) {
|
||||
func (c *pkgdashServiceClient) CommentsLookup(ctx context.Context, req *CommentsLookupReq, opts ...options.Option) (*CommentsLookupRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
@ -154,17 +206,17 @@ func (c *pkgdashServiceClient) GetModule(ctx context.Context, req *GetModuleReq,
|
||||
)
|
||||
opts = append(opts,
|
||||
v41.Method(http.MethodGet),
|
||||
v41.Path("/v1/module"),
|
||||
v41.Path("/v1/comments/{id}/comments"),
|
||||
)
|
||||
rsp := &GetModuleRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.GetModule", req), rsp, opts...)
|
||||
rsp := &CommentsLookupRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.CommentsLookup", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) GetComments(ctx context.Context, req *GetCommentsReq, opts ...options.Option) (*GetCommentsRsp, error) {
|
||||
func (c *pkgdashServiceClient) CommentsList(ctx context.Context, req *CommentsListReq, opts ...options.Option) (*CommentsListRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
@ -172,10 +224,46 @@ func (c *pkgdashServiceClient) GetComments(ctx context.Context, req *GetComments
|
||||
)
|
||||
opts = append(opts,
|
||||
v41.Method(http.MethodGet),
|
||||
v41.Path("/v1/comment"),
|
||||
v41.Path("/v1/packages/{package_id}/comments"),
|
||||
)
|
||||
rsp := &GetCommentsRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.GetComments", req), rsp, opts...)
|
||||
rsp := &CommentsListRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.CommentsList", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) CommentsDelete(ctx context.Context, req *CommentsDeleteReq, opts ...options.Option) (*CommentsDeleteRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
v41.ErrorMap(errmap),
|
||||
)
|
||||
opts = append(opts,
|
||||
v41.Method(http.MethodDelete),
|
||||
v41.Path("/v1/packages/{package_id}/comments/{id}"),
|
||||
)
|
||||
rsp := &CommentsDeleteRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.CommentsDelete", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) ModulesList(ctx context.Context, req *ModulesListReq, opts ...options.Option) (*ModulesListRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
v41.ErrorMap(errmap),
|
||||
)
|
||||
opts = append(opts,
|
||||
v41.Method(http.MethodGet),
|
||||
v41.Path("/v1/modules"),
|
||||
)
|
||||
rsp := &ModulesListRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.ModulesList", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -186,38 +274,53 @@ type pkgdashServiceServer struct {
|
||||
PkgdashServiceServer
|
||||
}
|
||||
|
||||
func (h *pkgdashServiceServer) ListPackage(ctx context.Context, req *emptypb.Empty, rsp *ListPackageRsp) error {
|
||||
return h.PkgdashServiceServer.ListPackage(ctx, req, rsp)
|
||||
func (h *pkgdashServiceServer) PackagesCreate(ctx context.Context, req *PackagesCreateReq, rsp *PackagesCreateRsp) error {
|
||||
return h.PkgdashServiceServer.PackagesCreate(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *pkgdashServiceServer) UpdatePackage(ctx context.Context, req *UpdatePackageReq, rsp *UpdatePackageRsp) error {
|
||||
return h.PkgdashServiceServer.UpdatePackage(ctx, req, rsp)
|
||||
func (h *pkgdashServiceServer) PackagesDelete(ctx context.Context, req *PackagesDeleteReq, rsp *PackagesDeleteRsp) error {
|
||||
return h.PkgdashServiceServer.PackagesDelete(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *pkgdashServiceServer) AddComment(ctx context.Context, req *AddCommentReq, rsp *AddCommentRsp) error {
|
||||
return h.PkgdashServiceServer.AddComment(ctx, req, rsp)
|
||||
func (h *pkgdashServiceServer) PackagesList(ctx context.Context, req *PackagesListReq, rsp *PackagesListRsp) error {
|
||||
return h.PkgdashServiceServer.PackagesList(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *pkgdashServiceServer) AddPackage(ctx context.Context, req *AddPackageReq, rsp *AddPackageRsp) error {
|
||||
return h.PkgdashServiceServer.AddPackage(ctx, req, rsp)
|
||||
func (h *pkgdashServiceServer) PackagesUpdate(ctx context.Context, req *PackagesUpdateReq, rsp *PackagesUpdateRsp) error {
|
||||
return h.PkgdashServiceServer.PackagesUpdate(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *pkgdashServiceServer) GetModule(ctx context.Context, req *GetModuleReq, rsp *GetModuleRsp) error {
|
||||
return h.PkgdashServiceServer.GetModule(ctx, req, rsp)
|
||||
func (h *pkgdashServiceServer) CommentsCreate(ctx context.Context, req *CommentsCreateReq, rsp *CommentsCreateRsp) error {
|
||||
return h.PkgdashServiceServer.CommentsCreate(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *pkgdashServiceServer) GetComments(ctx context.Context, req *GetCommentsReq, rsp *GetCommentsRsp) error {
|
||||
return h.PkgdashServiceServer.GetComments(ctx, req, rsp)
|
||||
func (h *pkgdashServiceServer) CommentsLookup(ctx context.Context, req *CommentsLookupReq, rsp *CommentsLookupRsp) error {
|
||||
return h.PkgdashServiceServer.CommentsLookup(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *pkgdashServiceServer) CommentsList(ctx context.Context, req *CommentsListReq, rsp *CommentsListRsp) error {
|
||||
return h.PkgdashServiceServer.CommentsList(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *pkgdashServiceServer) CommentsDelete(ctx context.Context, req *CommentsDeleteReq, rsp *CommentsDeleteRsp) error {
|
||||
return h.PkgdashServiceServer.CommentsDelete(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *pkgdashServiceServer) ModulesList(ctx context.Context, req *ModulesListReq, rsp *ModulesListRsp) error {
|
||||
return h.PkgdashServiceServer.ModulesList(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func RegisterPkgdashServiceServer(s server.Server, sh PkgdashServiceServer, opts ...options.Option) error {
|
||||
type pkgdashService interface {
|
||||
ListPackage(ctx context.Context, req *emptypb.Empty, rsp *ListPackageRsp) error
|
||||
UpdatePackage(ctx context.Context, req *UpdatePackageReq, rsp *UpdatePackageRsp) error
|
||||
AddComment(ctx context.Context, req *AddCommentReq, rsp *AddCommentRsp) error
|
||||
AddPackage(ctx context.Context, req *AddPackageReq, rsp *AddPackageRsp) error
|
||||
GetModule(ctx context.Context, req *GetModuleReq, rsp *GetModuleRsp) error
|
||||
GetComments(ctx context.Context, req *GetCommentsReq, rsp *GetCommentsRsp) error
|
||||
PackagesCreate(ctx context.Context, req *PackagesCreateReq, rsp *PackagesCreateRsp) error
|
||||
PackagesDelete(ctx context.Context, req *PackagesDeleteReq, rsp *PackagesDeleteRsp) error
|
||||
PackagesList(ctx context.Context, req *PackagesListReq, rsp *PackagesListRsp) error
|
||||
PackagesUpdate(ctx context.Context, req *PackagesUpdateReq, rsp *PackagesUpdateRsp) error
|
||||
CommentsCreate(ctx context.Context, req *CommentsCreateReq, rsp *CommentsCreateRsp) error
|
||||
CommentsLookup(ctx context.Context, req *CommentsLookupReq, rsp *CommentsLookupRsp) error
|
||||
CommentsList(ctx context.Context, req *CommentsListReq, rsp *CommentsListRsp) error
|
||||
CommentsDelete(ctx context.Context, req *CommentsDeleteReq, rsp *CommentsDeleteRsp) error
|
||||
ModulesList(ctx context.Context, req *ModulesListReq, rsp *ModulesListRsp) error
|
||||
}
|
||||
type PkgdashService struct {
|
||||
pkgdashService
|
||||
|
@ -1,71 +0,0 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"embed"
|
||||
"errors"
|
||||
|
||||
"go.unistack.org/unistack-org/pkgdash/models"
|
||||
pb "go.unistack.org/unistack-org/pkgdash/proto"
|
||||
"go.unistack.org/unistack-org/pkgdash/storage/postgres"
|
||||
"go.unistack.org/unistack-org/pkgdash/storage/sqlite"
|
||||
)
|
||||
|
||||
//go:embed migrations
|
||||
var fs embed.FS
|
||||
|
||||
var (
|
||||
storages = map[string]func(*sql.DB, embed.FS) interface{}{
|
||||
"postgres": postgres.NewStorage(),
|
||||
"sqlite": sqlite.NewStorage(),
|
||||
}
|
||||
)
|
||||
|
||||
type contextKey string
|
||||
|
||||
var (
|
||||
storeIdent = contextKey("store")
|
||||
)
|
||||
|
||||
type Migrate interface {
|
||||
MigrateUp() error
|
||||
MigrateDown() error
|
||||
}
|
||||
|
||||
type Storage interface {
|
||||
Migrate
|
||||
|
||||
ListPackage(ctx context.Context) (models.ListPackage, error)
|
||||
UpdatePackage(ctx context.Context, req *pb.UpdatePackageReq) error
|
||||
AddComment(ctx context.Context, req *pb.AddCommentReq) (uint64, error)
|
||||
AddPackage(ctx context.Context, req *pb.AddPackageReq) error
|
||||
InsertButchModules(ctx context.Context, req []models.Module) ([]uint64, error)
|
||||
GetModule(ctx context.Context, req *pb.GetModuleReq) (models.ListModule, error)
|
||||
GetComment(ctx context.Context, req *pb.GetCommentsReq) (models.ListComment, error)
|
||||
}
|
||||
|
||||
func NewStorage(name string, db *sql.DB) (Storage, error) {
|
||||
function, ok := storages[name]
|
||||
if !ok {
|
||||
return nil, errors.New("incorrect name store")
|
||||
}
|
||||
store := function(db, fs)
|
||||
database, ok := store.(Storage)
|
||||
if !ok {
|
||||
return nil, errors.New("dont implements interface Storage")
|
||||
}
|
||||
return database, nil
|
||||
}
|
||||
|
||||
func InContext(ctx context.Context, val Storage) context.Context {
|
||||
return context.WithValue(ctx, storeIdent, val)
|
||||
}
|
||||
|
||||
func FromContext(ctx context.Context) (Storage, error) {
|
||||
if store, ok := ctx.Value(storeIdent).(Storage); !ok {
|
||||
return nil, errors.New("empty store")
|
||||
} else {
|
||||
return store, nil
|
||||
}
|
||||
}
|
@ -1,16 +1,18 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export { AddCommentReq } from './models/add-comment-req';
|
||||
export { AddCommentRsp } from './models/add-comment-rsp';
|
||||
export { AddPackageReq } from './models/add-package-req';
|
||||
export { AddPackageRsp } from './models/add-package-rsp';
|
||||
export { Comment } from './models/comment';
|
||||
export { Error } from './models/error';
|
||||
export { CommentsCreateReq } from './models/comments-create-req';
|
||||
export { CommentsCreateRsp } from './models/comments-create-rsp';
|
||||
export { CommentsDeleteRsp } from './models/comments-delete-rsp';
|
||||
export { CommentsListRsp } from './models/comments-list-rsp';
|
||||
export { CommentsLookupRsp } from './models/comments-lookup-rsp';
|
||||
export { ErrorRsp } from './models/error-rsp';
|
||||
export { GetCommentsRsp } from './models/get-comments-rsp';
|
||||
export { GetModuleRsp } from './models/get-module-rsp';
|
||||
export { ListPackageRsp } from './models/list-package-rsp';
|
||||
export { Module } from './models/module';
|
||||
export { ModulesListRsp } from './models/modules-list-rsp';
|
||||
export { Package } from './models/package';
|
||||
export { UpdatePackageReq } from './models/update-package-req';
|
||||
export { UpdatePackageRsp } from './models/update-package-rsp';
|
||||
export { PackagesCreateReq } from './models/packages-create-req';
|
||||
export { PackagesCreateRsp } from './models/packages-create-rsp';
|
||||
export { PackagesDeleteRsp } from './models/packages-delete-rsp';
|
||||
export { PackagesListRsp } from './models/packages-list-rsp';
|
||||
export { PackagesUpdateReq } from './models/packages-update-req';
|
||||
export { PackagesUpdateRsp } from './models/packages-update-rsp';
|
||||
|
@ -1,5 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export interface AddCommentRsp {
|
||||
id?: number;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export interface AddCommentReq {
|
||||
idPackage?: number;
|
||||
export interface CommentsCreateReq {
|
||||
package_id?: number;
|
||||
text?: string;
|
||||
}
|
6
ui/src/app/api/models/comments-create-rsp.ts
Normal file
6
ui/src/app/api/models/comments-create-rsp.ts
Normal file
@ -0,0 +1,6 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import { Comment } from './comment';
|
||||
export interface CommentsCreateRsp {
|
||||
comment?: Comment;
|
||||
}
|
4
ui/src/app/api/models/comments-delete-rsp.ts
Normal file
4
ui/src/app/api/models/comments-delete-rsp.ts
Normal file
@ -0,0 +1,4 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export interface CommentsDeleteRsp {
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import { Comment } from './comment';
|
||||
export interface GetCommentsRsp {
|
||||
export interface CommentsListRsp {
|
||||
comments?: Array<Comment>;
|
||||
}
|
6
ui/src/app/api/models/comments-lookup-rsp.ts
Normal file
6
ui/src/app/api/models/comments-lookup-rsp.ts
Normal file
@ -0,0 +1,6 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import { Comment } from './comment';
|
||||
export interface CommentsLookupRsp {
|
||||
comment?: Comment;
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import { Error } from './error';
|
||||
export interface ErrorRsp {
|
||||
error?: Error;
|
||||
code?: string;
|
||||
details?: string;
|
||||
title?: string;
|
||||
uuid?: string;
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export interface Error {
|
||||
code?: string;
|
||||
details?: string;
|
||||
title?: string;
|
||||
uuid?: string;
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export interface Module {
|
||||
created?: string;
|
||||
id?: number;
|
||||
last_version?: string;
|
||||
name?: string;
|
||||
package?: number;
|
||||
updated?: string;
|
||||
version?: string;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import { Module } from './module';
|
||||
export interface GetModuleRsp {
|
||||
export interface ModulesListRsp {
|
||||
modules?: Array<Module>;
|
||||
}
|
@ -2,9 +2,11 @@
|
||||
/* eslint-disable */
|
||||
export interface Package {
|
||||
comments?: Array<number>;
|
||||
created?: string;
|
||||
id?: number;
|
||||
issues?: Array<number>;
|
||||
modules?: Array<number>;
|
||||
name?: string;
|
||||
updated?: string;
|
||||
url?: string;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export interface AddPackageReq {
|
||||
export interface PackagesCreateReq {
|
||||
modules?: Array<number>;
|
||||
name?: string;
|
||||
url?: string;
|
@ -1,5 +1,5 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export interface AddPackageRsp {
|
||||
export interface PackagesCreateRsp {
|
||||
status?: string;
|
||||
}
|
4
ui/src/app/api/models/packages-delete-rsp.ts
Normal file
4
ui/src/app/api/models/packages-delete-rsp.ts
Normal file
@ -0,0 +1,4 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export interface PackagesDeleteRsp {
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import { Package } from './package';
|
||||
export interface ListPackageRsp {
|
||||
export interface PackagesListRsp {
|
||||
packages?: Array<Package>;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export interface UpdatePackageReq {
|
||||
export interface PackagesUpdateReq {
|
||||
id?: number;
|
||||
issues?: Array<number>;
|
||||
modules?: Array<number>;
|
6
ui/src/app/api/models/packages-update-rsp.ts
Normal file
6
ui/src/app/api/models/packages-update-rsp.ts
Normal file
@ -0,0 +1,6 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import { Package } from './package';
|
||||
export interface PackagesUpdateRsp {
|
||||
package?: Package;
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export interface UpdatePackageRsp {
|
||||
id?: number;
|
||||
}
|
@ -10,15 +10,18 @@ import { ApiConfiguration } from '../api-configuration';
|
||||
import { StrictHttpResponse } from '../strict-http-response';
|
||||
import { RequestBuilder } from '../request-builder';
|
||||
|
||||
import { AddCommentReq } from '../models/add-comment-req';
|
||||
import { AddCommentRsp } from '../models/add-comment-rsp';
|
||||
import { AddPackageReq } from '../models/add-package-req';
|
||||
import { AddPackageRsp } from '../models/add-package-rsp';
|
||||
import { GetCommentsRsp } from '../models/get-comments-rsp';
|
||||
import { GetModuleRsp } from '../models/get-module-rsp';
|
||||
import { ListPackageRsp } from '../models/list-package-rsp';
|
||||
import { UpdatePackageReq } from '../models/update-package-req';
|
||||
import { UpdatePackageRsp } from '../models/update-package-rsp';
|
||||
import { CommentsCreateReq } from '../models/comments-create-req';
|
||||
import { CommentsCreateRsp } from '../models/comments-create-rsp';
|
||||
import { CommentsDeleteRsp } from '../models/comments-delete-rsp';
|
||||
import { CommentsListRsp } from '../models/comments-list-rsp';
|
||||
import { CommentsLookupRsp } from '../models/comments-lookup-rsp';
|
||||
import { ModulesListRsp } from '../models/modules-list-rsp';
|
||||
import { PackagesCreateReq } from '../models/packages-create-req';
|
||||
import { PackagesCreateRsp } from '../models/packages-create-rsp';
|
||||
import { PackagesDeleteRsp } from '../models/packages-delete-rsp';
|
||||
import { PackagesListRsp } from '../models/packages-list-rsp';
|
||||
import { PackagesUpdateReq } from '../models/packages-update-req';
|
||||
import { PackagesUpdateRsp } from '../models/packages-update-rsp';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class PkgdashServiceService extends BaseService {
|
||||
@ -26,24 +29,26 @@ export class PkgdashServiceService extends BaseService {
|
||||
super(config, http);
|
||||
}
|
||||
|
||||
/** Path part for operation `getComments()` */
|
||||
static readonly GetCommentsPath = '/v1/comment';
|
||||
/** Path part for operation `commentsLookup()` */
|
||||
static readonly CommentsLookupPath = '/v1/comments/{id}/comments';
|
||||
|
||||
/**
|
||||
* This method provides access to the full `HttpResponse`, allowing access to response headers.
|
||||
* To access only the response body, use `getComments()` instead.
|
||||
* To access only the response body, use `commentsLookup()` instead.
|
||||
*
|
||||
* This method doesn't expect any request body.
|
||||
*/
|
||||
getComments$Response(
|
||||
params?: {
|
||||
id?: Array<number>;
|
||||
commentsLookup$Response(
|
||||
params: {
|
||||
id: number;
|
||||
package_id?: number;
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<StrictHttpResponse<GetCommentsRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.GetCommentsPath, 'get');
|
||||
): Observable<StrictHttpResponse<CommentsLookupRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.CommentsLookupPath, 'get');
|
||||
if (params) {
|
||||
rb.query('id', params.id, {});
|
||||
rb.path('id', params.id, {});
|
||||
rb.query('package_id', params.package_id, {});
|
||||
}
|
||||
|
||||
return this.http.request(
|
||||
@ -51,46 +56,45 @@ export class PkgdashServiceService extends BaseService {
|
||||
).pipe(
|
||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||
map((r: HttpResponse<any>) => {
|
||||
return r as StrictHttpResponse<GetCommentsRsp>;
|
||||
return r as StrictHttpResponse<CommentsLookupRsp>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method provides access only to the response body.
|
||||
* To access the full response (for headers, for example), `getComments$Response()` instead.
|
||||
* To access the full response (for headers, for example), `commentsLookup$Response()` instead.
|
||||
*
|
||||
* This method doesn't expect any request body.
|
||||
*/
|
||||
getComments(
|
||||
params?: {
|
||||
id?: Array<number>;
|
||||
commentsLookup(
|
||||
params: {
|
||||
id: number;
|
||||
package_id?: number;
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<GetCommentsRsp> {
|
||||
return this.getComments$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<GetCommentsRsp>): GetCommentsRsp => r.body)
|
||||
): Observable<CommentsLookupRsp> {
|
||||
return this.commentsLookup$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<CommentsLookupRsp>): CommentsLookupRsp => r.body)
|
||||
);
|
||||
}
|
||||
|
||||
/** Path part for operation `getModule()` */
|
||||
static readonly GetModulePath = '/v1/module';
|
||||
/** Path part for operation `modulesList()` */
|
||||
static readonly ModulesListPath = '/v1/modules';
|
||||
|
||||
/**
|
||||
* This method provides access to the full `HttpResponse`, allowing access to response headers.
|
||||
* To access only the response body, use `getModule()` instead.
|
||||
* To access only the response body, use `modulesList()` instead.
|
||||
*
|
||||
* This method doesn't expect any request body.
|
||||
*/
|
||||
getModule$Response(
|
||||
modulesList$Response(
|
||||
params?: {
|
||||
id?: Array<number>;
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<StrictHttpResponse<GetModuleRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.GetModulePath, 'get');
|
||||
): Observable<StrictHttpResponse<ModulesListRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.ModulesListPath, 'get');
|
||||
if (params) {
|
||||
rb.query('id', params.id, {});
|
||||
}
|
||||
|
||||
return this.http.request(
|
||||
@ -98,44 +102,87 @@ export class PkgdashServiceService extends BaseService {
|
||||
).pipe(
|
||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||
map((r: HttpResponse<any>) => {
|
||||
return r as StrictHttpResponse<GetModuleRsp>;
|
||||
return r as StrictHttpResponse<ModulesListRsp>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method provides access only to the response body.
|
||||
* To access the full response (for headers, for example), `getModule$Response()` instead.
|
||||
* To access the full response (for headers, for example), `modulesList$Response()` instead.
|
||||
*
|
||||
* This method doesn't expect any request body.
|
||||
*/
|
||||
getModule(
|
||||
modulesList(
|
||||
params?: {
|
||||
id?: Array<number>;
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<GetModuleRsp> {
|
||||
return this.getModule$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<GetModuleRsp>): GetModuleRsp => r.body)
|
||||
): Observable<ModulesListRsp> {
|
||||
return this.modulesList$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<ModulesListRsp>): ModulesListRsp => r.body)
|
||||
);
|
||||
}
|
||||
|
||||
/** Path part for operation `addPackage()` */
|
||||
static readonly AddPackagePath = '/v1/package';
|
||||
/** Path part for operation `packagesList()` */
|
||||
static readonly PackagesListPath = '/v1/packages';
|
||||
|
||||
/**
|
||||
* This method provides access to the full `HttpResponse`, allowing access to response headers.
|
||||
* To access only the response body, use `addPackage()` instead.
|
||||
* To access only the response body, use `packagesList()` instead.
|
||||
*
|
||||
* This method doesn't expect any request body.
|
||||
*/
|
||||
packagesList$Response(
|
||||
params?: {
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<StrictHttpResponse<PackagesListRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.PackagesListPath, 'get');
|
||||
if (params) {
|
||||
}
|
||||
|
||||
return this.http.request(
|
||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
||||
).pipe(
|
||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||
map((r: HttpResponse<any>) => {
|
||||
return r as StrictHttpResponse<PackagesListRsp>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method provides access only to the response body.
|
||||
* To access the full response (for headers, for example), `packagesList$Response()` instead.
|
||||
*
|
||||
* This method doesn't expect any request body.
|
||||
*/
|
||||
packagesList(
|
||||
params?: {
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<PackagesListRsp> {
|
||||
return this.packagesList$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<PackagesListRsp>): PackagesListRsp => r.body)
|
||||
);
|
||||
}
|
||||
|
||||
/** Path part for operation `packagesCreate()` */
|
||||
static readonly PackagesCreatePath = '/v1/packages';
|
||||
|
||||
/**
|
||||
* This method provides access to the full `HttpResponse`, allowing access to response headers.
|
||||
* To access only the response body, use `packagesCreate()` instead.
|
||||
*
|
||||
* This method sends `application/json` and handles request body of type `application/json`.
|
||||
*/
|
||||
addPackage$Response(
|
||||
packagesCreate$Response(
|
||||
params: {
|
||||
body: AddPackageReq
|
||||
body: PackagesCreateReq
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<StrictHttpResponse<AddPackageRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.AddPackagePath, 'post');
|
||||
): Observable<StrictHttpResponse<PackagesCreateRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.PackagesCreatePath, 'post');
|
||||
if (params) {
|
||||
rb.body(params.body, 'application/json');
|
||||
}
|
||||
@ -145,45 +192,45 @@ export class PkgdashServiceService extends BaseService {
|
||||
).pipe(
|
||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||
map((r: HttpResponse<any>) => {
|
||||
return r as StrictHttpResponse<AddPackageRsp>;
|
||||
return r as StrictHttpResponse<PackagesCreateRsp>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method provides access only to the response body.
|
||||
* To access the full response (for headers, for example), `addPackage$Response()` instead.
|
||||
* To access the full response (for headers, for example), `packagesCreate$Response()` instead.
|
||||
*
|
||||
* This method sends `application/json` and handles request body of type `application/json`.
|
||||
*/
|
||||
addPackage(
|
||||
packagesCreate(
|
||||
params: {
|
||||
body: AddPackageReq
|
||||
body: PackagesCreateReq
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<AddPackageRsp> {
|
||||
return this.addPackage$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<AddPackageRsp>): AddPackageRsp => r.body)
|
||||
): Observable<PackagesCreateRsp> {
|
||||
return this.packagesCreate$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<PackagesCreateRsp>): PackagesCreateRsp => r.body)
|
||||
);
|
||||
}
|
||||
|
||||
/** Path part for operation `updateInfo()` */
|
||||
static readonly UpdateInfoPath = '/v1/package/{id}';
|
||||
/** Path part for operation `packagesUpdate()` */
|
||||
static readonly PackagesUpdatePath = '/v1/packages/{id}';
|
||||
|
||||
/**
|
||||
* This method provides access to the full `HttpResponse`, allowing access to response headers.
|
||||
* To access only the response body, use `updateInfo()` instead.
|
||||
* To access only the response body, use `packagesUpdate()` instead.
|
||||
*
|
||||
* This method sends `application/json` and handles request body of type `application/json`.
|
||||
*/
|
||||
updateInfo$Response(
|
||||
packagesUpdate$Response(
|
||||
params: {
|
||||
id: number;
|
||||
body: UpdatePackageReq
|
||||
body: PackagesUpdateReq
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<StrictHttpResponse<UpdatePackageRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.UpdateInfoPath, 'post');
|
||||
): Observable<StrictHttpResponse<PackagesUpdateRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.PackagesUpdatePath, 'put');
|
||||
if (params) {
|
||||
rb.path('id', params.id, {});
|
||||
rb.body(params.body, 'application/json');
|
||||
@ -194,48 +241,142 @@ export class PkgdashServiceService extends BaseService {
|
||||
).pipe(
|
||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||
map((r: HttpResponse<any>) => {
|
||||
return r as StrictHttpResponse<UpdatePackageRsp>;
|
||||
return r as StrictHttpResponse<PackagesUpdateRsp>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method provides access only to the response body.
|
||||
* To access the full response (for headers, for example), `updateInfo$Response()` instead.
|
||||
* To access the full response (for headers, for example), `packagesUpdate$Response()` instead.
|
||||
*
|
||||
* This method sends `application/json` and handles request body of type `application/json`.
|
||||
*/
|
||||
updateInfo(
|
||||
packagesUpdate(
|
||||
params: {
|
||||
id: number;
|
||||
body: UpdatePackageReq
|
||||
body: PackagesUpdateReq
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<UpdatePackageRsp> {
|
||||
return this.updateInfo$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<UpdatePackageRsp>): UpdatePackageRsp => r.body)
|
||||
): Observable<PackagesUpdateRsp> {
|
||||
return this.packagesUpdate$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<PackagesUpdateRsp>): PackagesUpdateRsp => r.body)
|
||||
);
|
||||
}
|
||||
|
||||
/** Path part for operation `addComment()` */
|
||||
static readonly AddCommentPath = '/v1/package/{pkg}/comment';
|
||||
/** Path part for operation `packagesDelete()` */
|
||||
static readonly PackagesDeletePath = '/v1/packages/{id}';
|
||||
|
||||
/**
|
||||
* This method provides access to the full `HttpResponse`, allowing access to response headers.
|
||||
* To access only the response body, use `addComment()` instead.
|
||||
* To access only the response body, use `packagesDelete()` instead.
|
||||
*
|
||||
* This method doesn't expect any request body.
|
||||
*/
|
||||
packagesDelete$Response(
|
||||
params: {
|
||||
id: number;
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<StrictHttpResponse<PackagesDeleteRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.PackagesDeletePath, 'delete');
|
||||
if (params) {
|
||||
rb.path('id', params.id, {});
|
||||
}
|
||||
|
||||
return this.http.request(
|
||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
||||
).pipe(
|
||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||
map((r: HttpResponse<any>) => {
|
||||
return r as StrictHttpResponse<PackagesDeleteRsp>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method provides access only to the response body.
|
||||
* To access the full response (for headers, for example), `packagesDelete$Response()` instead.
|
||||
*
|
||||
* This method doesn't expect any request body.
|
||||
*/
|
||||
packagesDelete(
|
||||
params: {
|
||||
id: number;
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<PackagesDeleteRsp> {
|
||||
return this.packagesDelete$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<PackagesDeleteRsp>): PackagesDeleteRsp => r.body)
|
||||
);
|
||||
}
|
||||
|
||||
/** Path part for operation `commentsList()` */
|
||||
static readonly CommentsListPath = '/v1/packages/{package_id}/comments';
|
||||
|
||||
/**
|
||||
* This method provides access to the full `HttpResponse`, allowing access to response headers.
|
||||
* To access only the response body, use `commentsList()` instead.
|
||||
*
|
||||
* This method doesn't expect any request body.
|
||||
*/
|
||||
commentsList$Response(
|
||||
params: {
|
||||
package_id: number;
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<StrictHttpResponse<CommentsListRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.CommentsListPath, 'get');
|
||||
if (params) {
|
||||
rb.path('package_id', params.package_id, {});
|
||||
}
|
||||
|
||||
return this.http.request(
|
||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
||||
).pipe(
|
||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||
map((r: HttpResponse<any>) => {
|
||||
return r as StrictHttpResponse<CommentsListRsp>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method provides access only to the response body.
|
||||
* To access the full response (for headers, for example), `commentsList$Response()` instead.
|
||||
*
|
||||
* This method doesn't expect any request body.
|
||||
*/
|
||||
commentsList(
|
||||
params: {
|
||||
package_id: number;
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<CommentsListRsp> {
|
||||
return this.commentsList$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<CommentsListRsp>): CommentsListRsp => r.body)
|
||||
);
|
||||
}
|
||||
|
||||
/** Path part for operation `commentsCreate()` */
|
||||
static readonly CommentsCreatePath = '/v1/packages/{package_id}/comments';
|
||||
|
||||
/**
|
||||
* This method provides access to the full `HttpResponse`, allowing access to response headers.
|
||||
* To access only the response body, use `commentsCreate()` instead.
|
||||
*
|
||||
* This method sends `application/json` and handles request body of type `application/json`.
|
||||
*/
|
||||
addComment$Response(
|
||||
commentsCreate$Response(
|
||||
params: {
|
||||
pkg: string;
|
||||
body: AddCommentReq
|
||||
package_id: number;
|
||||
body: CommentsCreateReq
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<StrictHttpResponse<AddCommentRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.AddCommentPath, 'post');
|
||||
): Observable<StrictHttpResponse<CommentsCreateRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.CommentsCreatePath, 'post');
|
||||
if (params) {
|
||||
rb.path('pkg', params.pkg, {});
|
||||
rb.path('package_id', params.package_id, {});
|
||||
rb.body(params.body, 'application/json');
|
||||
}
|
||||
|
||||
@ -244,45 +385,49 @@ export class PkgdashServiceService extends BaseService {
|
||||
).pipe(
|
||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||
map((r: HttpResponse<any>) => {
|
||||
return r as StrictHttpResponse<AddCommentRsp>;
|
||||
return r as StrictHttpResponse<CommentsCreateRsp>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method provides access only to the response body.
|
||||
* To access the full response (for headers, for example), `addComment$Response()` instead.
|
||||
* To access the full response (for headers, for example), `commentsCreate$Response()` instead.
|
||||
*
|
||||
* This method sends `application/json` and handles request body of type `application/json`.
|
||||
*/
|
||||
addComment(
|
||||
commentsCreate(
|
||||
params: {
|
||||
pkg: string;
|
||||
body: AddCommentReq
|
||||
package_id: number;
|
||||
body: CommentsCreateReq
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<AddCommentRsp> {
|
||||
return this.addComment$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<AddCommentRsp>): AddCommentRsp => r.body)
|
||||
): Observable<CommentsCreateRsp> {
|
||||
return this.commentsCreate$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<CommentsCreateRsp>): CommentsCreateRsp => r.body)
|
||||
);
|
||||
}
|
||||
|
||||
/** Path part for operation `listPackage()` */
|
||||
static readonly ListPackagePath = '/v1/packages';
|
||||
/** Path part for operation `commentsDelete()` */
|
||||
static readonly CommentsDeletePath = '/v1/packages/{package_id}/comments/{id}';
|
||||
|
||||
/**
|
||||
* This method provides access to the full `HttpResponse`, allowing access to response headers.
|
||||
* To access only the response body, use `listPackage()` instead.
|
||||
* To access only the response body, use `commentsDelete()` instead.
|
||||
*
|
||||
* This method doesn't expect any request body.
|
||||
*/
|
||||
listPackage$Response(
|
||||
params?: {
|
||||
commentsDelete$Response(
|
||||
params: {
|
||||
package_id: number;
|
||||
id: number;
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<StrictHttpResponse<ListPackageRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.ListPackagePath, 'get');
|
||||
): Observable<StrictHttpResponse<CommentsDeleteRsp>> {
|
||||
const rb = new RequestBuilder(this.rootUrl, PkgdashServiceService.CommentsDeletePath, 'delete');
|
||||
if (params) {
|
||||
rb.path('package_id', params.package_id, {});
|
||||
rb.path('id', params.id, {});
|
||||
}
|
||||
|
||||
return this.http.request(
|
||||
@ -290,24 +435,26 @@ export class PkgdashServiceService extends BaseService {
|
||||
).pipe(
|
||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||
map((r: HttpResponse<any>) => {
|
||||
return r as StrictHttpResponse<ListPackageRsp>;
|
||||
return r as StrictHttpResponse<CommentsDeleteRsp>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method provides access only to the response body.
|
||||
* To access the full response (for headers, for example), `listPackage$Response()` instead.
|
||||
* To access the full response (for headers, for example), `commentsDelete$Response()` instead.
|
||||
*
|
||||
* This method doesn't expect any request body.
|
||||
*/
|
||||
listPackage(
|
||||
params?: {
|
||||
commentsDelete(
|
||||
params: {
|
||||
package_id: number;
|
||||
id: number;
|
||||
},
|
||||
context?: HttpContext
|
||||
): Observable<ListPackageRsp> {
|
||||
return this.listPackage$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<ListPackageRsp>): ListPackageRsp => r.body)
|
||||
): Observable<CommentsDeleteRsp> {
|
||||
return this.commentsDelete$Response(params, context).pipe(
|
||||
map((r: StrictHttpResponse<CommentsDeleteRsp>): CommentsDeleteRsp => r.body)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,12 @@ import { BrowserModule } from '@angular/platform-browser';
|
||||
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
import { AppComponent } from './app.component';
|
||||
import { DashboardComponent } from './dashboard/dashboard.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent
|
||||
AppComponent,
|
||||
DashboardComponent,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
1
ui/src/app/dashboard/dashboard.component.html
Normal file
1
ui/src/app/dashboard/dashboard.component.html
Normal file
@ -0,0 +1 @@
|
||||
<p>dashboard works!</p>
|
0
ui/src/app/dashboard/dashboard.component.scss
Normal file
0
ui/src/app/dashboard/dashboard.component.scss
Normal file
25
ui/src/app/dashboard/dashboard.component.spec.ts
Normal file
25
ui/src/app/dashboard/dashboard.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { DashboardComponent } from './dashboard.component';
|
||||
|
||||
describe('DashboardComponent', () => {
|
||||
let component: DashboardComponent;
|
||||
let fixture: ComponentFixture<DashboardComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ DashboardComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DashboardComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
15
ui/src/app/dashboard/dashboard.component.ts
Normal file
15
ui/src/app/dashboard/dashboard.component.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
templateUrl: './dashboard.component.html',
|
||||
styleUrls: ['./dashboard.component.scss']
|
||||
})
|
||||
export class DashboardComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Ui</title>
|
||||
<title>UI</title>
|
||||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
|
Loading…
x
Reference in New Issue
Block a user