Port envd from e2b with internalized shared packages and Connect RPC
- Copy envd source from e2b-dev/infra, internalize shared dependencies
into envd/internal/shared/ (keys, filesystem, id, smap, utils)
- Switch from gRPC to Connect RPC for all envd services
- Update module paths to git.omukk.dev/wrenn/{sandbox,sandbox/envd}
- Add proto specs (process, filesystem) with buf-based code generation
- Implement full envd: process exec, filesystem ops, port forwarding,
cgroup management, MMDS integration, and HTTP API
- Update main module dependencies (firecracker SDK, pgx, goose, etc.)
- Remove placeholder .gitkeep files replaced by real implementations
This commit is contained in:
43
envd/internal/shared/utils/ptr.go
Normal file
43
envd/internal/shared/utils/ptr.go
Normal file
@ -0,0 +1,43 @@
|
||||
package utils
|
||||
|
||||
import "fmt"
|
||||
|
||||
func ToPtr[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
|
||||
func FromPtr[T any](s *T) T {
|
||||
if s == nil {
|
||||
var zero T
|
||||
|
||||
return zero
|
||||
}
|
||||
|
||||
return *s
|
||||
}
|
||||
|
||||
func Sprintp[T any](s *T) string {
|
||||
if s == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%v", *s)
|
||||
}
|
||||
|
||||
func DerefOrDefault[T any](s *T, defaultValue T) T {
|
||||
if s == nil {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
return *s
|
||||
}
|
||||
|
||||
func CastPtr[S any, T any](s *S, castFunc func(S) T) *T {
|
||||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
t := castFunc(*s)
|
||||
|
||||
return &t
|
||||
}
|
||||
Reference in New Issue
Block a user