Skip to content

Commit

Permalink
refactor: remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Dec 27, 2024
1 parent 8ec8c46 commit dc8c20b
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cmd/pkg/driver/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type MongoDriver struct {
var _ Driver = (*MongoDriver)(nil)

// NewMongoDriver initializes a new MongoDB connection and returns a Driver instance.
func NewMongoDriver(ctx context.Context, uri, name string) (Driver, error) {
func NewMongoDriver(uri, name string) (Driver, error) {
var server *memongo.Server
if strings.HasPrefix(uri, "memongodb://") {
server = mongoserver.New()
Expand Down
8 changes: 4 additions & 4 deletions cmd/pkg/driver/mongo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TestNewMongoDriver(t *testing.T) {
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()

driver, err := NewMongoDriver(ctx, "memongodb://", "")
driver, err := NewMongoDriver("memongodb://", "")
assert.NoError(t, err)
assert.NotNil(t, driver)
assert.NoError(t, driver.Close(ctx))
Expand All @@ -21,7 +21,7 @@ func TestMongoDriver_SpecStore(t *testing.T) {
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()

driver, _ := NewMongoDriver(ctx, "memongodb://", "")
driver, _ := NewMongoDriver("memongodb://", "")
defer driver.Close(ctx)

store, err := driver.SpecStore(ctx, "")
Expand All @@ -33,7 +33,7 @@ func TestMongoDriver_SecretStore(t *testing.T) {
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()

driver, _ := NewMongoDriver(ctx, "memongodb://", "")
driver, _ := NewMongoDriver("memongodb://", "")
defer driver.Close(ctx)

store, err := driver.SecretStore(ctx, "")
Expand All @@ -45,7 +45,7 @@ func TestMongoDriver_ChartStore(t *testing.T) {
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()

driver, _ := NewMongoDriver(ctx, "memongodb://", "")
driver, _ := NewMongoDriver("memongodb://", "")
defer driver.Close(ctx)

store, err := driver.ChartStore(ctx, "")
Expand Down
2 changes: 1 addition & 1 deletion cmd/pkg/uniflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func main() {

if strings.HasPrefix(databaseURL, "memongodb://") || strings.HasPrefix(databaseURL, "mongodb://") {
var err error
if drv, err = driver.NewMongoDriver(ctx, databaseURL, databaseName); err != nil {
if drv, err = driver.NewMongoDriver(databaseURL, databaseName); err != nil {
log.Fatal(err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/pkg/uniflowctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func main() {

if strings.HasPrefix(databaseURL, "memongodb://") || strings.HasPrefix(databaseURL, "mongodb://") {
var err error
if drv, err = driver.NewMongoDriver(ctx, databaseURL, databaseName); err != nil {
if drv, err = driver.NewMongoDriver(databaseURL, databaseName); err != nil {
log.Fatal(err)
}
}
Expand Down
5 changes: 2 additions & 3 deletions driver/mongo/pkg/chart/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ func (s *Store) Index(ctx context.Context) error {
{Key: chart.KeyNamespace, Value: 1},
{Key: chart.KeyName, Value: 1},
},
Options: options.Index().SetUnique(true).SetPartialFilterExpression(bson.M{
chart.KeyName: bson.M{"$exists": true},
}),
Options: options.Index().SetUnique(true).
SetPartialFilterExpression(bson.M{chart.KeyName: bson.M{"$exists": true}}),
},
}

Expand Down
5 changes: 2 additions & 3 deletions driver/mongo/pkg/secret/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ func (s *Store) Index(ctx context.Context) error {
{Key: secret.KeyNamespace, Value: 1},
{Key: secret.KeyName, Value: 1},
},
Options: options.Index().SetUnique(true).SetPartialFilterExpression(bson.M{
secret.KeyName: bson.M{"$exists": true},
}),
Options: options.Index().SetUnique(true).
SetPartialFilterExpression(bson.M{secret.KeyName: bson.M{"$exists": true}}),
},
}

Expand Down
5 changes: 2 additions & 3 deletions driver/mongo/pkg/spec/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ func (s *Store) Index(ctx context.Context) error {
{Key: spec.KeyNamespace, Value: 1},
{Key: spec.KeyName, Value: 1},
},
Options: options.Index().SetUnique(true).SetPartialFilterExpression(bson.M{
spec.KeyName: bson.M{"$exists": true},
}),
Options: options.Index().SetUnique(true).
SetPartialFilterExpression(bson.M{spec.KeyName: bson.M{"$exists": true}}),
},
{
Keys: bson.M{spec.KeyKind: 1},
Expand Down
2 changes: 1 addition & 1 deletion ext/pkg/network/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
type ListenNodeSpec struct {
spec.Meta `map:",inline"`
Protocol string `map:"protocol" validate:"required"`
Host string `map:"host,omitempty"`
Host string `map:"host,omitempty" validate:"omitempty,hostname|ip"`
Port int `map:"port" validate:"required"`
Cert string `map:"cert,omitempty"`
Key string `map:"key,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions pkg/resource/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (s *store[T]) Watch(ctx context.Context, resources ...T) (Stream, error) {

go func() {
<-stream.Done()

s.mu.Lock()
defer s.mu.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion pkg/runtime/breakpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestNewBreakpoint(t *testing.T) {
)
defer b.Close()

assert.NotZero(t, proc.ID())
assert.NotZero(t, b.ID())
assert.Equal(t, proc, b.Process())
assert.Equal(t, sb, b.Symbol())
assert.Equal(t, sb.In(node.PortIn), b.InPort())
Expand Down

0 comments on commit dc8c20b

Please sign in to comment.