diff --git a/cmd/pkg/driver/mongo.go b/cmd/pkg/driver/mongo.go index fcc5bc1e..80f380e7 100644 --- a/cmd/pkg/driver/mongo.go +++ b/cmd/pkg/driver/mongo.go @@ -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() diff --git a/cmd/pkg/driver/mongo_test.go b/cmd/pkg/driver/mongo_test.go index 4897b08f..d38b73a9 100644 --- a/cmd/pkg/driver/mongo_test.go +++ b/cmd/pkg/driver/mongo_test.go @@ -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)) @@ -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, "") @@ -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, "") @@ -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, "") diff --git a/cmd/pkg/uniflow/main.go b/cmd/pkg/uniflow/main.go index 6ffd4e9f..c702334c 100644 --- a/cmd/pkg/uniflow/main.go +++ b/cmd/pkg/uniflow/main.go @@ -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) } } diff --git a/cmd/pkg/uniflowctl/main.go b/cmd/pkg/uniflowctl/main.go index 3d93e010..3e616449 100644 --- a/cmd/pkg/uniflowctl/main.go +++ b/cmd/pkg/uniflowctl/main.go @@ -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) } } diff --git a/driver/mongo/pkg/chart/store.go b/driver/mongo/pkg/chart/store.go index 642cd7d8..0c0cc0e9 100644 --- a/driver/mongo/pkg/chart/store.go +++ b/driver/mongo/pkg/chart/store.go @@ -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}}), }, } diff --git a/driver/mongo/pkg/secret/store.go b/driver/mongo/pkg/secret/store.go index fcfd6dd0..1243d038 100644 --- a/driver/mongo/pkg/secret/store.go +++ b/driver/mongo/pkg/secret/store.go @@ -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}}), }, } diff --git a/driver/mongo/pkg/spec/store.go b/driver/mongo/pkg/spec/store.go index 72679982..cfe39d1b 100644 --- a/driver/mongo/pkg/spec/store.go +++ b/driver/mongo/pkg/spec/store.go @@ -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}, diff --git a/ext/pkg/network/listener.go b/ext/pkg/network/listener.go index bccbd7a8..61f6f483 100644 --- a/ext/pkg/network/listener.go +++ b/ext/pkg/network/listener.go @@ -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"` diff --git a/pkg/resource/store.go b/pkg/resource/store.go index fdfeafbf..84b8bbe1 100644 --- a/pkg/resource/store.go +++ b/pkg/resource/store.go @@ -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() diff --git a/pkg/runtime/breakpoint_test.go b/pkg/runtime/breakpoint_test.go index e9e1a054..34e91559 100644 --- a/pkg/runtime/breakpoint_test.go +++ b/pkg/runtime/breakpoint_test.go @@ -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())