Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.

Commit 08d2c7d

Browse files
vertex451Artem Shcherbatiuk
andauthored
fix: name collision (#57)
* fixed name collision issue --------- Co-authored-by: Artem Shcherbatiuk <[email protected]>
1 parent d652916 commit 08d2c7d

File tree

13 files changed

+29
-29
lines changed

13 files changed

+29
-29
lines changed

cmd/gateway.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414

1515
"github.com/openmfp/golang-commons/logger"
1616

17-
appCfg "github.com/openmfp/crd-gql-gateway/internal/config"
18-
"github.com/openmfp/crd-gql-gateway/internal/manager"
17+
appCfg "github.com/openmfp/crd-gql-gateway/gateway/config"
18+
"github.com/openmfp/crd-gql-gateway/gateway/manager"
1919
)
2020

2121
var gatewayCmd = &cobra.Command{

cmd/start.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/graphql-go/handler"
99
"github.com/spf13/cobra"
1010

11-
"github.com/openmfp/crd-gql-gateway/gateway"
11+
"github.com/openmfp/crd-gql-gateway/deprecated"
1212
"k8s.io/apimachinery/pkg/runtime"
1313
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
1414
controllerruntime "sigs.k8s.io/controller-runtime"
@@ -47,7 +47,7 @@ var startCmd = &cobra.Command{
4747
panic("no cache sync")
4848
}
4949

50-
cfg.Wrap(gateway.NewImpersonationTransport)
50+
cfg.Wrap(deprecated.NewImpersonationTransport)
5151

5252
cl, err := client.NewWithWatch(cfg, client.Options{
5353
Scheme: schema,
@@ -59,14 +59,14 @@ var startCmd = &cobra.Command{
5959
return err
6060
}
6161

62-
gqlSchema, err := gateway.New(cmd.Context(), gateway.Config{
62+
gqlSchema, err := deprecated.New(cmd.Context(), deprecated.Config{
6363
Client: cl,
6464
})
6565
if err != nil {
6666
return err
6767
}
6868

69-
http.Handle("/graphql", gateway.Handler(gateway.HandlerConfig{
69+
http.Handle("/graphql", deprecated.Handler(deprecated.HandlerConfig{
7070
Config: &handler.Config{
7171
Schema: &gqlSchema,
7272
Pretty: true,

definitions/root

Lines changed: 0 additions & 1 deletion
This file was deleted.

gateway/gateway.go renamed to deprecated/gateway.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gateway
1+
package deprecated
22

33
import (
44
"context"

gateway/resolver.go renamed to deprecated/resolver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gateway
1+
package deprecated
22

33
import (
44
"context"

internal/config/config.go renamed to gateway/config/config.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import (
55
)
66

77
type Config struct {
8-
Port string `envconfig:"default=8080,optional"`
9-
LogLevel string `envconfig:"default=INFO,optional"`
10-
WatchedDir string `envconfig:"default=bin/definitions,required"`
11-
EnableKCP bool `envconfig:"default=true,optional"`
12-
HandlerCfg HandlerConfig
8+
Port string `envconfig:"default=8080,optional"`
9+
LogLevel string `envconfig:"default=INFO,optional"`
10+
WatchedDir string `envconfig:"default=bin/definitions,required"`
11+
EnableKCP bool `envconfig:"default=true,optional"`
12+
LocalDevelopment bool `envconfig:"default=false,optional"`
13+
HandlerCfg HandlerConfig
1314
}
1415

1516
type HandlerConfig struct {

internal/manager/manager.go renamed to gateway/manager/manager.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import (
1616
"github.com/graphql-go/graphql"
1717
"github.com/graphql-go/handler"
1818
"github.com/kcp-dev/logicalcluster/v3"
19-
appConfig "github.com/openmfp/crd-gql-gateway/internal/config"
20-
"github.com/openmfp/crd-gql-gateway/internal/gateway"
21-
"github.com/openmfp/crd-gql-gateway/internal/resolver"
19+
appConfig "github.com/openmfp/crd-gql-gateway/gateway/config"
20+
"github.com/openmfp/crd-gql-gateway/gateway/resolver"
21+
"github.com/openmfp/crd-gql-gateway/gateway/schema"
2222
"github.com/openmfp/golang-commons/logger"
2323
"k8s.io/client-go/rest"
2424
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -141,7 +141,7 @@ func (s *Service) handleEvent(event fsnotify.Event) {
141141
func (s *Service) OnFileChanged(filename string) {
142142
schema, err := s.loadSchemaFromFile(filename)
143143
if err != nil {
144-
s.log.Error().Err(err).Str("file", filename).Msg("Error loading example:alpha from file")
144+
s.log.Error().Err(err).Str("file", filename).Msg("Error loading schema from file")
145145
return
146146
}
147147

@@ -165,7 +165,7 @@ func (s *Service) loadSchemaFromFile(filename string) (*graphql.Schema, error) {
165165
return nil, err
166166
}
167167

168-
g, err := gateway.New(s.log, definitions, s.resolver)
168+
g, err := schema.New(s.log, definitions, s.resolver)
169169
if err != nil {
170170
return nil, err
171171
}
@@ -210,7 +210,7 @@ func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) {
210210
}
211211

212212
token := r.Header.Get("Authorization")
213-
if token == "" {
213+
if !s.appCfg.LocalDevelopment && token == "" {
214214
http.Error(w, "Authorization header is required", http.StatusUnauthorized)
215215
return
216216
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)