file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
src/vec.rs
Rust
//! Vector-like collection for indexed keys. use std::{ ops::{Index, IndexMut}, slice::GetDisjointMutError, }; use index_vec::Idx; use crate::{ IndexedDomain, IndexedValue, ToIndex, pointer::{ArcFamily, PointerFamily, RcFamily, RefFamily}, }; /// A fixed-sized vector with one value for each key in t...
willcrichton/indexical
56
Human-friendly indexed collections
Rust
willcrichton
Will Crichton
Brown University
crates/miniserve/src/lib.rs
Rust
#![warn(clippy::pedantic)] use std::{ collections::HashMap, io::{self}, net::{TcpListener, TcpStream}, sync::Arc, thread, }; /// Re-export for library clients. pub use http; /// Implementation details for HTTP. mod protocol; /// A request from a client, either a GET or a POST with a body. #[deri...
willcrichton/rqst-async
0
Rust
willcrichton
Will Crichton
Brown University
crates/miniserve/src/protocol.rs
Rust
//! Implementation details for HTTP. //! //! You should not need to deal with this module. use std::{ io::{self, BufRead, BufReader, BufWriter, Write}, net::{Shutdown, TcpStream}, }; use http::StatusCode; pub fn stringify_response(response: http::Response<Vec<u8>>) -> Vec<u8> { let (parts, body) = respon...
willcrichton/rqst-async
0
Rust
willcrichton
Will Crichton
Brown University
crates/server/index.html
HTML
<!DOCTYPE html> <html> <head> <title>ChatABC</title> <style> #spinner.active { width: 0.75em; height: 0.75em; border-top: 2px solid #555; border-right: 2px solid transparent; border-radius: 50%; display: inline-block; box-sizing: border-box; ...
willcrichton/rqst-async
0
Rust
willcrichton
Will Crichton
Brown University
crates/server/src/main.rs
Rust
use miniserve::{http::StatusCode, Content, Request, Response}; use serde::{Deserialize, Serialize}; fn index(_req: Request) -> Response { let content = include_str!("../index.html").to_string(); Ok(Content::Html(content)) } #[derive(Serialize, Deserialize)] struct Messages { messages: Vec<String>, } fn c...
willcrichton/rqst-async
0
Rust
willcrichton
Will Crichton
Brown University
index.html
HTML
<title>Tic Tac Toe</title> <meta charset="UTF-8" /> <style> body, td, input { font-size: 24px; line-height: 1.5; text-align: center; font-family: system-ui, sans-serif; } td { height: 3rem; width: 3rem; text-align: center; } table { margin: 5rem auto; } @media (prefers...
willcrichton/skills-review-pull-requests
0
My clone repository
HTML
willcrichton
Will Crichton
Brown University
client.go
Go
package main import ( "context" "github.com/google/go-github/v50/github" ) var packageType = "container" // GitHubClient describes a (partial) GitHub REST API client. type GitHubClient interface { ListPackages(ctx context.Context, user string, opts *github.PackageListOptions) ([]*github.Package, *github.Response...
willdurand/container-registry-proxy
15
📖 A proxy that makes the GitHub Container Registry compatible with the Docker Registry HTTP API V2 specification.
Go
willdurand
William Durand
mozilla
errors.go
Go
package main const ( ERROR_UNKNOWN = "UNKNOWN" ) type apiError struct { Code string `json:"code"` Message string `json:"message"` Detail string `json:"detail"` } type apiErrors struct { Errors []apiError `json:"errors"` } func makeError(code, message string) apiErrors { return apiErrors{ Errors: []apiEr...
willdurand/container-registry-proxy
15
📖 A proxy that makes the GitHub Container Registry compatible with the Docker Registry HTTP API V2 specification.
Go
willdurand
William Durand
mozilla
main.go
Go
package main import ( "context" "encoding/json" "fmt" "log" "net/http" "net/http/httputil" "net/url" "os" "time" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" "github.com/google/go-github/v50/github" ) const ( defaultHost = "127.0.0.1" defaultPort = "10000" defaultUpst...
willdurand/container-registry-proxy
15
📖 A proxy that makes the GitHub Container Registry compatible with the Docker Registry HTTP API V2 specification.
Go
willdurand
William Durand
mozilla
main_test.go
Go
package main import ( "context" "fmt" "net/http" "net/http/httptest" "strings" "testing" "github.com/google/go-github/v50/github" ) type githubClientMock struct { Packages []*github.Package PackageVersions []*github.PackageVersion Err error } func (c *githubClientMock) ListPackages(ctx ...
willdurand/container-registry-proxy
15
📖 A proxy that makes the GitHub Container Registry compatible with the Docker Registry HTTP API V2 specification.
Go
willdurand
William Durand
mozilla
cmd/microvm/create.go
Go
package main import ( "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/microvm" ) func init() { createCmd := &cobra.Command{ Use: "create <id>", Short: "Create a container", Run: cli.HandleErrors(func(cmd *cobra.Command, args []string) err...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/microvm/delete.go
Go
package main import ( "os" "path/filepath" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" ) func init() { deleteCmd := &cobra.Command{ Use: "delete <id>", Aliases: []string{"del", "rm"}, Short: "Delete a container", Run: cli.HandleErrors(func(cmd *cobra.Command, args []st...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/microvm/kill.go
Go
package main import ( "syscall" "github.com/docker/docker/pkg/signal" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/microvm" ) func init() { killCmd := &cobra.Command{ Use: "kill <id> [<signal>]", Short: "Send a signal to a container",...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/microvm/main.go
Go
package main import "github.com/willdurand/containers/internal/cli" const ( programName string = "microvm" ) // rootCmd represents the base command when called without any subcommands. var rootCmd = cli.NewRootCommand( programName, "An experimental runtime backed by micro VMs", ) func init() { rootCmd.Persisten...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/microvm/redirect_stdio.go
Go
package main import ( "bufio" "fmt" "io" "os" "sync" "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/microvm/container" ) func init() { redirectStdioCmd := &cobra.Command{ Use: "redirect-stdio <id>", Sho...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/microvm/start.go
Go
package main import ( "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/microvm" ) func init() { startCmd := &cobra.Command{ Use: "start <id>", Short: "Start a container", Run: cli.HandleErrors(func(cmd *cobra.Command, args []string) error ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/microvm/state.go
Go
package main import ( "os" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/microvm" ) func init() { stateCmd := &cobra.Command{ Use: "state <id>", Short: "Query the state of a container", Run: cli.HandleErrors(func(cmd *cobra.Command, a...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yacr/create.go
Go
package main import ( "fmt" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yacr" ) func init() { cmd := &cobra.Command{ Use: "create <id>", Short: "Create a container", Run: cli.HandleErrors(create), Args: cobra.ExactArgs(1), } ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yacr/delete.go
Go
package main import ( "fmt" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yacr" ) func init() { cmd := &cobra.Command{ Use: "delete <id>", Aliases: []string{"del", "rm"}, Short: "Delete a container", Run: cli.HandleErrors(de...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yacr/kill.go
Go
package main import ( "fmt" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yacr" ) func init() { cmd := &cobra.Command{ Use: "kill <id> [<signal>]", Short: "Send a signal to a container", Run: cli.HandleErrors(kill), Args: cobra.M...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yacr/list.go
Go
package main import ( "fmt" "os" "text/tabwriter" "time" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yacr" ) func init() { cmd := &cobra.Command{ Use: "list", Aliases: []string{"ls"}, Short: "List containers", Run: cli....
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yacr/main.go
Go
// Yet Another Container Runtime package main import "github.com/willdurand/containers/internal/cli" const ( programName string = "yacr" ) // rootCmd represents the base command when called without any subcommands. var rootCmd = cli.NewRootCommand( programName, "Yet another (unsafe) container runtime", ) func in...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yacr/spec.go
Go
package main import ( "encoding/json" "os" "path/filepath" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/runtime" ) func init() { cmd := &cobra.Command{ Use: "spec", Short: "Create a new specification file for a bundle", Run: cli....
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yacr/start.go
Go
package main import ( "fmt" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yacr" ) func init() { cmd := &cobra.Command{ Use: "start <id>", Short: "Start a container", Run: cli.HandleErrors(start), Args: cobra.ExactArgs(1), } roo...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yacr/state.go
Go
package main import ( "fmt" "os" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yacr" ) func init() { cmd := &cobra.Command{ Use: "state <id>", Short: "Query the state of a container", Run: cli.HandleErrors(state), Args: cobra.Ex...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yacs/main.go
Go
package main import ( "fmt" "github.com/sevlyar/go-daemon" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yacs" ) func main() { rootCmd := cli.NewRootCommand("yacs", "Yet another container shim") rootCmd.Run = cli.HandleErrors(run) rootCmd....
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/container/attach.go
Go
package container import ( "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yaman" ) func init() { cmd := &cobra.Command{ Use: "attach <container>", Short: "Attach standard input, output, and error streams to a runnin...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/container/cleanup.go
Go
package container import ( "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yaman" ) func init() { cmd := &cobra.Command{ Use: "cleanup <container>", Short: "Clean-up a container", Hidden: true, Run: cli.HandleErrors(cleanUp), Arg...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/container/container.go
Go
package container import ( "github.com/spf13/cobra" "github.com/willdurand/containers/internal/yaman" ) var containerCommand = &cobra.Command{ Use: "container", Aliases: []string{"c"}, Short: "Manage containers", } func Register(rootCmd *cobra.Command) { rootCmd.AddCommand(containerCommand) } func compl...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/container/create.go
Go
package container import ( "encoding/json" "fmt" "os" "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yaman" "github.com/willdurand/containers/internal/yaman/container" "github.com/willdurand/containers/internal/...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/container/delete.go
Go
package container import ( "fmt" "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yaman" ) func init() { cmd := &cobra.Command{ Use: "delete <container> [<container>...]", Aliases: []string{"del", "rm", "rem...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/container/hook.go
Go
package container import ( "os" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yaman" ) func init() { cmd := &cobra.Command{ Use: "hook <hook>", Short: "Hidden command called by the OCI runtime", Hidden: true, Run: cli.HandleErr...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/container/inspect.go
Go
package container import ( "encoding/json" "os" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yaman" ) func init() { cmd := &cobra.Command{ Use: "inspect <container>", Short: "Return low-level information on the...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/container/list.go
Go
package container import ( "fmt" "os" "text/tabwriter" "time" "github.com/docker/go-units" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yaman" ) func init() { cmd := &cobra.Command{ Use: "list", Short: "List containers", Alia...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/container/logs.go
Go
package container import ( "os" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yaman" ) func init() { cmd := &cobra.Command{ Use: "logs <container>", Short: "Fetch the logs of a container", Run: cl...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/container/restart.go
Go
package container import ( "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yaman" ) func init() { cmd := &cobra.Command{ Use: "restart <container>", Short: "Restart a container", Run: cli.HandleErrors...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/container/run.go
Go
package container import ( "fmt" "os" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yaman" "github.com/willdurand/containers/internal/yaman/registry" "github.com/willdurand/containers/internal/yaman/shim" ) func init() { cmd := &cobra.Comm...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/container/start.go
Go
package container import ( "os" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yaman" ) func init() { cmd := &cobra.Command{ Use: "start <container>", Short: "Start a container", Run: cli.HandleErr...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/container/stop.go
Go
package container import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yaman" ) func init() { cmd := &cobra.Command{ Use: "stop <container> [<container>...]", Short: "Stop one or mor...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/image/image.go
Go
package image import "github.com/spf13/cobra" var imageCommand = &cobra.Command{ Use: "image", Aliases: []string{"i"}, Short: "Manage images", } func Register(rootCmd *cobra.Command) { rootCmd.AddCommand(imageCommand) }
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/image/list.go
Go
package image import ( "fmt" "os" "text/tabwriter" "time" "github.com/docker/go-units" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yaman" ) func init() { cmd := &cobra.Command{ Use: "list", Aliases: []string{"ls"}, Short: "L...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/image/pull.go
Go
package image import ( "os" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/cli" "github.com/willdurand/containers/internal/yaman/image" "github.com/willdurand/containers/internal/yaman/registry" ) func init() { cmd := &cobra.Command{ Use: "pull <image>", Short: "Pull an image from a ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
cmd/yaman/main.go
Go
// Yet Another (Container) MANager. package main import ( "github.com/willdurand/containers/cmd/yaman/container" "github.com/willdurand/containers/cmd/yaman/image" "github.com/willdurand/containers/internal/cli" ) const ( programName string = "yaman" ) // rootCmd represents the root command. var rootCmd = cli.Ne...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
extras/docker/hello-world/hello.c
C
#include <unistd.h> const char message[] = "\n" "Hello from @willdurand!\n" "\n" "This message shows that your installation appears to be working correctly\n" "(but that might be a lie because this is bleeding edge technology).\n" "\n" "To generate this message, Yaman took the following steps:\n" " 1. ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
extras/microvm/init.c
C
#include <errno.h> #include <fcntl.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/mount.h> #include <sys/reboot.h> #include <sys/stat.h> #include <termios.h> #include <unistd.h> static const char *MV_ENV_VARS[] = {"MV_INIT", "MV_HOSTNAME", "MV_DEBUG", ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/cli/cli.go
Go
// Package cli contains the common features used to build CLI applications. package cli import ( "errors" "fmt" "io/fs" "os" "path/filepath" "strings" "github.com/sirupsen/logrus" "github.com/sirupsen/logrus/hooks/writer" "github.com/spf13/cobra" "github.com/willdurand/containers/internal/version" ) // New...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/cli/error.go
Go
package cli type ExitCodeError struct { Message string ExitCode int } func (e ExitCodeError) Error() string { return e.Message }
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/cmd/cmd.go
Go
package cmd import ( "fmt" "os/exec" "strings" ) // Run runs a given command and tries to return more meaningful information when // something goes wrong. func Run(c *exec.Cmd) error { if _, err := c.Output(); err != nil { if exitError, ok := err.(*exec.ExitError); ok { return fmt.Errorf("%s: %w", strings.Tr...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/constants/constants.go
Go
// Package constants provides common constant definitions. package constants
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/constants/state.go
Go
package constants const ( // StateCreating indicates that the container is being created. StateCreating string = "creating" // StateCreated indicates that the runtime has finished the create operation. StateCreated string = "created" // StateRunning indicates that the container process has executed the // user-s...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/logs/errors.go
Go
package logs import ( "bytes" "encoding/json" "errors" "io/ioutil" "os" ) // GetBetterError parses a log file in order to return an error that is more // informative than the default one passed as a second argument. func GetBetterError(logFilePath string, defaultError error) error { logFile, err := os.Open(logF...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/microvm/container/container.go
Go
package container import ( "fmt" "path/filepath" "strings" "github.com/willdurand/containers/internal/runtime" ) type MicrovmContainer struct { *runtime.BaseContainer } // kernelPath is the path to the kernel binary on the host. This path should be // kept in sync with the `make -C microvm install_kernel` comm...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/microvm/create.go
Go
package microvm import ( "bytes" "errors" "fmt" "io/fs" "io/ioutil" "net" "os" "os/exec" "path/filepath" "strconv" "github.com/creack/pty" "github.com/sirupsen/logrus" "github.com/willdurand/containers/internal/microvm/container" "golang.org/x/sys/unix" _ "embed" ) type CreateOpts struct { PidFile ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/microvm/kill.go
Go
package microvm import ( "fmt" "syscall" "github.com/willdurand/containers/internal/microvm/container" ) func Kill(rootDir, containerId string, signal syscall.Signal) error { container, err := container.LoadWithBundleConfig(rootDir, containerId) if err != nil { return err } if !container.IsCreated() && !co...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/microvm/start.go
Go
package microvm import ( "fmt" "github.com/willdurand/containers/internal/constants" "github.com/willdurand/containers/internal/microvm/container" ) func Start(rootDir, containerId string) error { container, err := container.LoadWithBundleConfig(rootDir, containerId) if err != nil { return err } if !contai...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/microvm/state.go
Go
package microvm import ( "encoding/json" "io" "github.com/willdurand/containers/internal/microvm/container" ) func State(rootDir, containerId string, w io.Writer) error { container, err := container.LoadWithBundleConfig(rootDir, containerId) if err != nil { return err } if err := json.NewEncoder(w).Encode(...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/runtime/container.go
Go
package runtime import ( "bytes" "encoding/json" "errors" "fmt" "io/fs" "io/ioutil" "os" "path/filepath" "time" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/willdurand/containers/internal/constants" ) type BaseContainer struct { Spec runtimespec.Spec State r...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/runtime/runtime.go
Go
package runtime import ( "encoding/json" "fmt" "io/ioutil" "os" "path/filepath" "strings" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/willdurand/containers/internal/user" ) func LoadSpec(bundleDir string) (runtimespec.Spec, error) { var spec runtimespec.Spec data, err := iout...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/user/user.go
Go
package user import ( "bufio" "errors" "io" "os" "os/user" "strconv" "strings" ) var ( ErrInvalidEntry = errors.New("invalid entry in subordinate file") ErrNotFound = errors.New("no subordinate IDs found for current user") ) // SubordinateID represents a range of subordinate (user or group) IDs. // // S...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/user/user_test.go
Go
package user import ( "bytes" "testing" ) func TestParseSubordinateIDs(t *testing.T) { var buffer bytes.Buffer buffer.WriteString("vagrant:100000:65536\n") buffer.WriteString("ubuntu:165536:65536\n") ids, err := parseSubordinateIDs(&buffer) if err != nil { t.Error("failed to parse subuid") } if len(ids) ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/version/version.go
Go
// Package version provides a function to print the version of this project, // and it is usually exposed in a `version` command for each CLI application. package version import ( "runtime" "strings" runtimespec "github.com/opencontainers/runtime-spec/specs-go" ) var ( // VersionString represents the project's v...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacr/container/container.go
Go
package container import ( "bytes" "encoding/json" "fmt" "os" "os/exec" "path/filepath" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" "github.com/willdurand/containers/internal/runtime" "github.com/willdurand/containers/internal/yacr/ipc" ) type YacrContainer st...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacr/create.go
Go
package yacr import ( "errors" "fmt" "io/ioutil" "net" "os" "os/exec" "strconv" "syscall" "github.com/creack/pty" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" "github.com/willdurand/containers/internal/cmd" "github.com/willdurand/containers/internal/yacr/cont...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacr/create_container.go
Go
package yacr import ( "errors" "fmt" "io/fs" "net" "os" "os/exec" "path/filepath" "strconv" "syscall" "time" "github.com/sirupsen/logrus" "github.com/willdurand/containers/internal/yacr/container" "github.com/willdurand/containers/internal/yacr/ipc" "golang.org/x/sys/unix" ) func CreateContainer(rootDi...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacr/delete.go
Go
package yacr import ( "fmt" "os" "path/filepath" "syscall" "github.com/sirupsen/logrus" "github.com/willdurand/containers/internal/yacr/container" ) func Delete(rootDir, containerId string, force bool) error { container, err := container.LoadWithBundleConfig(rootDir, containerId) if err != nil { if force {...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacr/ipc/messages.go
Go
package ipc const ( CONTAINER_BOOTED string = "container:booted" CONTAINER_BEFORE_PIVOT string = "container:before-pivot" CONTAINER_WAIT_START string = "container:wait-start" START_CONTAINER string = "start-container" OK string = "ok" )
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacr/ipc/utils.go
Go
package ipc import ( "errors" "fmt" "io/fs" "net" "os" ) func EnsureValidSockAddr(sockAddr string, mustExist bool) error { if sockAddr == "" { return fmt.Errorf("socket address '%s' is empty", sockAddr) } if len(sockAddr) > 108 { // LOL: https://github.com/moby/moby/pull/13408 return fmt.Errorf("socket ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacr/kill.go
Go
package yacr import ( "fmt" "syscall" "github.com/docker/docker/pkg/signal" "github.com/sirupsen/logrus" "github.com/willdurand/containers/internal/yacr/container" ) func Kill(rootDir string, args []string) error { containerId := args[0] sig := syscall.SIGTERM if len(args) > 1 { if s, err := signal.ParseS...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacr/list.go
Go
package yacr import ( "fmt" "io/ioutil" "time" "github.com/sirupsen/logrus" "github.com/willdurand/containers/internal/yacr/container" ) type ContainerListItem struct { ID string Status string CreatedAt time.Time PID int BundlePath string } type ContainerList []ContainerListItem func ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacr/start.go
Go
package yacr import ( "bytes" "errors" "fmt" "io/ioutil" "net" "github.com/sirupsen/logrus" "github.com/willdurand/containers/internal/constants" "github.com/willdurand/containers/internal/yacr/container" "github.com/willdurand/containers/internal/yacr/ipc" ) func Start(rootDir, containerId string) error { ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacr/state.go
Go
package yacr import ( "encoding/json" "io" "github.com/willdurand/containers/internal/yacr/container" ) func State(rootDir, containerId string, w io.Writer) error { container, err := container.LoadWithBundleConfig(rootDir, containerId) if err != nil { return err } if err := json.NewEncoder(w).Encode(contai...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacs/container.go
Go
package yacs import ( "bufio" "bytes" "errors" "fmt" "io" "io/fs" "net" "os" "os/exec" "path/filepath" "strconv" "syscall" "github.com/sirupsen/logrus" "github.com/willdurand/containers/internal/cmd" "github.com/willdurand/containers/internal/logs" "github.com/willdurand/containers/internal/yacs/log" ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacs/container_status.go
Go
package yacs import ( "encoding/json" "syscall" ) // ContainerStatus represents the container process status and especially the // (wait) status after the process has exited. type ContainerStatus struct { PID int WaitStatus *syscall.WaitStatus } func (s *ContainerStatus) Exited() bool { return s.WaitStat...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacs/container_status_test.go
Go
package yacs import ( "encoding/json" "syscall" "testing" ) func TestJSON(t *testing.T) { wstatus := syscall.WaitStatus(0) s1 := &ContainerStatus{ PID: 123, WaitStatus: &wstatus, } if !s1.Exited() { t.Error("s1 is not exited") } data, err := json.Marshal(s1) if err != nil { t.Error(err) } ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacs/http_server.go
Go
package yacs import ( "context" "encoding/json" "errors" "fmt" "net" "net/http" "path/filepath" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" "github.com/willdurand/containers/internal/constants" ) const shimSocketName = "shim.sock" var ( ErrNotCreated = error...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacs/log/file.go
Go
package log import ( "encoding/json" "os" "sync" "time" "github.com/sirupsen/logrus" ) type LogFile struct { sync.Mutex file *os.File } func NewFile(name string) (*LogFile, error) { file, err := os.OpenFile(name, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644) if err != nil { return nil, err } return &Lo...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacs/runtime.go
Go
package yacs import ( "bytes" "encoding/json" "errors" "os/exec" "path/filepath" "strings" "syscall" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" ) const ( runtimeLogFileName = "runtime.log" ) var ( ErrContainerNotExist = errors.New("container does not exist"...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacs/sync_pipe.go
Go
package yacs import ( "errors" "io/fs" "os" "path/filepath" "syscall" "golang.org/x/sys/unix" ) // syncPipeName is the name of the named pipe used by both the parent and child // process to communicate when Yacs is executed. We need this pipe because we // "fork" in order to spawn a daemon process but we don't...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yacs/yacs.go
Go
package yacs import ( "bytes" "errors" "fmt" "io/ioutil" "os" "os/exec" "path/filepath" "syscall" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" "github.com/spf13/pflag" "github.com/willdurand/containers/internal/runtime" "golang.org/x/sys/unix" ) const ( con...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/container/container.go
Go
package container import ( "encoding/json" "fmt" "os" "os/exec" "path/filepath" "strings" "syscall" "time" "github.com/google/uuid" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" "github.com/willdurand/containers/internal/cmd" "github.com/willdurand/containers/...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/container/utils.go
Go
package container import "path/filepath" func GetBaseDir(rootDir string) string { return filepath.Join(rootDir, "containers") }
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/container_attach.go
Go
package yaman import ( "github.com/willdurand/containers/internal/yaman/shim" ) type AttachOpts struct { Stdin bool Stdout bool Stderr bool } func Attach(rootDir, id string, opts AttachOpts) error { shim, err := shim.Load(rootDir, id) if err != nil { return err } return shim.Attach(opts.Stdin, opts.Stdou...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/container_cleanup.go
Go
package yaman import "github.com/willdurand/containers/internal/yaman/shim" func CleanUp(rootDir, id string) error { shim, err := shim.Load(rootDir, id) if err != nil { return err } if err := shim.Terminate(); err != nil { return err } if shim.Container.Opts.Remove { return shim.Delete() } return nil...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/container_create.go
Go
package yaman import ( "github.com/willdurand/containers/internal/yaman/container" "github.com/willdurand/containers/internal/yaman/image" "github.com/willdurand/containers/internal/yaman/registry" "github.com/willdurand/containers/internal/yaman/shim" ) func Create(rootDir, imageName string, pullOpts registry.Pu...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/container_delete.go
Go
package yaman import "github.com/willdurand/containers/internal/yaman/shim" // Delete deletes a container. func Delete(rootDir, id string) error { shim, err := shim.Load(rootDir, id) if err != nil { return err } return shim.Delete() }
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/container_hook.go
Go
package yaman import ( "encoding/json" "io" "io/ioutil" "path/filepath" "strconv" "time" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" "github.com/willdurand/containers/internal/yaman/network" "github.com/willdurand/containers/internal/yaman/shim" ) func Process...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/container_inspect.go
Go
package yaman import ( "time" imagespec "github.com/opencontainers/image-spec/specs-go/v1" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/willdurand/containers/internal/yacs" "github.com/willdurand/containers/internal/yaman/container" "github.com/willdurand/containers/internal/yaman/i...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/container_list.go
Go
package yaman import ( "fmt" "io/ioutil" "regexp" "sort" "strings" "time" "github.com/docker/go-units" "github.com/willdurand/containers/internal/constants" "github.com/willdurand/containers/internal/yaman/container" "github.com/willdurand/containers/internal/yaman/network" "github.com/willdurand/container...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/container_logs.go
Go
package yaman import ( "io" "github.com/willdurand/containers/internal/yaman/shim" ) // CopyLogsOpts contains the options for the `CopyLogs` function. type CopyLogsOpts struct { Timestamps bool Stdout io.Writer Stderr io.Writer } // CopyLogs copies the logs of a container to the writers specified in th...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/container_restart.go
Go
package yaman import ( "github.com/willdurand/containers/internal/yaman/shim" ) func Restart(rootDir, id string) error { shim, err := shim.Load(rootDir, id) if err != nil { return err } if err := shim.Recreate(rootDir); err != nil { return err } sOpts := StartOpts{ Attach: false, Interactive: fa...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/container_run.go
Go
package yaman import ( "github.com/willdurand/containers/internal/yaman/container" "github.com/willdurand/containers/internal/yaman/registry" "github.com/willdurand/containers/internal/yaman/shim" ) // RunResult represents the return value of the `Run` function. type RunResult struct { ContainerID string ExitSta...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/container_start.go
Go
package yaman import ( "github.com/willdurand/containers/internal/yaman/shim" ) type StartOpts struct { Attach bool Interactive bool } type StartResult struct { ExitStatus int } func Start(rootDir, id string, opts StartOpts) (StartResult, error) { var result StartResult shim, err := shim.Load(rootDir, i...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/container_stop.go
Go
package yaman import "github.com/willdurand/containers/internal/yaman/shim" func Stop(rootDir, id string) error { shim, err := shim.Load(rootDir, id) if err != nil { return err } return shim.StopContainer() }
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/image/image.go
Go
package image import ( "encoding/json" "fmt" "os" "path/filepath" "regexp" "strings" imagespec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/willdurand/containers/internal/yaman/network" ) // Image represents a OCI image. type Image struct { Hostname string Name string Version string...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/image/image_test.go
Go
package image import "testing" func TestIsNameValid(t *testing.T) { for _, tc := range []struct { name string expected bool }{ {"", false}, {"alpine:latest", false}, {"alpine", true}, {"library/alpine", true}, {"gcr.io/project/image", true}, } { if valid := isNameValid(tc.name); valid != tc.exp...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/image/utils.go
Go
package image // isNameValid validates the name of an image. func isNameValid(name string) bool { return imageNamePattern.MatchString(name) }
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/image_list.go
Go
package yaman import ( "errors" "io/fs" "io/ioutil" "path/filepath" "sort" "strings" "time" "github.com/willdurand/containers/internal/yaman/image" ) type ImageListItem struct { Registry string Name string Version string Created time.Time Pulled time.Time } type ImageList []ImageListItem func ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/network/exposed_port.go
Go
package network import ( "errors" "fmt" "strconv" "strings" ) var ErrInvalidExposedPort = errors.New("invalid exposed port") type ExposedPort struct { Proto string HostAddr string HostPort int GuestAddr string GuestPort int } // String returns a human-readable representation of an exposed port. func ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/network/exposed_port_test.go
Go
package network import "testing" func TestExposedPort(t *testing.T) { for _, tc := range []struct { port ExposedPort expected string }{ { port: ExposedPort{ Proto: "tcp", HostAddr: "1.2.3.4", HostPort: 1234, GuestPort: 4567, }, expected: "1.2.3.4:1234->4567/tcp", }, { ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla
internal/yaman/network/slirp4netns.go
Go
package network import ( "encoding/json" "fmt" "net" "os/exec" "strconv" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) type Slirp4netnsCommand struct { Execute string `json:"execute"` Args map[string]interface{} `json:"arguments,omitempty"` } type Slirp4netns struct { pid ...
willdurand/containers
9
📦 This is a repository with some code I wrote to learn more about containers.
Go
willdurand
William Durand
mozilla