diff --git a/.gitignore b/.gitignore index 6729600..c294e4d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,18 @@ +# Swap files +*.swp + # Toolchain -# Goland project folder +# Golang project folder .idea/ + # Visual Studio Code .vscode/ + +# Build +build/ +log/ +vendor/ + # emacs/vim GPATH GRTAGS @@ -10,10 +20,10 @@ GTAGS TAGS tags cscope.* -# mac + +# macOS .DS_Store -# debug +# Debug *.log *.pcap - diff --git a/.golangci.yml b/.golangci.yml index 28fe4b9..71ec882 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -29,12 +29,6 @@ run: # "/" will be replaced by current OS file path separator to properly work # on Windows. skip-files: - - "api_.*\\.go$" - - "model_.*\\.go$" - - "routers.go" - - "client.go" - - "configuration.go" - - "nas.go" # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": # If invoked with -mod=readonly, the go command is disallowed from the implicit # automatic updating of go.mod described above. Instead, it fails when any changes @@ -250,13 +244,14 @@ linters: # Additional - lll - godox - #- gomnd - #- goconst + # - gomnd + # - goconst # - gocognit # - maligned # - nestif # - gomodguard - nakedret + # - golint - gci - misspell - gofumpt @@ -267,9 +262,9 @@ linters: - dogsled - bodyclose - asciicheck - #- stylecheck - # - unparam - # - wsl + # - stylecheck + # - unparam + # - wsl #disable-all: false fast: true diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index f465a20..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,9 +0,0 @@ -# Change Log ---- -2020-03-xx-xx ---- -- Implemented enchacements: - -- Fixed bugs: - -- Closed issues: diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE diff --git a/cmd/main.go b/cmd/main.go new file mode 100644 index 0000000..898c3df --- /dev/null +++ b/cmd/main.go @@ -0,0 +1,96 @@ +/* + * Npcf_BDTPolicyControl Service API + * + * The Npcf_BDTPolicyControl Service is used by an NF service consumer to + * retrieve background data transfer policies from the PCF and to update the PCF with + * the background data transfer policy selected by the NF service consumer. + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package main + +import ( + "fmt" + "os" + "path/filepath" + "runtime/debug" + + "github.com/asaskevich/govalidator" + "github.com/urfave/cli" + + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/util" + "github.com/free5gc/pcf/pkg/service" + "github.com/free5gc/util/version" +) + +var PCF = &service.PCF{} + +func main() { + defer func() { + if p := recover(); p != nil { + // Print stack for panic to log. Fatalf() will let program exit. + logger.AppLog.Fatalf("panic: %v\n%s", p, string(debug.Stack())) + } + }() + + app := cli.NewApp() + app.Name = "pcf" + app.Usage = "5G Policy Control Function (PCF)" + app.Action = action + app.Flags = PCF.GetCliCmd() + if err := app.Run(os.Args); err != nil { + fmt.Printf("PCF Run Error: %v\n", err) + } +} + +func action(c *cli.Context) error { + if err := initLogFile(c.String("log"), c.String("log5gc")); err != nil { + logger.AppLog.Errorf("%+v", err) + return err + } + + if err := PCF.Initialize(c); err != nil { + switch err1 := err.(type) { + case govalidator.Errors: + errs := err1.Errors() + for _, e := range errs { + logger.CfgLog.Errorf("%+v", e) + } + default: + logger.CfgLog.Errorf("%+v", err) + } + + logger.CfgLog.Errorf("[-- PLEASE REFER TO SAMPLE CONFIG FILE COMMENTS --]") + return fmt.Errorf("Failed to initialize !!") + } + logger.AppLog.Infoln(c.App.Name) + logger.AppLog.Infoln("PCF version: ", version.GetVersion()) + + PCF.Start() + + return nil +} + +func initLogFile(logNfPath, log5gcPath string) error { + PCF.KeyLogPath = util.PcfDefaultKeyLogPath + + if err := logger.LogFileHook(logNfPath, log5gcPath); err != nil { + return err + } + + if logNfPath != "" { + nfDir, _ := filepath.Split(logNfPath) + tmpDir := filepath.Join(nfDir, "key") + if err := os.MkdirAll(tmpDir, 0775); err != nil { + logger.InitLog.Errorf("Make directory %s failed: %+v", tmpDir, err) + return err + } + _, name := filepath.Split(util.PcfDefaultKeyLogPath) + PCF.KeyLogPath = filepath.Join(tmpDir, name) + } + + return nil +} diff --git a/factory/config.go b/factory/config.go deleted file mode 100644 index a058afa..0000000 --- a/factory/config.go +++ /dev/null @@ -1,66 +0,0 @@ -/* - * PCF Configuration Factory - */ - -package factory - -import ( - "github.com/free5gc/logger_util" -) - -const ( - PCF_EXPECTED_CONFIG_VERSION = "1.0.0" -) - -type Config struct { - Info *Info `yaml:"info"` - Configuration *Configuration `yaml:"configuration"` - Logger *logger_util.Logger `yaml:"logger"` -} - -type Info struct { - Version string `yaml:"version,omitempty"` - Description string `yaml:"description,omitempty"` -} - -const ( - PCF_DEFAULT_IPV4 = "127.0.0.7" - PCF_DEFAULT_PORT = "8000" - PCF_DEFAULT_PORT_INT = 8000 -) - -type Configuration struct { - PcfName string `yaml:"pcfName,omitempty"` - Sbi *Sbi `yaml:"sbi,omitempty"` - TimeFormat string `yaml:"timeFormat,omitempty"` - DefaultBdtRefId string `yaml:"defaultBdtRefId,omitempty"` - NrfUri string `yaml:"nrfUri,omitempty"` - ServiceList []Service `yaml:"serviceList,omitempty"` - Mongodb *Mongodb `yaml:"mongodb"` - Locality string `yaml:"locality,omitempty"` -} - -type Service struct { - ServiceName string `yaml:"serviceName"` - SuppFeat string `yaml:"suppFeat,omitempty"` -} - -type Sbi struct { - Scheme string `yaml:"scheme"` - RegisterIPv4 string `yaml:"registerIPv4,omitempty"` // IP that is registered at NRF. - // IPv6Addr string `yaml:"ipv6Addr,omitempty"` - BindingIPv4 string `yaml:"bindingIPv4,omitempty"` // IP used to run the server in the node. - Port int `yaml:"port,omitempty"` -} - -type Mongodb struct { - Name string `yaml:"name"` - Url string `yaml:"url"` -} - -func (c *Config) GetVersion() string { - if c.Info != nil && c.Info.Version != "" { - return c.Info.Version - } - return "" -} diff --git a/go.mod b/go.mod index 0fe4a39..5e3ea8f 100644 --- a/go.mod +++ b/go.mod @@ -4,26 +4,18 @@ go 1.14 require ( github.com/antihax/optional v1.0.0 - github.com/antonfisher/nested-logrus-formatter v1.3.0 - github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect + github.com/antonfisher/nested-logrus-formatter v1.3.1 + github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d github.com/cydev/zero v0.0.0-20160322155811-4a4535dd56e7 - github.com/free5gc/MongoDBLibrary v1.0.0 - github.com/free5gc/http2_util v1.0.0 - github.com/free5gc/http_wrapper v1.0.0 - github.com/free5gc/idgenerator v1.0.0 - github.com/free5gc/logger_conf v1.0.0 - github.com/free5gc/logger_util v1.0.0 - github.com/free5gc/openapi v1.0.0 - github.com/free5gc/path_util v1.0.0 - github.com/free5gc/version v1.0.0 + github.com/free5gc/openapi v1.0.4 + github.com/free5gc/util v1.0.1 github.com/gin-contrib/cors v1.3.1 - github.com/gin-gonic/gin v1.6.3 - github.com/google/uuid v1.1.2 + github.com/gin-gonic/gin v1.7.3 + github.com/google/uuid v1.3.0 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 - github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/sirupsen/logrus v1.7.0 + github.com/sirupsen/logrus v1.8.1 github.com/tim-ywliu/event v0.1.0 github.com/urfave/cli v1.22.5 - go.mongodb.org/mongo-driver v1.4.4 + go.mongodb.org/mongo-driver v1.7.1 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index fe0663c..92d33ad 100644 --- a/go.sum +++ b/go.sum @@ -35,58 +35,40 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/antonfisher/nested-logrus-formatter v1.3.0 h1:8zixYquU1Odk+vzAaAQPAdRh1ZjmUXNQ1T+dUBvlhVo= -github.com/antonfisher/nested-logrus-formatter v1.3.0/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA= -github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= -github.com/aws/aws-sdk-go v1.36.7 h1:XoJPAjKoqvdL531XGWxKYn5eGX/xMoXzMN5fBtoyfSY= -github.com/aws/aws-sdk-go v1.36.7/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= +github.com/antonfisher/nested-logrus-formatter v1.3.1 h1:NFJIr+pzwv5QLHTPyKz9UMEoHck02Q9L0FP13b/xSbQ= +github.com/antonfisher/nested-logrus-formatter v1.3.1/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA= +github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= +github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= -github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cydev/zero v0.0.0-20160322155811-4a4535dd56e7 h1:OQoU2eJO+adwX0gBaIede9S+aL6aQU/0aKwktWKyl8s= github.com/cydev/zero v0.0.0-20160322155811-4a4535dd56e7/go.mod h1:XGbwUcTsr1d7ezSp77rqp7aaYHlX+01wCaIFUNMRY6g= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/evanphx/json-patch v4.9.0+incompatible h1:kLcOMZeuLAJvL2BPWLMIj5oaZQobrkAqrL+WFZwQses= -github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/free5gc/MongoDBLibrary v1.0.0 h1:+CN5t3G9AvI4iv7azq46KUK4VWYsprbR7OHBqVM9XSo= -github.com/free5gc/MongoDBLibrary v1.0.0/go.mod h1:0TSgWaO+5KyIrylML6jbHqtgoJJKpHGiXHPFdHXXPts= -github.com/free5gc/http2_util v1.0.0 h1:0laMypHUNizAE5zsLoeJQq0R4XrfbvsLCW4NHCPpc44= -github.com/free5gc/http2_util v1.0.0/go.mod h1:GN2BCD8IINjtnAKYGwe+dEeTBRFEv4lQnZblFIIhbdE= -github.com/free5gc/http_wrapper v1.0.0 h1:NdnDHkItXxUzoxggiQsnR9SObBdi6KmwcN+QUJs4CoQ= -github.com/free5gc/http_wrapper v1.0.0/go.mod h1:vVArDqfCo7fvmYGi9WRPj4yurSu86GxRh3iQ70aq+OE= -github.com/free5gc/idgenerator v1.0.0 h1:e55Cn2p8dGCGYv5VoJ6oOsTj3SIVLToNLuS2CDOulZA= -github.com/free5gc/idgenerator v1.0.0/go.mod h1:+iGY7VUgUX88lqPhGAPGy/b2SxtNJMvymdJbNyjk4HU= -github.com/free5gc/logger_conf v1.0.0 h1:cMqqB8L4HjE57tP36mBmiVUPIcHv8Ayr12jKfeiwqZU= -github.com/free5gc/logger_conf v1.0.0/go.mod h1:DHecLXVV1qA5Z+lSoUvZdZ6tCtZidTNmtx99jsCfgLE= -github.com/free5gc/logger_util v1.0.0 h1:hLTCTnKlEqJURrBwooNFQLavWPdJzS0o9KGIYUNKdJI= -github.com/free5gc/logger_util v1.0.0/go.mod h1:TK/bAJbm/l2TMNmbsKn83+xUmDNqts69IEir/nCa8w0= -github.com/free5gc/openapi v1.0.0 h1:DaGVt05b1pSDBOailKAlLj6hAk6vunN0Nhzvl/xcWCY= -github.com/free5gc/openapi v1.0.0/go.mod h1:7OzxoWBj6KQgznMW2ZiUtZdCGY+t89v4wtgKLhluKgU= -github.com/free5gc/path_util v1.0.0 h1:vJPGTymaWtavz6fJ/7k6WKEYv5BQLAq/O04RP54sab0= -github.com/free5gc/path_util v1.0.0/go.mod h1:OpmcebEKrMPnH7Jg5lZ8y9ZWJNAjQ4l9FGWXUv58Mo0= -github.com/free5gc/version v1.0.0 h1:Kn4uOhyHT1IAgerBgWRHag4xLMDXrRsqubLeMv5Nb/w= -github.com/free5gc/version v1.0.0/go.mod h1:wOTwzjk7sqeysX1b/Z4x+pWBHFuZOPtQj3h+IJXSpmQ= +github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8P3k= +github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ= +github.com/free5gc/openapi v1.0.4 h1:bC6oqXy8Z+3e532xLMFmrTHvdyv4sNGDPezQSslw5gQ= +github.com/free5gc/openapi v1.0.4/go.mod h1:KRCnnp0GeK0Bl4gnrX79cQAidKXNENf8VRdG0y9R0Fc= +github.com/free5gc/util v1.0.1 h1:A8bynjzZXkYMLOq9FN5J4Yg5mdjXhYoXc/FFFwSLPss= +github.com/free5gc/util v1.0.1/go.mod h1:VsA8FaZAxZW6eKzF/VXN2kuctl19Tj+NYH7ZxkZ+YCA= github.com/gin-contrib/cors v1.3.1 h1:doAsuITavI4IOcd0Y19U4B+O0dNWihRyX//nn4sEmgA= github.com/gin-contrib/cors v1.3.1/go.mod h1:jjEJ4268OPZUcU7k9Pm653S7lXUGcqMADzFA61xsmDk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do= -github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= -github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/gin-gonic/gin v1.7.3 h1:aMBzLJ/GMEYmv1UWs2FFTcPISLrQH2mRgL9Glz8xows= +github.com/gin-gonic/gin v1.7.3/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= 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= @@ -98,11 +80,8 @@ github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTM github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= -github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= -github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= @@ -129,6 +108,8 @@ github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWe github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= +github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= +github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -143,7 +124,6 @@ github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= @@ -153,12 +133,10 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.2 h1:aeE13tS0IiQgFjYdoL8qN3K1N2bXXtI6Vi51/y7BpMw= -github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -181,34 +159,30 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= 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/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.9.5 h1:U+CaK85mrNNb4k8BNOfgJtJ/gr6kswUCFj6miSzVC6M= github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.11.3 h1:dB4Bn0tN3wdCzQxnS8r06kV74qN/TAfaIS0bVE8h3jc= -github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -224,16 +198,12 @@ github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kN github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mitchellh/mapstructure v1.4.0 h1:7ks8ZkOP5/ujthUsT07rNv+nkLXCQWKNHuwzOAesEks= -github.com/mitchellh/mapstructure v1.4.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= @@ -250,15 +220,17 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -266,31 +238,32 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tim-ywliu/event v0.1.0 h1:lLh1lkm5CZtnAbQInEPufEF4yVST9THmvSSP2TYP1Ms= github.com/tim-ywliu/event v0.1.0/go.mod h1:A9ErEElAsxOGdM0DoJa4KUBFOq/L0aKZHSYGJwJ7lqU= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go v1.2.1 h1:dz+JxTe7GZQdErTo7SREc1jQj/hFP1k7jyIAwODoW+k= -github.com/ugorji/go v1.2.1/go.mod h1:cSVypSfTLm2o9fKxXvQgn3rMmkPXovcWor6Qn5tbFmI= github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/ugorji/go/codec v1.2.1 h1:/TRfW3XKkvWvmAYyCUaQlhoCDGjcvNR8xVVA/l5p/jQ= -github.com/ugorji/go/codec v1.2.1/go.mod h1:s/WxCRi46t8rA+fowL40EnmD7ec0XhR7ZypxeBNdzsM= github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU= github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c h1:u40Z8hqBAAQyv+vATcGgV0YCnDjqSL7/q/JyPhhJSPk= -github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= -github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc h1:n+nNi93yXLkJvKwXNP9d55HC7lGK4H/SRcwB5IaUZLo= -github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= +github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.0.2 h1:akYIkZ28e6A96dkWNJQu3nmCzH3YfwMPQExUYDaRv7w= +github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= +github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyhBc= +github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.mongodb.org/mongo-driver v1.4.4 h1:bsPHfODES+/yx2PCWzUYMH8xj6PVniPI8DQrsJuSXSs= -go.mongodb.org/mongo-driver v1.4.4/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= +go.mongodb.org/mongo-driver v1.7.1 h1:jwqTeEM3x6L9xDXrCxN0Hbg7vdGfPBOTIkr0+/LYZDA= +go.mongodb.org/mongo-driver v1.7.1/go.mod h1:Q4oFMbo1+MSNqICAdYMlC/zSTrwCogR4R8NzkI+yfU8= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -300,12 +273,11 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 h1:sYNJzB4J8toYPQTM6pAkcmBRgw9SnQKP9oXCHfgy604= -golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -348,7 +320,6 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191021144547-ec77196f6094/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -363,16 +334,15 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11 h1:lwlPPsmjDKK0J6eG6xDWd5XPehI0R024zxjDnw3esPA= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d h1:20cMwl2fHAzkJMEA+8J4JgqBQcQGzbisXo31MIeenXI= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5 h1:Lm4OryKCca1vehdsWogr9N4t7NfZxLbJoc/H0w4K4S4= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210810183815-faf39c7919d5 h1:Ati8dO7+U7mxpkPSxBZQEvzHVUYB/MqCklCN8ig5w/o= +golang.org/x/oauth2 v0.0.0-20210810183815-faf39c7919d5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -381,9 +351,8 @@ golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 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-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -404,7 +373,6 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -418,19 +386,18 @@ golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201211090839-8ad439b19e0f h1:QdHQnPce6K4XQewki9WNbG5KOROuDzqO3NaYjI1cXJ0= -golang.org/x/sys v0.0.0-20201211090839-8ad439b19e0f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 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= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 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= @@ -440,6 +407,7 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -480,7 +448,6 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -505,9 +472,8 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -566,9 +532,8 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= -gopkg.in/h2non/gentleman.v1 v1.0.4/go.mod h1:JYuHVdFzS4MKOXe0o+chKJ4hCe6tqKKw9XH9YP6WFrg= -gopkg.in/h2non/gock.v1 v1.0.16 h1:F11k+OafeuFENsjei5t2vMTSTs9L62AdyTe4E1cgdG8= -gopkg.in/h2non/gock.v1 v1.0.16/go.mod h1:XVuDAssexPLwgxCLMvDTWNU5eqklsydR6I5phZ9oPB8= +gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= +gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/context/context.go b/internal/context/context.go similarity index 98% rename from context/context.go rename to internal/context/context.go index 5f0bff4..900a0a2 100644 --- a/context/context.go +++ b/internal/context/context.go @@ -7,11 +7,11 @@ import ( "strings" "sync" - "github.com/free5gc/idgenerator" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/factory" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/pkg/factory" + "github.com/free5gc/util/idgenerator" ) var pcfCtx *PCFContext diff --git a/context/ue.go b/internal/context/ue.go similarity index 99% rename from context/ue.go rename to internal/context/ue.go index ae4d432..941658d 100644 --- a/context/ue.go +++ b/internal/context/ue.go @@ -7,9 +7,9 @@ import ( "strconv" "strings" - "github.com/free5gc/idgenerator" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/util/idgenerator" ) // key is supi diff --git a/logger/logger.go b/internal/logger/logger.go similarity index 77% rename from logger/logger.go rename to internal/logger/logger.go index 5e7cd26..9d4c7e5 100644 --- a/logger/logger.go +++ b/internal/logger/logger.go @@ -7,8 +7,7 @@ import ( formatter "github.com/antonfisher/nested-logrus-formatter" "github.com/sirupsen/logrus" - "github.com/free5gc/logger_conf" - "github.com/free5gc/logger_util" + logger_util "github.com/free5gc/util/logger" ) var ( @@ -43,16 +42,6 @@ func init() { FieldsOrder: []string{"component", "category"}, } - free5gcLogHook, err := logger_util.NewFileHook(logger_conf.Free5gcLogFile, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666) - if err == nil { - log.Hooks.Add(free5gcLogHook) - } - - selfLogHook, err := logger_util.NewFileHook(logger_conf.NfLogDir+"pcf.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666) - if err == nil { - log.Hooks.Add(selfLogHook) - } - AppLog = log.WithFields(logrus.Fields{"component": "PCF", "category": "App"}) InitLog = log.WithFields(logrus.Fields{"component": "PCF", "category": "Init"}) CfgLog = log.WithFields(logrus.Fields{"component": "PCF", "category": "CFG"}) @@ -71,10 +60,36 @@ func init() { NotifyEventLog = log.WithFields(logrus.Fields{"component": "PCF", "category": "NotifyEvent"}) } +func LogFileHook(logNfPath string, log5gcPath string) error { + if fullPath, err := logger_util.CreateFree5gcLogFile(log5gcPath); err == nil { + if fullPath != "" { + free5gcLogHook, hookErr := logger_util.NewFileHook(fullPath, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666) + if hookErr != nil { + return hookErr + } + log.Hooks.Add(free5gcLogHook) + } + } else { + return err + } + + if fullPath, err := logger_util.CreateNfLogFile(logNfPath, "pcf.log"); err == nil { + selfLogHook, hookErr := logger_util.NewFileHook(fullPath, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666) + if hookErr != nil { + return hookErr + } + log.Hooks.Add(selfLogHook) + } else { + return err + } + + return nil +} + func SetLogLevel(level logrus.Level) { log.SetLevel(level) } -func SetReportCaller(set bool) { - log.SetReportCaller(set) +func SetReportCaller(enable bool) { + log.SetReportCaller(enable) } diff --git a/ampolicy/api_default.go b/internal/sbi/ampolicy/api_default.go similarity index 91% rename from ampolicy/api_default.go rename to internal/sbi/ampolicy/api_default.go index 10764cb..aa2e6c1 100644 --- a/ampolicy/api_default.go +++ b/internal/sbi/ampolicy/api_default.go @@ -14,16 +14,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/producer" - "github.com/free5gc/pcf/util" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/sbi/producer" + "github.com/free5gc/pcf/internal/util" + "github.com/free5gc/util/httpwrapper" ) func HTTPPoliciesPolAssoIdDelete(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["polAssoId"], _ = c.Params.Get("polAssoId") rsp := producer.HandleDeletePoliciesPolAssoId(req) @@ -44,7 +44,7 @@ func HTTPPoliciesPolAssoIdDelete(c *gin.Context) { // HTTPPoliciesPolAssoIdGet - func HTTPPoliciesPolAssoIdGet(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["polAssoId"], _ = c.Params.Get("polAssoId") rsp := producer.HandleGetPoliciesPolAssoId(req) @@ -93,7 +93,7 @@ func HTTPPoliciesPolAssoIdUpdatePost(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, policyAssociationUpdateRequest) + req := httpwrapper.NewRequest(c.Request, policyAssociationUpdateRequest) req.Params["polAssoId"], _ = c.Params.Get("polAssoId") rsp := producer.HandleUpdatePostPoliciesPolAssoId(req) @@ -149,7 +149,7 @@ func HTTPPoliciesPost(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, policyAssociationRequest) + req := httpwrapper.NewRequest(c.Request, policyAssociationRequest) req.Params["polAssoId"], _ = c.Params.Get("polAssoId") rsp := producer.HandlePostPolicies(req) diff --git a/ampolicy/routers.go b/internal/sbi/ampolicy/routers.go similarity index 95% rename from ampolicy/routers.go rename to internal/sbi/ampolicy/routers.go index 86d88ab..f4e6141 100644 --- a/ampolicy/routers.go +++ b/internal/sbi/ampolicy/routers.go @@ -15,8 +15,8 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/logger_util" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/logger" + logger_util "github.com/free5gc/util/logger" ) // Route is the information for every URI. diff --git a/bdtpolicy/api_bdt_policies_collection_routers.go b/internal/sbi/bdtpolicy/api_bdt_policies_collection_routers.go similarity index 83% rename from bdtpolicy/api_bdt_policies_collection_routers.go rename to internal/sbi/bdtpolicy/api_bdt_policies_collection_routers.go index 2333c96..d7f346b 100644 --- a/bdtpolicy/api_bdt_policies_collection_routers.go +++ b/internal/sbi/bdtpolicy/api_bdt_policies_collection_routers.go @@ -1,7 +1,10 @@ /* * Npcf_BDTPolicyControl Service API * - * The Npcf_BDTPolicyControl Service is used by an NF service consumer to retrieve background data transfer policies from the PCF and to update the PCF with the background data transfer policy selected by the NF service consumer. + * The Npcf_BDTPolicyControl Service is used by an NF service consumer to + * retrieve background data transfer policies from the PCF and to update + * the PCF with the background data transfer policy selected by the NF + * service consumer. * * API version: 1.0.0 * Generated by: OpenAPI Generator (https://openapi-generator.tech) @@ -14,11 +17,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/producer" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // CreateBDTPolicy - Create a new Individual BDT policy @@ -52,7 +55,7 @@ func HTTPCreateBDTPolicy(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, bdtReqData) + req := httpwrapper.NewRequest(c.Request, bdtReqData) rsp := producer.HandleCreateBDTPolicyContextRequest(req) // step 5: response for key, val := range rsp.Header { // header response is optional diff --git a/bdtpolicy/api_individual_bdt_policy_document_routers.go b/internal/sbi/bdtpolicy/api_individual_bdt_policy_document_routers.go similarity index 85% rename from bdtpolicy/api_individual_bdt_policy_document_routers.go rename to internal/sbi/bdtpolicy/api_individual_bdt_policy_document_routers.go index 01ed8f7..d79a7fb 100644 --- a/bdtpolicy/api_individual_bdt_policy_document_routers.go +++ b/internal/sbi/bdtpolicy/api_individual_bdt_policy_document_routers.go @@ -1,7 +1,10 @@ /* * Npcf_BDTPolicyControl Service API * - * The Npcf_BDTPolicyControl Service is used by an NF service consumer to retrieve background data transfer policies from the PCF and to update the PCF with the background data transfer policy selected by the NF service consumer. + * The Npcf_BDTPolicyControl Service is used by an NF service consumer to + * retrieve background data transfer policies from the PCF and to update + * the PCF with the background data transfer policy selected by the NF + * service consumer. * * API version: 1.0.0 * Generated by: OpenAPI Generator (https://openapi-generator.tech) @@ -14,16 +17,16 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/producer" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // GetBDTPolicy - Read an Individual BDT policy func HTTPGetBDTPolicy(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["bdtPolicyId"] = c.Params.ByName("bdtPolicyId") rsp := producer.HandleGetBDTPolicyContextRequest(req) @@ -73,7 +76,7 @@ func HTTPUpdateBDTPolicy(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, bdtPolicyDataPatch) + req := httpwrapper.NewRequest(c.Request, bdtPolicyDataPatch) req.Params["bdtPolicyId"] = c.Params.ByName("bdtPolicyId") rsp := producer.HandleUpdateBDTPolicyContextProcedure(req) diff --git a/bdtpolicy/routers.go b/internal/sbi/bdtpolicy/routers.go similarity index 87% rename from bdtpolicy/routers.go rename to internal/sbi/bdtpolicy/routers.go index de77704..f2906db 100644 --- a/bdtpolicy/routers.go +++ b/internal/sbi/bdtpolicy/routers.go @@ -1,7 +1,10 @@ /* * Npcf_BDTPolicyControl Service API * - * The Npcf_BDTPolicyControl Service is used by an NF service consumer to retrieve background data transfer policies from the PCF and to update the PCF with the background data transfer policy selected by the NF service consumer. + * The Npcf_BDTPolicyControl Service is used by an NF service consumer to + * retrieve background data transfer policies from the PCF and to update + * the PCF with the background data transfer policy selected by the NF + * service consumer. * * API version: 1.0.0 * Generated by: OpenAPI Generator (https://openapi-generator.tech) @@ -15,8 +18,8 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/logger_util" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/logger" + logger_util "github.com/free5gc/util/logger" ) // Route is the information for every URI. diff --git a/consumer/communication.go b/internal/sbi/consumer/communication.go similarity index 91% rename from consumer/communication.go rename to internal/sbi/consumer/communication.go index 467c298..f069891 100644 --- a/consumer/communication.go +++ b/internal/sbi/consumer/communication.go @@ -7,9 +7,9 @@ import ( "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - pcf_context "github.com/free5gc/pcf/context" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/util" + pcf_context "github.com/free5gc/pcf/internal/context" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/util" ) func AmfStatusChangeSubscribe(amfUri string, guamiList []models.Guami) ( diff --git a/consumer/nf_discovery.go b/internal/sbi/consumer/nf_discovery.go similarity index 97% rename from consumer/nf_discovery.go rename to internal/sbi/consumer/nf_discovery.go index b42a7ae..597df8a 100644 --- a/consumer/nf_discovery.go +++ b/internal/sbi/consumer/nf_discovery.go @@ -9,8 +9,8 @@ import ( "github.com/free5gc/openapi/Nnrf_NFDiscovery" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/util" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/util" ) func SendSearchNFInstances( diff --git a/consumer/nf_management.go b/internal/sbi/consumer/nf_management.go similarity index 97% rename from consumer/nf_management.go rename to internal/sbi/consumer/nf_management.go index 85f3496..2bb5ae0 100644 --- a/consumer/nf_management.go +++ b/internal/sbi/consumer/nf_management.go @@ -10,8 +10,8 @@ import ( "github.com/free5gc/openapi" "github.com/free5gc/openapi/Nnrf_NFManagement" "github.com/free5gc/openapi/models" - pcf_context "github.com/free5gc/pcf/context" - "github.com/free5gc/pcf/logger" + pcf_context "github.com/free5gc/pcf/internal/context" + "github.com/free5gc/pcf/internal/logger" ) func BuildNFInstance(context *pcf_context.PCFContext) (profile models.NfProfile, err error) { diff --git a/httpcallback/amf_status_change_notify.go b/internal/sbi/httpcallback/amf_status_change_notify.go similarity index 88% rename from httpcallback/amf_status_change_notify.go rename to internal/sbi/httpcallback/amf_status_change_notify.go index 4afe3c6..ce4ba71 100644 --- a/httpcallback/amf_status_change_notify.go +++ b/internal/sbi/httpcallback/amf_status_change_notify.go @@ -5,11 +5,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/producer" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) func HTTPAmfStatusChangeNotify(c *gin.Context) { @@ -41,7 +41,7 @@ func HTTPAmfStatusChangeNotify(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, amfStatusChangeNotification) + req := httpwrapper.NewRequest(c.Request, amfStatusChangeNotification) rsp := producer.HandleAmfStatusChangeNotify(req) diff --git a/httpcallback/router.go b/internal/sbi/httpcallback/router.go similarity index 93% rename from httpcallback/router.go rename to internal/sbi/httpcallback/router.go index ca4bf5c..d5f77e0 100644 --- a/httpcallback/router.go +++ b/internal/sbi/httpcallback/router.go @@ -6,8 +6,8 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/logger_util" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/logger" + logger_util "github.com/free5gc/util/logger" ) // Route is the information for every URI. diff --git a/httpcallback/sm_policy_notify.go b/internal/sbi/httpcallback/sm_policy_notify.go similarity index 88% rename from httpcallback/sm_policy_notify.go rename to internal/sbi/httpcallback/sm_policy_notify.go index 169b612..d6a5c48 100644 --- a/httpcallback/sm_policy_notify.go +++ b/internal/sbi/httpcallback/sm_policy_notify.go @@ -5,11 +5,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/producer" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // Nudr-Notify-smpolicy @@ -42,7 +42,7 @@ func HTTPNudrNotify(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, policyDataChangeNotification) + req := httpwrapper.NewRequest(c.Request, policyDataChangeNotification) req.Params["ReqURI"] = c.Params.ByName("supi") rsp := producer.HandleSmPolicyNotify(req) diff --git a/internal/notifyevent/dispatcher.go b/internal/sbi/notifyevent/dispatcher.go similarity index 96% rename from internal/notifyevent/dispatcher.go rename to internal/sbi/notifyevent/dispatcher.go index 4f95530..f2fc254 100644 --- a/internal/notifyevent/dispatcher.go +++ b/internal/sbi/notifyevent/dispatcher.go @@ -4,7 +4,7 @@ import ( "github.com/tim-ywliu/event" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/logger" ) var notifyDispatcher *event.Dispatcher diff --git a/internal/notifyevent/listener.go b/internal/sbi/notifyevent/listener.go similarity index 89% rename from internal/notifyevent/listener.go rename to internal/sbi/notifyevent/listener.go index d9c7583..ab39837 100644 --- a/internal/notifyevent/listener.go +++ b/internal/sbi/notifyevent/listener.go @@ -1,7 +1,7 @@ package notifyevent import ( - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/logger" ) type NotifyListener struct{} diff --git a/internal/notifyevent/send_smpolicy_termination.go b/internal/sbi/notifyevent/send_smpolicy_termination.go similarity index 95% rename from internal/notifyevent/send_smpolicy_termination.go rename to internal/sbi/notifyevent/send_smpolicy_termination.go index f7c7bdb..8cce76b 100644 --- a/internal/notifyevent/send_smpolicy_termination.go +++ b/internal/sbi/notifyevent/send_smpolicy_termination.go @@ -7,8 +7,8 @@ import ( "github.com/tim-ywliu/event" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/util" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/util" ) const SendSMpolicyTerminationNotifyEventName event.Name = "SendSMpolicyTerminationNotify" diff --git a/internal/notifyevent/send_smpolicy_update.go b/internal/sbi/notifyevent/send_smpolicy_update.go similarity index 95% rename from internal/notifyevent/send_smpolicy_update.go rename to internal/sbi/notifyevent/send_smpolicy_update.go index f9ad678..e9f5cb7 100644 --- a/internal/notifyevent/send_smpolicy_update.go +++ b/internal/sbi/notifyevent/send_smpolicy_update.go @@ -7,8 +7,8 @@ import ( "github.com/tim-ywliu/event" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/util" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/util" ) const SendSMpolicyUpdateNotifyEventName event.Name = "SendSMpolicyUpdateNotify" diff --git a/oam/api_get_am_policy.go b/internal/sbi/oam/api_get_am_policy.go similarity index 71% rename from oam/api_get_am_policy.go rename to internal/sbi/oam/api_get_am_policy.go index 2ad4978..88f9e7b 100644 --- a/oam/api_get_am_policy.go +++ b/internal/sbi/oam/api_get_am_policy.go @@ -5,24 +5,26 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/producer" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) func setCorsHeader(c *gin.Context) { c.Writer.Header().Set("Access-Control-Allow-Origin", "*") c.Writer.Header().Set("Access-Control-Allow-Credentials", "true") - c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With") + c.Writer.Header().Set( + "Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, "+ + "X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With") c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT, PATCH, DELETE") } func HTTPOAMGetAmPolicy(c *gin.Context) { setCorsHeader(c) - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["supi"] = c.Params.ByName("supi") rsp := producer.HandleOAMGetAmPolicyRequest(req) diff --git a/oam/routers.go b/internal/sbi/oam/routers.go similarity index 92% rename from oam/routers.go rename to internal/sbi/oam/routers.go index 3724e49..a8fa315 100644 --- a/oam/routers.go +++ b/internal/sbi/oam/routers.go @@ -5,8 +5,8 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/logger_util" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/logger" + logger_util "github.com/free5gc/util/logger" ) // Route is the information for every URI. diff --git a/policyauthorization/api_application_sessions_collection.go b/internal/sbi/policyauthorization/api_application_sessions_collection.go similarity index 90% rename from policyauthorization/api_application_sessions_collection.go rename to internal/sbi/policyauthorization/api_application_sessions_collection.go index cb06cad..3ee3131 100644 --- a/policyauthorization/api_application_sessions_collection.go +++ b/internal/sbi/policyauthorization/api_application_sessions_collection.go @@ -14,12 +14,12 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/producer" - "github.com/free5gc/pcf/util" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/sbi/producer" + "github.com/free5gc/pcf/internal/util" + "github.com/free5gc/util/httpwrapper" ) // HTTPPostAppSessions - Creates a new Individual Application Session Context resource @@ -61,7 +61,7 @@ func HTTPPostAppSessions(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, appSessionContext) + req := httpwrapper.NewRequest(c.Request, appSessionContext) rsp := producer.HandlePostAppSessionsContext(req) for key, val := range rsp.Header { diff --git a/policyauthorization/api_events_subscription_document.go b/internal/sbi/policyauthorization/api_events_subscription_document.go similarity index 90% rename from policyauthorization/api_events_subscription_document.go rename to internal/sbi/policyauthorization/api_events_subscription_document.go index 29d4748..a1ccaa8 100644 --- a/policyauthorization/api_events_subscription_document.go +++ b/internal/sbi/policyauthorization/api_events_subscription_document.go @@ -14,17 +14,17 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/producer" - "github.com/free5gc/pcf/util" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/sbi/producer" + "github.com/free5gc/pcf/internal/util" + "github.com/free5gc/util/httpwrapper" ) // HTTPDeleteEventsSubsc - deletes the Events Subscription subresource func HTTPDeleteEventsSubsc(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["appSessionId"], _ = c.Params.Get("appSessionId") rsp := producer.HandleDeleteEventsSubscContext(req) @@ -80,7 +80,7 @@ func HTTPUpdateEventsSubsc(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, eventsSubscReqData) + req := httpwrapper.NewRequest(c.Request, eventsSubscReqData) req.Params["appSessionId"], _ = c.Params.Get("appSessionId") rsp := producer.HandleUpdateEventsSubscContext(req) diff --git a/policyauthorization/api_individual_application_session_context_document.go b/internal/sbi/policyauthorization/api_individual_application_session_context_document.go similarity index 92% rename from policyauthorization/api_individual_application_session_context_document.go rename to internal/sbi/policyauthorization/api_individual_application_session_context_document.go index f068115..aba0509 100644 --- a/policyauthorization/api_individual_application_session_context_document.go +++ b/internal/sbi/policyauthorization/api_individual_application_session_context_document.go @@ -14,11 +14,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/producer" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // HTTPDeleteAppSession - Deletes an existing Individual Application Session Context @@ -54,7 +54,7 @@ func HTTPDeleteAppSession(c *gin.Context) { } } - req := http_wrapper.NewRequest(c.Request, eventsSubscReqData) + req := httpwrapper.NewRequest(c.Request, eventsSubscReqData) req.Params["appSessionId"], _ = c.Params.Get("appSessionId") rsp := producer.HandleDeleteAppSessionContext(req) @@ -75,7 +75,7 @@ func HTTPDeleteAppSession(c *gin.Context) { // HTTPGetAppSession - Reads an existing Individual Application Session Context func HTTPGetAppSession(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["appSessionId"], _ = c.Params.Get("appSessionId") rsp := producer.HandleGetAppSessionContext(req) @@ -124,7 +124,7 @@ func HTTPModAppSession(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, appSessionContextUpdateData) + req := httpwrapper.NewRequest(c.Request, appSessionContextUpdateData) req.Params["appSessionId"], _ = c.Params.Get("appSessionId") rsp := producer.HandleModAppSessionContext(req) diff --git a/policyauthorization/routers.go b/internal/sbi/policyauthorization/routers.go similarity index 96% rename from policyauthorization/routers.go rename to internal/sbi/policyauthorization/routers.go index 2220025..2c142cb 100644 --- a/policyauthorization/routers.go +++ b/internal/sbi/policyauthorization/routers.go @@ -15,8 +15,8 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/logger_util" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/logger" + logger_util "github.com/free5gc/util/logger" ) // Route is the information for every URI. diff --git a/producer/ampolicy.go b/internal/sbi/producer/ampolicy.go similarity index 91% rename from producer/ampolicy.go rename to internal/sbi/producer/ampolicy.go index a66cfb7..45c94ed 100644 --- a/producer/ampolicy.go +++ b/internal/sbi/producer/ampolicy.go @@ -8,25 +8,25 @@ import ( "github.com/mohae/deepcopy" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/consumer" - pcf_context "github.com/free5gc/pcf/context" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/util" + pcf_context "github.com/free5gc/pcf/internal/context" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/sbi/consumer" + "github.com/free5gc/pcf/internal/util" + "github.com/free5gc/util/httpwrapper" ) -func HandleDeletePoliciesPolAssoId(request *http_wrapper.Request) *http_wrapper.Response { +func HandleDeletePoliciesPolAssoId(request *httpwrapper.Request) *httpwrapper.Response { logger.AMpolicylog.Infof("Handle AM Policy Association Delete") polAssoId := request.Params["polAssoId"] problemDetails := DeletePoliciesPolAssoIdProcedure(polAssoId) if problemDetails == nil { - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } else { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } } @@ -41,22 +41,22 @@ func DeletePoliciesPolAssoIdProcedure(polAssoId string) *models.ProblemDetails { } // PoliciesPolAssoIdGet - -func HandleGetPoliciesPolAssoId(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetPoliciesPolAssoId(request *httpwrapper.Request) *httpwrapper.Response { logger.AMpolicylog.Infof("Handle AM Policy Association Get") polAssoId := request.Params["polAssoId"] response, problemDetails := GetPoliciesPolAssoIdProcedure(polAssoId) if response != nil { - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } func GetPoliciesPolAssoIdProcedure(polAssoId string) (*models.PolicyAssociation, *models.ProblemDetails) { @@ -87,7 +87,7 @@ func GetPoliciesPolAssoIdProcedure(polAssoId string) (*models.PolicyAssociation, return &rsp, nil } -func HandleUpdatePostPoliciesPolAssoId(request *http_wrapper.Request) *http_wrapper.Response { +func HandleUpdatePostPoliciesPolAssoId(request *httpwrapper.Request) *httpwrapper.Response { logger.AMpolicylog.Infof("Handle AM Policy Association Update") polAssoId := request.Params["polAssoId"] @@ -95,15 +95,15 @@ func HandleUpdatePostPoliciesPolAssoId(request *http_wrapper.Request) *http_wrap response, problemDetails := UpdatePostPoliciesPolAssoIdProcedure(polAssoId, policyAssociationUpdateRequest) if response != nil { - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } func UpdatePostPoliciesPolAssoIdProcedure(polAssoId string, @@ -179,7 +179,7 @@ func UpdatePostPoliciesPolAssoIdProcedure(polAssoId string, } // Create AM Policy -func HandlePostPolicies(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePostPolicies(request *httpwrapper.Request) *httpwrapper.Response { logger.AMpolicylog.Infof("Handle AM Policy Create Request") polAssoId := request.Params["polAssoId"] @@ -190,15 +190,15 @@ func HandlePostPolicies(request *http_wrapper.Request) *http_wrapper.Response { "Location": {locationHeader}, } if response != nil { - return http_wrapper.NewResponse(http.StatusCreated, headers, response) + return httpwrapper.NewResponse(http.StatusCreated, headers, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } func PostPoliciesProcedure(polAssoId string, diff --git a/producer/bdtpolicy.go b/internal/sbi/producer/bdtpolicy.go similarity index 88% rename from producer/bdtpolicy.go rename to internal/sbi/producer/bdtpolicy.go index 1ec3d78..1a21b94 100644 --- a/producer/bdtpolicy.go +++ b/internal/sbi/producer/bdtpolicy.go @@ -9,17 +9,17 @@ import ( "github.com/google/uuid" "github.com/mohae/deepcopy" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi/Nnrf_NFDiscovery" "github.com/free5gc/openapi/Nudr_DataRepository" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/consumer" - pcf_context "github.com/free5gc/pcf/context" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/util" + pcf_context "github.com/free5gc/pcf/internal/context" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/sbi/consumer" + "github.com/free5gc/pcf/internal/util" + "github.com/free5gc/util/httpwrapper" ) -func HandleGetBDTPolicyContextRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetBDTPolicyContextRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.Bdtpolicylog.Infof("Handle GetBDTPolicyContext") @@ -32,15 +32,15 @@ func HandleGetBDTPolicyContextRequest(request *http_wrapper.Request) *http_wrapp // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } func getBDTPolicyContextProcedure(bdtPolicyID string) ( @@ -59,7 +59,7 @@ func getBDTPolicyContextProcedure(bdtPolicyID string) ( } // UpdateBDTPolicy - Update an Individual BDT policy (choose policy data) -func HandleUpdateBDTPolicyContextProcedure(request *http_wrapper.Request) *http_wrapper.Response { +func HandleUpdateBDTPolicyContextProcedure(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.Bdtpolicylog.Infof("Handle UpdateBDTPolicyContext") @@ -73,15 +73,15 @@ func HandleUpdateBDTPolicyContextProcedure(request *http_wrapper.Request) *http_ // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } func updateBDTPolicyContextProcedure(request models.BdtPolicyDataPatch, bdtPolicyID string) ( @@ -140,7 +140,7 @@ func updateBDTPolicyContextProcedure(request models.BdtPolicyDataPatch, bdtPolic } // CreateBDTPolicy - Create a new Individual BDT policy -func HandleCreateBDTPolicyContextRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleCreateBDTPolicyContextRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.Bdtpolicylog.Infof("Handle CreateBDTPolicyContext") @@ -149,7 +149,7 @@ func HandleCreateBDTPolicyContextRequest(request *http_wrapper.Request) *http_wr if requestMsg.AspId == "" || requestMsg.DesTimeInt == nil || requestMsg.NumOfUes == 0 || requestMsg.VolPerUe == nil { logger.Bdtpolicylog.Errorf("Required BdtReqData not found: AspId[%+v], DesTimeInt[%+v], NumOfUes[%+v], VolPerUe[%+v]", requestMsg.AspId, requestMsg.DesTimeInt, requestMsg.NumOfUes, requestMsg.VolPerUe) - return http_wrapper.NewResponse(http.StatusNotFound, nil, nil) + return httpwrapper.NewResponse(http.StatusNotFound, nil, nil) } // step 3: handle the message @@ -158,11 +158,11 @@ func HandleCreateBDTPolicyContextRequest(request *http_wrapper.Request) *http_wr // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusCreated, header, response) + return httpwrapper.NewResponse(http.StatusCreated, header, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { - return http_wrapper.NewResponse(http.StatusNotFound, nil, nil) + return httpwrapper.NewResponse(http.StatusNotFound, nil, nil) } } diff --git a/producer/callback.go b/internal/sbi/producer/callback.go similarity index 69% rename from producer/callback.go rename to internal/sbi/producer/callback.go index 7c79c5f..43d54d3 100644 --- a/producer/callback.go +++ b/internal/sbi/producer/callback.go @@ -3,19 +3,19 @@ package producer import ( "net/http" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/util/httpwrapper" ) -func HandleAmfStatusChangeNotify(request *http_wrapper.Request) *http_wrapper.Response { +func HandleAmfStatusChangeNotify(request *httpwrapper.Request) *httpwrapper.Response { logger.CallbackLog.Warnf("[PCF] Handle Amf Status Change Notify is not implemented.") notification := request.Body.(models.AmfStatusChangeNotification) AmfStatusChangeNotifyProcedure(notification) - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } // TODO: handle AMF Status Change Notify @@ -23,7 +23,7 @@ func AmfStatusChangeNotifyProcedure(notification models.AmfStatusChangeNotificat logger.CallbackLog.Debugf("receive AMF status change notification[%+v]", notification) } -func HandleSmPolicyNotify(request *http_wrapper.Request) *http_wrapper.Response { +func HandleSmPolicyNotify(request *httpwrapper.Request) *httpwrapper.Response { logger.CallbackLog.Warnf("[PCF] Handle Sm Policy Notify is not implemented.") notification := request.Body.(models.PolicyDataChangeNotification) @@ -31,7 +31,7 @@ func HandleSmPolicyNotify(request *http_wrapper.Request) *http_wrapper.Response SmPolicyNotifyProcedure(supi, notification) - return http_wrapper.NewResponse(http.StatusNotImplemented, nil, nil) + return httpwrapper.NewResponse(http.StatusNotImplemented, nil, nil) } // TODO: handle SM Policy Notify diff --git a/producer/oam.go b/internal/sbi/producer/oam.go similarity index 81% rename from producer/oam.go rename to internal/sbi/producer/oam.go index 0a2c827..858fc7d 100644 --- a/producer/oam.go +++ b/internal/sbi/producer/oam.go @@ -4,10 +4,10 @@ import ( "net/http" "strconv" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/context" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/context" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/util/httpwrapper" ) type UEAmPolicy struct { @@ -23,7 +23,7 @@ type UEAmPolicy struct { type UEAmPolicys []UEAmPolicy -func HandleOAMGetAmPolicyRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleOAMGetAmPolicyRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.OamLog.Infof("Handle OAMGetAmPolicy") @@ -36,15 +36,15 @@ func HandleOAMGetAmPolicyRequest(request *http_wrapper.Request) *http_wrapper.Re // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } func OAMGetAmPolicyProcedure(supi string) (response *UEAmPolicys, problemDetails *models.ProblemDetails) { diff --git a/producer/policyauthorization.go b/internal/sbi/producer/policyauthorization.go similarity index 97% rename from producer/policyauthorization.go rename to internal/sbi/producer/policyauthorization.go index 1f9c6fc..c6f7462 100644 --- a/producer/policyauthorization.go +++ b/internal/sbi/producer/policyauthorization.go @@ -9,13 +9,13 @@ import ( "github.com/cydev/zero" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - pcf_context "github.com/free5gc/pcf/context" - "github.com/free5gc/pcf/internal/notifyevent" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/util" + pcf_context "github.com/free5gc/pcf/internal/context" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/sbi/notifyevent" + "github.com/free5gc/pcf/internal/util" + "github.com/free5gc/util/httpwrapper" ) func transferAfRoutReqRmToAfRoutReq(AfRoutReqRm *models.AfRoutingRequirementRm) *models.AfRoutingRequirement { @@ -123,7 +123,7 @@ func handleMediaSubComponent(smPolicy *pcf_context.UeSmPolicyData, medComp *mode // Subscription to resources allocation outcome (DONE) // Invocation of Multimedia Priority Services (TODO) // Support of content versioning (TODO) -func HandlePostAppSessionsContext(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePostAppSessionsContext(request *httpwrapper.Request) *httpwrapper.Response { logger.PolicyAuthorizationlog.Traceln("Handle Create AppSessions") appSessCtx := request.Body.(models.AppSessionContext) @@ -134,15 +134,15 @@ func HandlePostAppSessionsContext(request *http_wrapper.Request) *http_wrapper.R headers := http.Header{ "Location": {locationHeader}, } - return http_wrapper.NewResponse(http.StatusCreated, headers, response) + return httpwrapper.NewResponse(http.StatusCreated, headers, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } func postAppSessCtxProcedure(appSessCtx *models.AppSessionContext) (*models.AppSessionContext, @@ -426,16 +426,16 @@ func postAppSessCtxProcedure(appSessCtx *models.AppSessionContext) (*models.AppS } // HandleDeleteAppSession - Deletes an existing Individual Application Session Context -func HandleDeleteAppSessionContext(request *http_wrapper.Request) *http_wrapper.Response { +func HandleDeleteAppSessionContext(request *httpwrapper.Request) *httpwrapper.Response { eventsSubscReqData := request.Body.(*models.EventsSubscReqData) appSessID := request.Params["appSessionId"] logger.PolicyAuthorizationlog.Infof("Handle Del AppSessions, AppSessionId[%s]", appSessID) problemDetails := DeleteAppSessionContextProcedure(appSessID, eventsSubscReqData) if problemDetails == nil { - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } else { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } } @@ -494,15 +494,15 @@ func DeleteAppSessionContextProcedure(appSessID string, } // HandleGetAppSession - Reads an existing Individual Application Session Context -func HandleGetAppSessionContext(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetAppSessionContext(request *httpwrapper.Request) *httpwrapper.Response { appSessID := request.Params["appSessionId"] logger.PolicyAuthorizationlog.Infof("Handle Get AppSessions, AppSessionId[%s]", appSessID) problemDetails, response := GetAppSessionContextProcedure(appSessID) if problemDetails == nil { - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } } @@ -522,16 +522,16 @@ func GetAppSessionContextProcedure(appSessID string) (*models.ProblemDetails, *m } // HandleModAppSession - Modifies an existing Individual Application Session Context -func HandleModAppSessionContext(request *http_wrapper.Request) *http_wrapper.Response { +func HandleModAppSessionContext(request *httpwrapper.Request) *httpwrapper.Response { appSessID := request.Params["appSessionId"] ascUpdateData := request.Body.(models.AppSessionContextUpdateData) logger.PolicyAuthorizationlog.Infof("Handle Modify AppSessions, AppSessionId[%s]", appSessID) problemDetails, response := ModAppSessionContextProcedure(appSessID, ascUpdateData) if problemDetails == nil { - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } } @@ -805,15 +805,15 @@ func ModAppSessionContextProcedure(appSessID string, } // HandleDeleteEventsSubsc - deletes the Events Subscription subresource -func HandleDeleteEventsSubscContext(request *http_wrapper.Request) *http_wrapper.Response { +func HandleDeleteEventsSubscContext(request *httpwrapper.Request) *httpwrapper.Response { appSessID := request.Params["appSessID"] logger.PolicyAuthorizationlog.Tracef("Handle Del AppSessions Events Subsc, AppSessionId[%s]", appSessID) problemDetails := DeleteEventsSubscContextProcedure(appSessID) if problemDetails == nil { - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } else { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } } @@ -851,29 +851,29 @@ func DeleteEventsSubscContextProcedure(appSessID string) *models.ProblemDetails } // HandleUpdateEventsSubsc - creates or modifies an Events Subscription subresource -func HandleUpdateEventsSubscContext(request *http_wrapper.Request) *http_wrapper.Response { +func HandleUpdateEventsSubscContext(request *httpwrapper.Request) *httpwrapper.Response { EventsSubscReqData := request.Body.(models.EventsSubscReqData) appSessID := request.Params["appSessID"] logger.PolicyAuthorizationlog.Tracef("Handle Put AppSessions Events Subsc, AppSessionId[%s]", appSessID) response, locationHeader, status, problemDetails := UpdateEventsSubscContextProcedure(appSessID, EventsSubscReqData) if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else if status == http.StatusCreated { headers := http.Header{ "Location": {locationHeader}, } - return http_wrapper.NewResponse(http.StatusCreated, headers, response) + return httpwrapper.NewResponse(http.StatusCreated, headers, response) } else if status == http.StatusOK { - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if status == http.StatusNoContent { - return http_wrapper.NewResponse(http.StatusNoContent, nil, response) + return httpwrapper.NewResponse(http.StatusNoContent, nil, response) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } func SendAppSessionEventNotification(appSession *pcf_context.AppSessionData, request models.EventsNotification) { diff --git a/producer/smpolicy.go b/internal/sbi/producer/smpolicy.go similarity index 95% rename from producer/smpolicy.go rename to internal/sbi/producer/smpolicy.go index 8905570..73c5fa7 100644 --- a/producer/smpolicy.go +++ b/internal/sbi/producer/smpolicy.go @@ -10,20 +10,20 @@ import ( "github.com/antihax/optional" "go.mongodb.org/mongo-driver/bson" - "github.com/free5gc/MongoDBLibrary" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/Nudr_DataRepository" "github.com/free5gc/openapi/models" - pcf_context "github.com/free5gc/pcf/context" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/util" + pcf_context "github.com/free5gc/pcf/internal/context" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/util" + "github.com/free5gc/util/httpwrapper" + "github.com/free5gc/util/mongoapi" ) const flowRuleDataColl = "policyData.ues.flowRule" // SmPoliciesPost - -func HandleCreateSmPolicyRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleCreateSmPolicyRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SMpolicylog.Infof("Handle CreateSmPolicy") // step 2: retrieve request @@ -35,11 +35,11 @@ func HandleCreateSmPolicyRequest(request *http_wrapper.Request) *http_wrapper.Re // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusCreated, header, response) + return httpwrapper.NewResponse(http.StatusCreated, header, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { - return http_wrapper.NewResponse(http.StatusNotFound, nil, nil) + return httpwrapper.NewResponse(http.StatusNotFound, nil, nil) } } @@ -174,7 +174,10 @@ func createSMPolicyProcedure(request models.SmPolicyContextData) ( // get flow rules from databases filter := bson.M{"ueId": ue.Supi, "snssai": util.SnssaiModelsToHex(*request.SliceInfo), "dnn": request.Dnn} - flowRulesInterface := MongoDBLibrary.RestfulAPIGetMany(flowRuleDataColl, filter) + flowRulesInterface, err := mongoapi.RestfulAPIGetMany(flowRuleDataColl, filter) + if err != nil { + logger.SMpolicylog.Errorf("createSMPolicyProcedure error: %+v", err) + } for _, flowRule := range flowRulesInterface { pccRule := util.CreatePccRule(smPolicyData.PccRuleIdGenarator, 33, []models.FlowInformation{ @@ -219,7 +222,7 @@ func createSMPolicyProcedure(request models.SmPolicyContextData) ( } // SmPoliciessmPolicyIDDeletePost - -func HandleDeleteSmPolicyContextRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleDeleteSmPolicyContextRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SMpolicylog.Infof("Handle DeleteSmPolicyContext") @@ -232,9 +235,9 @@ func HandleDeleteSmPolicyContextRequest(request *http_wrapper.Request) *http_wra // step 4: process the return value from step 3 if problemDetails != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } else { - return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) + return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } } @@ -271,7 +274,7 @@ func deleteSmPolicyContextProcedure(smPolicyID string) *models.ProblemDetails { } // SmPoliciessmPolicyIDGet - -func HandleGetSmPolicyContextRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetSmPolicyContextRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SMpolicylog.Infof("Handle GetSmPolicyContext") @@ -283,15 +286,15 @@ func HandleGetSmPolicyContextRequest(request *http_wrapper.Request) *http_wrappe // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } func getSmPolicyContextProcedure(smPolicyID string) ( @@ -314,7 +317,7 @@ func getSmPolicyContextProcedure(smPolicyID string) ( } // SmPoliciessmPolicyIDUpdatePost - -func HandleUpdateSmPolicyContextRequest(request *http_wrapper.Request) *http_wrapper.Response { +func HandleUpdateSmPolicyContextRequest(request *httpwrapper.Request) *httpwrapper.Response { // step 1: log logger.SMpolicylog.Infof("Handle UpdateSmPolicyContext") @@ -328,15 +331,15 @@ func HandleUpdateSmPolicyContextRequest(request *http_wrapper.Request) *http_wra // step 4: process the return value from step 3 if response != nil { // status code is based on SPEC, and option headers - return http_wrapper.NewResponse(http.StatusOK, nil, response) + return httpwrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } problemDetails = &models.ProblemDetails{ Status: http.StatusForbidden, Cause: "UNSPECIFIED", } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } func updateSmPolicyContextProcedure(request models.SmPolicyUpdateContextData, smPolicyID string) ( diff --git a/smpolicy/api_default.go b/internal/sbi/smpolicy/api_default.go similarity index 92% rename from smpolicy/api_default.go rename to internal/sbi/smpolicy/api_default.go index 9630336..0e1f2bf 100644 --- a/smpolicy/api_default.go +++ b/internal/sbi/smpolicy/api_default.go @@ -14,11 +14,11 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/http_wrapper" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/producer" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/sbi/producer" + "github.com/free5gc/util/httpwrapper" ) // SmPoliciesPost - @@ -52,7 +52,7 @@ func HTTPSmPoliciesPost(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, smPolicyContextData) + req := httpwrapper.NewRequest(c.Request, smPolicyContextData) rsp := producer.HandleCreateSmPolicyRequest(req) // step 5: response @@ -75,7 +75,7 @@ func HTTPSmPoliciesPost(c *gin.Context) { // SmPoliciesSmPolicyIdDeletePost - func HTTPSmPoliciesSmPolicyIdDeletePost(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["smPolicyId"] = c.Params.ByName("smPolicyId") rsp := producer.HandleDeleteSmPolicyContextRequest(req) @@ -96,7 +96,7 @@ func HTTPSmPoliciesSmPolicyIdDeletePost(c *gin.Context) { // SmPoliciesSmPolicyIdGet - func HTTPSmPoliciesSmPolicyIDGet(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) + req := httpwrapper.NewRequest(c.Request, nil) req.Params["smPolicyId"] = c.Params.ByName("smPolicyId") rsp := producer.HandleGetSmPolicyContextRequest(req) @@ -146,7 +146,7 @@ func HTTPSmPoliciesSmPolicyIdUpdatePost(c *gin.Context) { return } - req := http_wrapper.NewRequest(c.Request, smPolicyUpdateContextData) + req := httpwrapper.NewRequest(c.Request, smPolicyUpdateContextData) req.Params["smPolicyId"] = c.Params.ByName("smPolicyId") rsp := producer.HandleUpdateSmPolicyContextRequest(req) diff --git a/smpolicy/routers.go b/internal/sbi/smpolicy/routers.go similarity index 95% rename from smpolicy/routers.go rename to internal/sbi/smpolicy/routers.go index 6180b98..c0b4a06 100644 --- a/smpolicy/routers.go +++ b/internal/sbi/smpolicy/routers.go @@ -15,8 +15,8 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/logger_util" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/logger" + logger_util "github.com/free5gc/util/logger" ) // Route is the information for every URI. diff --git a/uepolicy/api_default.go b/internal/sbi/uepolicy/api_default.go similarity index 100% rename from uepolicy/api_default.go rename to internal/sbi/uepolicy/api_default.go diff --git a/uepolicy/routers.go b/internal/sbi/uepolicy/routers.go similarity index 94% rename from uepolicy/routers.go rename to internal/sbi/uepolicy/routers.go index f97a47b..1f75fd7 100644 --- a/uepolicy/routers.go +++ b/internal/sbi/uepolicy/routers.go @@ -15,8 +15,8 @@ import ( "github.com/gin-gonic/gin" - "github.com/free5gc/logger_util" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/logger" + logger_util "github.com/free5gc/util/logger" ) type Route struct { diff --git a/util/convert.go b/internal/util/convert.go similarity index 100% rename from util/convert.go rename to internal/util/convert.go diff --git a/util/init_context.go b/internal/util/init_context.go similarity index 82% rename from util/init_context.go rename to internal/util/init_context.go index f0628c7..491c42e 100644 --- a/util/init_context.go +++ b/internal/util/init_context.go @@ -5,12 +5,12 @@ import ( "github.com/google/uuid" - "github.com/free5gc/MongoDBLibrary" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - "github.com/free5gc/pcf/context" - "github.com/free5gc/pcf/factory" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/context" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/pkg/factory" + "github.com/free5gc/util/mongoapi" ) // Init PCF Context from config flie @@ -25,13 +25,16 @@ func InitpcfContext(context *context.PCFContext) { mongodb := config.Configuration.Mongodb // Connect to MongoDB - MongoDBLibrary.SetMongoDB(mongodb.Name, mongodb.Url) + if err := mongoapi.SetMongoDB(mongodb.Name, mongodb.Url); err != nil { + logger.UtilLog.Errorf("InitpcfContext err: %+v", err) + return + } sbi := configuration.Sbi context.NrfUri = configuration.NrfUri context.UriScheme = "" - context.RegisterIPv4 = factory.PCF_DEFAULT_IPV4 // default localhost - context.SBIPort = factory.PCF_DEFAULT_PORT_INT // default port + context.RegisterIPv4 = factory.PcfSbiDefaultIPv4 // default localhost + context.SBIPort = factory.PcfSbiDefaultPort // default port if sbi != nil { if sbi.Scheme != "" { context.UriScheme = models.UriScheme(sbi.Scheme) diff --git a/util/pcc_rule.go b/internal/util/pcc_rule.go similarity index 100% rename from util/pcc_rule.go rename to internal/util/pcc_rule.go diff --git a/util/pcf_util.go b/internal/util/pcf_util.go similarity index 94% rename from util/pcf_util.go rename to internal/util/pcf_util.go index e94ed9c..ee881c4 100644 --- a/util/pcf_util.go +++ b/internal/util/pcf_util.go @@ -14,19 +14,21 @@ import ( "github.com/free5gc/openapi/Npcf_SMPolicyControl" "github.com/free5gc/openapi/Nudr_DataRepository" "github.com/free5gc/openapi/models" - "github.com/free5gc/path_util" - "github.com/free5gc/pcf/context" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/context" + "github.com/free5gc/pcf/internal/logger" ) const TimeFormat = time.RFC3339 // Path of HTTP2 key and log file +const ( + PcfDefaultKeyLogPath = "./log/pcfsslkey.log" + PcfDefaultPemPath = "./config/TLS/pcf.pem" + PcfDefaultKeyPath = "./config/TLS/pcf.key" + PcfDefaultConfigPath = "./config/pcfcfg.yaml" +) + var ( - PCF_LOG_PATH = path_util.Free5gcPath("free5gc/pcfsslkey.log") - PCF_PEM_PATH = path_util.Free5gcPath("free5gc/support/TLS/pcf.pem") - PCF_KEY_PATH = path_util.Free5gcPath("free5gc/support/TLS/pcf.key") - PCF_CONFIG_PATH = path_util.Free5gcPath("free5gc/config/pcfcfg.yaml") PCF_BASIC_PATH = "https://localhost:29507" ERROR_REQUEST_PARAMETERS = "ERROR_REQUEST_PARAMETERS" USER_UNKNOWN = "USER_UNKNOWN" diff --git a/util/search_nf_service.go b/internal/util/search_nf_service.go similarity index 100% rename from util/search_nf_service.go rename to internal/util/search_nf_service.go diff --git a/pcf.go b/pcf.go deleted file mode 100644 index ea81711..0000000 --- a/pcf.go +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Npcf_BDTPolicyControl Service API - * - * The Npcf_BDTPolicyControl Service is used by an NF service consumer to - * retrieve background data transfer policies from the PCF and to update the PCF with - * the background data transfer policy selected by the NF service consumer. - * - * API version: 1.0.0 - * Generated by: OpenAPI Generator (https://openapi-generator.tech) - */ - -package main - -import ( - "fmt" - "os" - - "github.com/sirupsen/logrus" - "github.com/urfave/cli" - - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/service" - "github.com/free5gc/version" -) - -var PCF = &service.PCF{} - -var appLog *logrus.Entry - -func init() { - appLog = logger.AppLog -} - -func main() { - app := cli.NewApp() - app.Name = "pcf" - fmt.Print(app.Name, "\n") - appLog.Infoln("PCF version: ", version.GetVersion()) - app.Usage = "-free5gccfg common configuration file -pcfcfg pcf configuration file" - app.Action = action - app.Flags = PCF.GetCliCmd() - - if err := app.Run(os.Args); err != nil { - appLog.Errorf("PCF Run Error: %v", err) - } -} - -func action(c *cli.Context) error { - if err := PCF.Initialize(c); err != nil { - logger.CfgLog.Errorf("%+v", err) - return fmt.Errorf("Failed to initialize !!") - } - - PCF.Start() - - return nil -} diff --git a/pkg/factory/config.go b/pkg/factory/config.go new file mode 100644 index 0000000..ff702bd --- /dev/null +++ b/pkg/factory/config.go @@ -0,0 +1,230 @@ +/* + * PCF Configuration Factory + */ + +package factory + +import ( + "fmt" + "strconv" + + "github.com/asaskevich/govalidator" + + logger_util "github.com/free5gc/util/logger" +) + +const ( + PcfExpectedConfigVersion = "1.0.1" + PcfSbiDefaultIPv4 = "127.0.0.7" + PcfSbiDefaultPort = 8000 + PcfTimeFormatLayout = "2006-01-02 15:04:05" +) + +type Config struct { + Info *Info `yaml:"info" valid:"required"` + Configuration *Configuration `yaml:"configuration" valid:"required"` + Logger *logger_util.Logger `yaml:"logger" valid:"required"` +} + +func (c *Config) Validate() (bool, error) { + info := c.Info + if _, err := info.validate(); err != nil { + return false, err + } + + Configuration := c.Configuration + if _, err := Configuration.validate(); err != nil { + return false, err + } + + Logger := c.Logger + if _, err := Logger.Validate(); err != nil { + return false, err + } + + if _, err := govalidator.ValidateStruct(c); err != nil { + return false, appendInvalid(err) + } + + return true, nil +} + +type Info struct { + Version string `yaml:"version,omitempty" valid:"required"` + Description string `yaml:"description,omitempty" valid:"-"` +} + +func (i *Info) validate() (bool, error) { + if _, err := govalidator.ValidateStruct(i); err != nil { + return false, appendInvalid(err) + } + + return true, nil +} + +type Configuration struct { + PcfName string `yaml:"pcfName,omitempty" valid:"required, type(string)"` + Sbi *Sbi `yaml:"sbi,omitempty" valid:"required"` + TimeFormat string `yaml:"timeFormat,omitempty" valid:"required"` + DefaultBdtRefId string `yaml:"defaultBdtRefId,omitempty" valid:"required, type(string)"` + NrfUri string `yaml:"nrfUri,omitempty" valid:"required, url"` + ServiceList []Service `yaml:"serviceList,omitempty" valid:"required"` + Mongodb *Mongodb `yaml:"mongodb" valid:"required"` + Locality string `yaml:"locality,omitempty" valid:"-"` +} + +func (c *Configuration) validate() (bool, error) { + if c.Sbi != nil { + if _, err := c.Sbi.validate(); err != nil { + return false, err + } + } + + if result := govalidator.IsTime(c.TimeFormat, PcfTimeFormatLayout); !result { + err := fmt.Errorf("Invalid TimeFormat: %s, should be in 2019-01-02 15:04:05 format.", c.TimeFormat) + return false, err + } + + if c.ServiceList != nil { + var errs govalidator.Errors + for _, v := range c.ServiceList { + if _, err := v.validate(); err != nil { + errs = append(errs, err) + } + } + if len(errs) > 0 { + return false, error(errs) + } + } + + if c.Mongodb != nil { + if _, err := c.Mongodb.validate(); err != nil { + return false, err + } + } + + if _, err := govalidator.ValidateStruct(c); err != nil { + return false, appendInvalid(err) + } + + return true, nil +} + +type Service struct { + ServiceName string `yaml:"serviceName" valid:"required, service"` + SuppFeat string `yaml:"suppFeat,omitempty" valid:"-"` +} + +func (s *Service) validate() (bool, error) { + govalidator.TagMap["service"] = govalidator.Validator(func(str string) bool { + switch str { + case "npcf-am-policy-control": + case "npcf-smpolicycontrol": + case "npcf-bdtpolicycontrol": + case "npcf-policyauthorization": + case "npcf-eventexposure": + case "npcf-ue-policy-control": + default: + return false + } + return true + }) + + if s.ServiceName == "npcf-smpolicycontrol" { + if sf, e := strconv.ParseUint(s.SuppFeat, 16, 40); e != nil { + err := fmt.Errorf("Invalid SuppFeat: %s, range of the value should be 0~3fff", s.SuppFeat) + return false, err + } else { + if sf2, e := strconv.ParseUint("3fff", 16, 20); e == nil { + if sf > sf2 { + err := fmt.Errorf("Invalid SuppFeat: %s, range of the value should be 0~3fff", s.SuppFeat) + return false, err + } + } + } + } else if s.ServiceName == "npcf-policyauthorization" { + if s.SuppFeat != "0" && s.SuppFeat != "1" && s.SuppFeat != "2" && s.SuppFeat != "3" { + err := fmt.Errorf("Invalid SuppFeat: %s, range of the value should be 0~3", s.SuppFeat) + return false, err + } + } + + if _, err := govalidator.ValidateStruct(s); err != nil { + return false, appendInvalid(err) + } + + return true, nil +} + +type Sbi struct { + Scheme string `yaml:"scheme" valid:"required,scheme"` + RegisterIPv4 string `yaml:"registerIPv4,omitempty" valid:"required,host"` // IP that is registered at NRF. + // IPv6Addr string `yaml:"ipv6Addr,omitempty"` + BindingIPv4 string `yaml:"bindingIPv4,omitempty" valid:"required,host"` // IP used to run the server in the node. + Port int `yaml:"port,omitempty" valid:"required,port"` + Tls *Tls `yaml:"tls,omitempty" valid:"optional"` +} + +func (s *Sbi) validate() (bool, error) { + govalidator.TagMap["scheme"] = govalidator.Validator(func(str string) bool { + return str == "https" || str == "http" + }) + + if tls := s.Tls; tls != nil { + if result, err := tls.validate(); err != nil { + return result, err + } + } + + if _, err := govalidator.ValidateStruct(s); err != nil { + return false, appendInvalid(err) + } + + return true, nil +} + +type Tls struct { + Pem string `yaml:"pem,omitempty" valid:"type(string),minstringlength(1),required"` + Key string `yaml:"key,omitempty" valid:"type(string),minstringlength(1),required"` +} + +func (t *Tls) validate() (bool, error) { + result, err := govalidator.ValidateStruct(t) + return result, err +} + +type Mongodb struct { + Name string `yaml:"name" valid:"required, type(string)"` + Url string `yaml:"url" valid:"required"` +} + +func (m *Mongodb) validate() (bool, error) { + pattern := `[-a-zA-Z0-9@:%._\+~#=]{1,256}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)` + if result := govalidator.StringMatches(m.Url, pattern); !result { + err := fmt.Errorf("Invalid Url: %s", m.Url) + return false, err + } + if _, err := govalidator.ValidateStruct(m); err != nil { + return false, appendInvalid(err) + } + + return true, nil +} + +func appendInvalid(err error) error { + var errs govalidator.Errors + + es := err.(govalidator.Errors).Errors() + for _, e := range es { + errs = append(errs, fmt.Errorf("Invalid %w", e)) + } + + return error(errs) +} + +func (c *Config) GetVersion() string { + if c.Info != nil && c.Info.Version != "" { + return c.Info.Version + } + return "" +} diff --git a/factory/factory.go b/pkg/factory/factory.go similarity index 82% rename from factory/factory.go rename to pkg/factory/factory.go index d414662..2b9fc9f 100644 --- a/factory/factory.go +++ b/pkg/factory/factory.go @@ -10,7 +10,7 @@ import ( "gopkg.in/yaml.v2" - "github.com/free5gc/pcf/logger" + "github.com/free5gc/pcf/internal/logger" ) var PcfConfig Config @@ -33,9 +33,9 @@ func InitConfigFactory(f string) error { func CheckConfigVersion() error { currentVersion := PcfConfig.GetVersion() - if currentVersion != PCF_EXPECTED_CONFIG_VERSION { + if currentVersion != PcfExpectedConfigVersion { return fmt.Errorf("config version is [%s], but expected is [%s].", - currentVersion, PCF_EXPECTED_CONFIG_VERSION) + currentVersion, PcfExpectedConfigVersion) } logger.CfgLog.Infof("config version [%s]", currentVersion) diff --git a/service/init.go b/pkg/service/init.go similarity index 56% rename from service/init.go rename to pkg/service/init.go index 4521fcf..bd54004 100644 --- a/service/init.go +++ b/pkg/service/init.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "os/signal" + "runtime/debug" "sync" "syscall" @@ -14,138 +15,107 @@ import ( "github.com/sirupsen/logrus" "github.com/urfave/cli" - "github.com/free5gc/http2_util" - "github.com/free5gc/logger_util" "github.com/free5gc/openapi/Nnrf_NFDiscovery" - openApiLogger "github.com/free5gc/openapi/logger" "github.com/free5gc/openapi/models" - "github.com/free5gc/path_util" - pathUtilLogger "github.com/free5gc/path_util/logger" - "github.com/free5gc/pcf/ampolicy" - "github.com/free5gc/pcf/bdtpolicy" - "github.com/free5gc/pcf/consumer" - "github.com/free5gc/pcf/context" - "github.com/free5gc/pcf/factory" - "github.com/free5gc/pcf/httpcallback" - "github.com/free5gc/pcf/internal/notifyevent" - "github.com/free5gc/pcf/logger" - "github.com/free5gc/pcf/oam" - "github.com/free5gc/pcf/policyauthorization" - "github.com/free5gc/pcf/smpolicy" - "github.com/free5gc/pcf/uepolicy" - "github.com/free5gc/pcf/util" + "github.com/free5gc/pcf/internal/context" + "github.com/free5gc/pcf/internal/logger" + "github.com/free5gc/pcf/internal/sbi/ampolicy" + "github.com/free5gc/pcf/internal/sbi/bdtpolicy" + "github.com/free5gc/pcf/internal/sbi/consumer" + "github.com/free5gc/pcf/internal/sbi/httpcallback" + "github.com/free5gc/pcf/internal/sbi/notifyevent" + "github.com/free5gc/pcf/internal/sbi/oam" + "github.com/free5gc/pcf/internal/sbi/policyauthorization" + "github.com/free5gc/pcf/internal/sbi/smpolicy" + "github.com/free5gc/pcf/internal/sbi/uepolicy" + "github.com/free5gc/pcf/internal/util" + "github.com/free5gc/pcf/pkg/factory" + "github.com/free5gc/util/httpwrapper" + logger_util "github.com/free5gc/util/logger" ) -type PCF struct{} +type PCF struct { + KeyLogPath string +} type ( - // Config information. - Config struct { - pcfcfg string + // Commands information. + Commands struct { + config string } ) -var config Config +var commands Commands -var pcfCLi = []cli.Flag{ +var cliCmd = []cli.Flag{ cli.StringFlag{ - Name: "free5gccfg", - Usage: "common config file", + Name: "config, c", + Usage: "Load configuration from `FILE`", }, cli.StringFlag{ - Name: "pcfcfg", - Usage: "config file", + Name: "log, l", + Usage: "Output NF log to `FILE`", + }, + cli.StringFlag{ + Name: "log5gc, lc", + Usage: "Output free5gc log to `FILE`", }, -} - -var initLog *logrus.Entry - -func init() { - initLog = logger.InitLog } func (*PCF) GetCliCmd() (flags []cli.Flag) { - return pcfCLi + return cliCmd } func (pcf *PCF) Initialize(c *cli.Context) error { - config = Config{ - pcfcfg: c.String("pcfcfg"), + commands = Commands{ + config: c.String("config"), } - if config.pcfcfg != "" { - if err := factory.InitConfigFactory(config.pcfcfg); err != nil { + + if commands.config != "" { + if err := factory.InitConfigFactory(commands.config); err != nil { return err } } else { - DefaultPcfConfigPath := path_util.Free5gcPath("free5gc/config/pcfcfg.yaml") - if err := factory.InitConfigFactory(DefaultPcfConfigPath); err != nil { + if err := factory.InitConfigFactory(util.PcfDefaultConfigPath); err != nil { return err } } - pcf.setLogLevel() - if err := factory.CheckConfigVersion(); err != nil { return err } + if _, err := factory.PcfConfig.Validate(); err != nil { + return err + } + + pcf.setLogLevel() + return nil } func (pcf *PCF) setLogLevel() { if factory.PcfConfig.Logger == nil { - initLog.Warnln("PCF config without log level setting!!!") + logger.InitLog.Warnln("PCF config without log level setting!!!") return } if factory.PcfConfig.Logger.PCF != nil { if factory.PcfConfig.Logger.PCF.DebugLevel != "" { if level, err := logrus.ParseLevel(factory.PcfConfig.Logger.PCF.DebugLevel); err != nil { - initLog.Warnf("PCF Log level [%s] is invalid, set to [info] level", + logger.InitLog.Warnf("PCF Log level [%s] is invalid, set to [info] level", factory.PcfConfig.Logger.PCF.DebugLevel) logger.SetLogLevel(logrus.InfoLevel) } else { - initLog.Infof("PCF Log level is set to [%s] level", level) + logger.InitLog.Infof("PCF Log level is set to [%s] level", level) logger.SetLogLevel(level) } } else { - initLog.Infoln("PCF Log level is default set to [info] level") + logger.InitLog.Infoln("PCF Log level is default set to [info] level") logger.SetLogLevel(logrus.InfoLevel) } logger.SetReportCaller(factory.PcfConfig.Logger.PCF.ReportCaller) } - - if factory.PcfConfig.Logger.PathUtil != nil { - if factory.PcfConfig.Logger.PathUtil.DebugLevel != "" { - if level, err := logrus.ParseLevel(factory.PcfConfig.Logger.PathUtil.DebugLevel); err != nil { - pathUtilLogger.PathLog.Warnf("PathUtil Log level [%s] is invalid, set to [info] level", - factory.PcfConfig.Logger.PathUtil.DebugLevel) - pathUtilLogger.SetLogLevel(logrus.InfoLevel) - } else { - pathUtilLogger.SetLogLevel(level) - } - } else { - pathUtilLogger.PathLog.Warnln("PathUtil Log level not set. Default set to [info] level") - pathUtilLogger.SetLogLevel(logrus.InfoLevel) - } - pathUtilLogger.SetReportCaller(factory.PcfConfig.Logger.PathUtil.ReportCaller) - } - - if factory.PcfConfig.Logger.OpenApi != nil { - if factory.PcfConfig.Logger.OpenApi.DebugLevel != "" { - if level, err := logrus.ParseLevel(factory.PcfConfig.Logger.OpenApi.DebugLevel); err != nil { - openApiLogger.OpenApiLog.Warnf("OpenAPI Log level [%s] is invalid, set to [info] level", - factory.PcfConfig.Logger.OpenApi.DebugLevel) - openApiLogger.SetLogLevel(logrus.InfoLevel) - } else { - openApiLogger.SetLogLevel(level) - } - } else { - openApiLogger.OpenApiLog.Warnln("OpenAPI Log level not set. Default set to [info] level") - openApiLogger.SetLogLevel(logrus.InfoLevel) - } - openApiLogger.SetReportCaller(factory.PcfConfig.Logger.OpenApi.ReportCaller) - } } func (pcf *PCF) FilterCli(c *cli.Context) (args []string) { @@ -162,7 +132,7 @@ func (pcf *PCF) FilterCli(c *cli.Context) (args []string) { } func (pcf *PCF) Start() { - initLog.Infoln("Server started") + logger.InitLog.Infoln("Server started") router := logger_util.NewGinWithLogrus(logger.GinLog) bdtpolicy.AddService(router) @@ -186,7 +156,15 @@ func (pcf *PCF) Start() { })) if err := notifyevent.RegisterNotifyDispatcher(); err != nil { - initLog.Error("Register NotifyDispatcher Error") + logger.InitLog.Error("Register NotifyDispatcher Error") + } + + pemPath := util.PcfDefaultPemPath + keyPath := util.PcfDefaultKeyPath + sbi := factory.PcfConfig.Configuration.Sbi + if sbi.Tls != nil { + pemPath = sbi.Tls.Pem + keyPath = sbi.Tls.Key } self := context.PCF_Self() @@ -196,11 +174,11 @@ func (pcf *PCF) Start() { profile, err := consumer.BuildNFInstance(self) if err != nil { - initLog.Error("Build PCF Profile Error") + logger.InitLog.Error("Build PCF Profile Error") } _, self.NfId, err = consumer.SendRegisterNFInstance(self.NrfUri, self.NfId, profile) if err != nil { - initLog.Errorf("PCF register to NRF Error[%s]", err.Error()) + logger.InitLog.Errorf("PCF register to NRF Error[%s]", err.Error()) } param := Nnrf_NFDiscovery.SearchNFInstancesParamOpts{ @@ -215,52 +193,66 @@ func (pcf *PCF) Start() { } } if err != nil { - initLog.Errorln(err) + logger.InitLog.Errorln(err) } signalChannel := make(chan os.Signal, 1) signal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM) go func() { + defer func() { + if p := recover(); p != nil { + // Print stack for panic to log. Fatalf() will let program exit. + logger.InitLog.Fatalf("panic: %v\n%s", p, string(debug.Stack())) + } + }() + <-signalChannel pcf.Terminate() os.Exit(0) }() - server, err := http2_util.NewServer(addr, util.PCF_LOG_PATH, router) + server, err := httpwrapper.NewHttp2Server(addr, pcf.KeyLogPath, router) if server == nil { - initLog.Errorf("Initialize HTTP server failed: %+v", err) + logger.InitLog.Errorf("Initialize HTTP server failed: %+v", err) return } if err != nil { - initLog.Warnf("Initialize HTTP server: +%v", err) + logger.InitLog.Warnf("Initialize HTTP server: +%v", err) } serverScheme := factory.PcfConfig.Configuration.Sbi.Scheme if serverScheme == "http" { err = server.ListenAndServe() } else if serverScheme == "https" { - err = server.ListenAndServeTLS(util.PCF_PEM_PATH, util.PCF_KEY_PATH) + err = server.ListenAndServeTLS(pemPath, keyPath) } if err != nil { - initLog.Fatalf("HTTP server setup failed: %+v", err) + logger.InitLog.Fatalf("HTTP server setup failed: %+v", err) } } func (pcf *PCF) Exec(c *cli.Context) error { - initLog.Traceln("args:", c.String("pcfcfg")) + logger.InitLog.Traceln("args:", c.String("pcfcfg")) args := pcf.FilterCli(c) - initLog.Traceln("filter: ", args) + logger.InitLog.Traceln("filter: ", args) command := exec.Command("./pcf", args...) stdout, err := command.StdoutPipe() if err != nil { - initLog.Fatalln(err) + logger.InitLog.Fatalln(err) } wg := sync.WaitGroup{} wg.Add(4) go func() { + defer func() { + if p := recover(); p != nil { + // Print stack for panic to log. Fatalf() will let program exit. + logger.InitLog.Fatalf("panic: %v\n%s", p, string(debug.Stack())) + } + }() + in := bufio.NewScanner(stdout) for in.Scan() { fmt.Println(in.Text()) @@ -270,9 +262,16 @@ func (pcf *PCF) Exec(c *cli.Context) error { stderr, err := command.StderrPipe() if err != nil { - initLog.Fatalln(err) + logger.InitLog.Fatalln(err) } go func() { + defer func() { + if p := recover(); p != nil { + // Print stack for panic to log. Fatalf() will let program exit. + logger.InitLog.Fatalf("panic: %v\n%s", p, string(debug.Stack())) + } + }() + in := bufio.NewScanner(stderr) fmt.Println("PCF log start") for in.Scan() { @@ -282,6 +281,13 @@ func (pcf *PCF) Exec(c *cli.Context) error { }() go func() { + defer func() { + if p := recover(); p != nil { + // Print stack for panic to log. Fatalf() will let program exit. + logger.InitLog.Fatalf("panic: %v\n%s", p, string(debug.Stack())) + } + }() + fmt.Println("PCF start") if err = command.Start(); err != nil { fmt.Printf("command.Start() error: %v", err)