Skip to content

Commit

Permalink
Pass address string to Ocpi service
Browse files Browse the repository at this point in the history
  • Loading branch information
dangeross committed May 18, 2022
1 parent 26ae7e8 commit 3e2b1c7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ require (
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/google/uuid v1.3.0
github.com/joho/godotenv v1.4.0
github.com/satimoto/go-datastore v0.1.2-0.20220504150421-789db4316b88
github.com/satimoto/go-datastore v0.1.2-0.20220506113557-5240743992e9
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/vektah/gqlparser/v2 v2.4.0
google.golang.org/grpc v1.46.0
)

require (
Expand Down Expand Up @@ -54,7 +53,7 @@ require (
github.com/miekg/dns v1.1.43 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/paulmach/orb v0.5.1-0.20220406232948-69ee7e81c712 // indirect
github.com/satimoto/go-ocpi-api v0.0.3-0.20220505075031-b256dd943feb
github.com/satimoto/go-ocpi-api v0.0.3-0.20220518064509-629fe41bca23
github.com/tidwall/gjson v1.6.1 // indirect
github.com/tidwall/match v1.0.1 // indirect
github.com/tidwall/pretty v1.0.2 // indirect
Expand All @@ -81,6 +80,7 @@ require (
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/satimoto/go-datastore-mocks v0.1.2-0.20220429143239-03099fadb0a5 // indirect
google.golang.org/grpc v1.46.0 // indirect
)

replace git.schwanenlied.me/yawning/bsaes.git => github.com/Yawning/bsaes v0.0.0-20180720073208-c0276d75487e
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,8 @@ github.com/satimoto/go-datastore v0.1.2-0.20220503081613-a512ca2c2fe1 h1:6jlSxvT
github.com/satimoto/go-datastore v0.1.2-0.20220503081613-a512ca2c2fe1/go.mod h1:gz81qrvwGFlGiHKrIDcHSkEbmSEhpMZvFRuZaVj2AUw=
github.com/satimoto/go-datastore v0.1.2-0.20220504150421-789db4316b88 h1:JYXFgf7AjHTRwlcoRYrV+ywDK6JWYuoJHaoXW2MEk58=
github.com/satimoto/go-datastore v0.1.2-0.20220504150421-789db4316b88/go.mod h1:gz81qrvwGFlGiHKrIDcHSkEbmSEhpMZvFRuZaVj2AUw=
github.com/satimoto/go-datastore v0.1.2-0.20220506113557-5240743992e9 h1:Pl1dQDrFflqdHHyex4R071ZGIMOIvoGDXPqnfLgGxJQ=
github.com/satimoto/go-datastore v0.1.2-0.20220506113557-5240743992e9/go.mod h1:gz81qrvwGFlGiHKrIDcHSkEbmSEhpMZvFRuZaVj2AUw=
github.com/satimoto/go-datastore-mocks v0.1.2-0.20220419191201-5cc6e4da30ab h1:3fmSQXnaTK32QUXR24IPBu9Ilesl3ORu6SbmqxLZvGU=
github.com/satimoto/go-datastore-mocks v0.1.2-0.20220419191201-5cc6e4da30ab/go.mod h1:UP4V0PS8Njwbj/GKn/iIKKSyP4zCAYh8MDXbUG9a/og=
github.com/satimoto/go-datastore-mocks v0.1.2-0.20220428080513-4e0e5e04de96 h1:ZQFRpou0XjMAqYsb7th1ue254grEAEbJXvrdgqgwWxs=
Expand All @@ -1066,6 +1068,8 @@ github.com/satimoto/go-ocpi-api v0.0.3-0.20220505072337-749ac70c5158 h1:6Qw8cIum
github.com/satimoto/go-ocpi-api v0.0.3-0.20220505072337-749ac70c5158/go.mod h1:HcjUyO6njEdoeioTwUWk55jiTrWCqmqJ3y4bk9VQQPQ=
github.com/satimoto/go-ocpi-api v0.0.3-0.20220505075031-b256dd943feb h1:FpiJ9GOw5cLPksv05r9Dg5+IXQyLerZaLgAkyRbCkT0=
github.com/satimoto/go-ocpi-api v0.0.3-0.20220505075031-b256dd943feb/go.mod h1:HcjUyO6njEdoeioTwUWk55jiTrWCqmqJ3y4bk9VQQPQ=
github.com/satimoto/go-ocpi-api v0.0.3-0.20220518064509-629fe41bca23 h1:uqh7NuqH2667huC50UbHFPTBFsH7tFNipNIGQqfN0bY=
github.com/satimoto/go-ocpi-api v0.0.3-0.20220518064509-629fe41bca23/go.mod h1:iVUTaQdMaJeeawv/qoYw9qUBGXRfEH7YpQkNndDHa78=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
Expand Down
11 changes: 10 additions & 1 deletion graph/resolver/resolve.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package resolver

import (
"os"

"github.com/satimoto/go-api/internal/authentication"
"github.com/satimoto/go-api/internal/businessdetail"
"github.com/satimoto/go-api/internal/channelrequest"
Expand Down Expand Up @@ -41,10 +43,17 @@ type Resolver struct {
}

func NewResolver(repositoryService *db.RepositoryService) *Resolver {
ocpiService := ocpi.NewService(os.Getenv("OCPI_RPC_ADDRESS"))

return NewResolverWithServices(repositoryService, ocpiService)
}

func NewResolverWithServices(repositoryService *db.RepositoryService, ocpiService ocpi.Ocpi) *Resolver {
repo := Repository(repositoryService)

return &Resolver{
Repository: repo,
OcpiService: ocpi.NewService(),
OcpiService: ocpiService,
AuthenticationResolver: authentication.NewResolver(repositoryService),
BusinessDetailResolver: businessdetail.NewResolver(repositoryService),
ChannelRequestResolver: channelrequest.NewResolver(repositoryService),
Expand Down
9 changes: 8 additions & 1 deletion internal/token/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package token

import (
"context"
"os"

"github.com/satimoto/go-datastore/db"
"github.com/satimoto/go-ocpi-api/pkg/ocpi"
Expand All @@ -19,10 +20,16 @@ type TokenResolver struct {
}

func NewResolver(repositoryService *db.RepositoryService) *TokenResolver {
ocpiService := ocpi.NewService(os.Getenv("OCPI_RPC_ADDRESS"))

return NewResolverWithServices(repositoryService, ocpiService)
}

func NewResolverWithServices(repositoryService *db.RepositoryService, ocpiService ocpi.Ocpi) *TokenResolver {
repo := TokenRepository(repositoryService)

return &TokenResolver{
Repository: repo,
OcpiService: ocpi.NewService(),
OcpiService: ocpiService,
}
}

0 comments on commit 3e2b1c7

Please sign in to comment.