Skip to content

Commit

Permalink
feat: ns apps
Browse files Browse the repository at this point in the history
  • Loading branch information
pieceowater committed Jan 11, 2025
1 parent cd09c89 commit c00e4f9
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.23.0
require (
github.com/99designs/gqlgen v0.17.56
github.com/joho/godotenv v1.5.1
github.com/pieceowater-dev/lotof.hub.proto v0.0.35
github.com/pieceowater-dev/lotof.hub.proto v0.0.36
github.com/pieceowater-dev/lotof.lib.gossiper/v2 v2.0.13
github.com/vektah/gqlparser/v2 v2.5.19
google.golang.org/grpc v1.68.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ github.com/paulmach/orb v0.11.1/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/En
github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pieceowater-dev/lotof.hub.proto v0.0.35 h1:QF0fBCQVPCOVnxzibCQAU3OIIBmG5wJ1W1hfTviB5uY=
github.com/pieceowater-dev/lotof.hub.proto v0.0.35/go.mod h1:9uwfvIUGGzTrTIVzQ4gH8hmrRC8sgtnLUhyPN5swIME=
github.com/pieceowater-dev/lotof.hub.proto v0.0.36 h1:LaCPYXdwgNJF1NHycy1Vjtkgg59fMOaLlmno6RBA+ac=
github.com/pieceowater-dev/lotof.hub.proto v0.0.36/go.mod h1:9uwfvIUGGzTrTIVzQ4gH8hmrRC8sgtnLUhyPN5swIME=
github.com/pieceowater-dev/lotof.lib.gossiper/v2 v2.0.13 h1:gcsEyGrurx8RkQGrefD7ftoPqmoAT4fbc7bmfXsGbxw=
github.com/pieceowater-dev/lotof.lib.gossiper/v2 v2.0.13/go.mod h1:XLkDdT/Ll6bY0yTaNmx+rbNDgryvoJwDfg2I6I9cmQ0=
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
Expand Down
21 changes: 21 additions & 0 deletions internal/pkg/msvc.namespaces/ns/ctrl/ns.ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,24 @@ func (c *NSController) Namespace(
Owner: res.Owner,
}, nil
}

func (c *NSController) AddAppToNamespace(
_ context.Context,
namespaceID string,
appBundle string,
) (*model.NamespaceApp, error) {
request := &ns.AddAppToNamespaceRequest{
NamespaceId: namespaceID,
AppBundle: appBundle,
}
res, err := c.nsService.AddAppToNamespace(request)
if err != nil {
return nil, err
}

return &model.NamespaceApp{
ID: res.Id,
NamespaceID: res.NamespaceId,
AppBundle: res.AppBundle,
}, nil
}
9 changes: 8 additions & 1 deletion internal/pkg/msvc.namespaces/ns/schema/ns.schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ extend type Query {
extend type Mutation {
createNamespace(input: NamespaceInput!): Namespace! @auth
updateNamespace(id: ID!, input: NamespaceInput!): Namespace! @auth
addAppToNamespace(namespaceId: ID!, appBundle: String!): NamespaceApp! @auth
}

type Namespace {
Expand All @@ -26,4 +27,10 @@ input NamespaceInput {
type PaginatedNamespaceList {
rows: [Namespace!]!
info: PaginationInfo!
}
}

type NamespaceApp {
id: ID!
namespaceID: ID!
appBundle: String!
}
16 changes: 16 additions & 0 deletions internal/pkg/msvc.namespaces/ns/svc/ns.svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,19 @@ func (s *NSService) UpdateNamespace(input *ns.UpdateNamespaceRequest) (*ns.Names
}
return res, nil
}

func (s *NSService) AddAppToNamespace(input *ns.AddAppToNamespaceRequest) (*ns.NamespaceApp, error) {
ctx := context.Background()
response, err := s.transport.Send(ctx, s.client, "AddAppToNamespace", input)
if err != nil {
log.Printf("Error sending request: %v", err)
return nil, err
}

res, ok := response.(*ns.NamespaceApp)
if !ok {
return nil, errors.New("invalid response type from gRPC transport")
}

return res, nil
}
5 changes: 5 additions & 0 deletions internal/pkg/resolvers/ns.schema.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c00e4f9

Please sign in to comment.