### Starting the Daemon Source: https://github.com/letsencrypt/boulder/blob/main/cmd/boulder-observer/README.md Example of starting the boulder-observer daemon with a specified configuration file and sample output logs showing monitor checks. ```shell $ ./boulder-observer -config test/config-next/observer.yml I152525 boulder-observer _KzylQI Versions: main=(Unspecified Unspecified) Golang=(go1.16.2) BuildHost=(Unspecified) I152525 boulder-observer q_D84gk Initializing boulder-observer daemon from config: test/config-next/observer.yml I152525 boulder-observer 7aq68AQ all monitors passed validation I152527 boulder-observer yaefiAw kind=[HTTP] success=[true] duration=[0.130097] name=[https://letsencrypt.org-[200]] I152527 boulder-observer 65CuDAA kind=[HTTP] success=[true] duration=[0.148633] name=[http://letsencrypt.org/foo-[200 404]] I152530 boulder-observer idi4rwE kind=[DNS] success=[false] duration=[0.000093] name=[[2606:4700:4700::1111]:53-udp-A-google.com-recurse] I152530 boulder-observer prOnrw8 kind=[DNS] success=[false] duration=[0.000242] name=[[2606:4700:4700::1111]:53-tcp-A-google.com-recurse] I152530 boulder-observer 6uXugQw kind=[DNS] success=[true] duration=[0.022962] name=[1.1.1.1:53-udp-A-google.com-recurse] I152530 boulder-observer to7h-wo kind=[DNS] success=[true] duration=[0.029860] name=[owen.ns.cloudflare.com:53-udp-A-letsencrypt.org-no-recurse] I152530 boulder-observer ovDorAY kind=[DNS] success=[true] duration=[0.033820] name=[owen.ns.cloudflare.com:53-tcp-A-letsencrypt.org-no-recurse] ... ``` -------------------------------- ### Installation and Import Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/letsencrypt/validator/v10/README.md Instructions for installing the validator package using go get and importing it into your Go project. ```go go get github.com/go-playground/validator/v10 import "github.com/letsencrypt/validator/v10" ``` -------------------------------- ### Development Environment Setup Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/redis/go-redis/v9/CONTRIBUTING.md Starts Docker containers for development and testing. Allows specifying a Redis image via an environment variable. ```bash make docker.start # To specify a Redis image: CLIENT_LIBS_TEST_IMAGE="your-redis-image:tag" make docker.start ``` -------------------------------- ### Building and Installing the miekg/dns Library Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/miekg/dns/README.md Instructions for building and installing the miekg/dns library using Go modules. It covers fetching the library and building the project. ```go go get github.com/miekg/dns go build github.com/miekg/dns ``` -------------------------------- ### Install Go-MySQL-Driver Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/go-sql-driver/mysql/README.md Installs the Go-MySQL-Driver using the go tool. Requires Git to be installed and in the system's PATH. ```bash go get -u github.com/go-sql-driver/mysql ``` -------------------------------- ### Boulder Database Permissions Example Source: https://github.com/letsencrypt/boulder/wiki/Deployment-&-Implementation-Guide Illustrative SQL snippet for granting database permissions to Boulder components, as found in `test/sa_db_users.sql`. This requires customization based on your deployment environment. ```go -- Example for granting permissions to a Boulder component -- GRANT SELECT, INSERT, UPDATE, DELETE ON boulder_db.* TO 'boulder_user'@'localhost' IDENTIFIED BY 'password'; ``` -------------------------------- ### Install go-redis OpenTelemetry Extra Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/redis/go-redis/extra/redisotel/v9/README.md Installs the go-redis extra package for OpenTelemetry instrumentation using go get. ```bash go get github.com/redis/go-redis/extra/redisotel/v9 ``` -------------------------------- ### Boulder Configuration: DNS Resolvers Example Source: https://github.com/letsencrypt/boulder/wiki/Deployment-&-Implementation-Guide Example of the `dnsResolvers` configuration in Boulder, specifying the DNS resolvers to be used for validation lookups. ```json { "dnsResolvers": [ "192.168.1.1", "192.168.1.2" ] } ``` -------------------------------- ### Redis Command Examples Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/redis/go-redis/v9/RELEASE-NOTES.md Adds comprehensive examples for various Redis commands, including hash search, list operations (LLEN, LPOP, LPUSH, LRANGE, RPOP, RPUSH), and set operations (SADD, SMEMBERS). ```go // Added hash search examples ([#3357]) // Added examples for list commands: LLEN, LPOP, LPUSH, LRANGE, RPOP, RPUSH ([#3234]) // Added SADD and SMEMBERS command examples ([#3242]) ``` -------------------------------- ### Start Local Prometheus Instance Source: https://github.com/letsencrypt/boulder/blob/main/cmd/boulder-observer/README.md Command to start a local Prometheus instance using a specified configuration file. This is part of the development setup for the Boulder project. ```shell prometheus --config.file=boulder/test/prometheus/prometheus.yml ``` -------------------------------- ### Install gRPC-Go Source: https://github.com/letsencrypt/boulder/blob/main/vendor/google.golang.org/grpc/README.md Demonstrates how to import the gRPC-Go library into your Go project for automatic dependency fetching. ```go import "google.golang.org/grpc" ``` -------------------------------- ### Initialize Procfs and Get Stats Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/prometheus/procfs/README.md Demonstrates how to initialize the proc filesystem and retrieve CPU statistics using the procfs library. ```go fs, err := procfs.NewFS("/proc") stats, err := fs.Stat() ``` -------------------------------- ### Typical Application Logging Setup in Go Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/go-logr/logr/README.md Demonstrates how an application typically initializes a logger using a specific implementation (e.g., 'logimpl') and passes it to other parts of the application. This setup is done early in the application's lifecycle. ```go package main import ( "time" "github.com/go-logr/logr" // Assume logimpl is a hypothetical logging implementation "path/to/logimpl" ) type appObject struct { logger logr.Logger } func createTheAppObject(logger logr.Logger) *appObject { return &appObject{logger: logger} } func (app *appObject) Run() { app.logger.Info("starting up", "timestamp", time.Now()) // ... app code ... } func main() { // Create the "root" logger. We have chosen the "logimpl" implementation. logger := logimpl.New("param1", "param2") // Pass the logger to other parts of the application app := createTheAppObject(logger) app.Run() } ``` -------------------------------- ### Install go-redis/v9 Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/redis/go-redis/v9/README.md Installs the latest v9 of the go-redis library using the go get command. This requires a Go module-enabled project. ```shell go get github.com/redis/go-redis/v9 ``` -------------------------------- ### Install tomll CLI tool Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/pelletier/go-toml/README.md Provides instructions on how to install the 'tomll' command-line tool for linting TOML files. ```bash go install github.com/pelletier/go-toml/cmd/tomll tomll --help ``` -------------------------------- ### Install jsontoml CLI tool Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/pelletier/go-toml/README.md Provides instructions on how to install the 'jsontoml' command-line tool for converting JSON to TOML. ```bash go install github.com/pelletier/go-toml/cmd/jsontoml jsontoml --help ``` -------------------------------- ### Install Universal Translator Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/go-playground/universal-translator/README.md Installs the Universal Translator Go package using the go get command. This is the standard method for adding dependencies in Go projects. ```shell go get github.com/go-playground/universal-translator ``` -------------------------------- ### Install tomljson CLI tool Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/pelletier/go-toml/README.md Provides instructions on how to install the 'tomljson' command-line tool for converting TOML to JSON. ```bash go install github.com/pelletier/go-toml/cmd/tomljson tomljson --help ``` -------------------------------- ### Redis Command Examples with go-redis Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/redis/go-redis/v9/README.md Illustrates how to execute various Redis commands using the go-redis client library. This includes examples for setting keys with TTL and NX options, sorting lists, retrieving ranges from sorted sets with scores, performing intersection operations on sorted sets, executing Lua scripts, and running custom commands. ```go // SET key value EX 10 NX set, err := rdb.SetNX(ctx, "key", "value", 10*time.Second).Result() // SET key value keepttl NX set, err := rdb.SetNX(ctx, "key", "value", redis.KeepTTL).Result() // SORT list LIMIT 0 2 ASC vals, err := rdb.Sort(ctx, "list", &redis.Sort{Offset: 0, Count: 2, Order: "ASC"}).Result() // ZRANGEBYSCORE zset -inf +inf WITHSCORES LIMIT 0 2 vals, err := rdb.ZRangeByScoreWithScores(ctx, "zset", &redis.ZRangeBy{ Min: "-inf", Max: "+inf", Offset: 0, Count: 2, }).Result() // ZINTERSTORE out 2 zset1 zset2 WEIGHTS 2 3 AGGREGATE SUM vals, err := rdb.ZInterStore(ctx, "out", &redis.ZStore{ Keys: []string{"zset1", "zset2"}, Weights: []int64{2, 3} }).Result() // EVAL "return {KEYS[1],ARGV[1]}" 1 "key" "hello" vals, err := rdb.Eval(ctx, "return {KEYS[1],ARGV[1]}", []string{"key"}, "hello").Result() // custom command res, err := rdb.Do(ctx, "set", "key", "value").Result() ``` -------------------------------- ### Boulder Configuration: Server Address Example Source: https://github.com/letsencrypt/boulder/wiki/Deployment-&-Implementation-Guide Demonstrates the `serverAddress` configuration for Boulder components acting as gRPC clients, specifying the address of the gRPC server. ```json { "serverAddress": "boulder-grpc-server.example.com" } ``` -------------------------------- ### Boulder Configuration: Client Names Example Source: https://github.com/letsencrypt/boulder/wiki/Deployment-&-Implementation-Guide Shows the `clientNames` configuration within a Boulder component's JSON file, used for specifying allowed client certificate Subject Alternative Names (SANs) for access control. ```json { "clientNames": [ "boulder-wfe", "boulder-wfe2" ] } ``` -------------------------------- ### Complete PKCS#11 Program Skeleton in Go Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/miekg/pkcs11/README.md A comprehensive Go example demonstrating a full PKCS#11 interaction flow. It includes initializing the library, opening and closing a session, logging in and out, retrieving slot lists, and performing a SHA-1 digest operation on a string. The example also shows proper error handling and resource cleanup using `defer`. ```Go p := pkcs11.New("/usr/lib/softhsm/libsofthsm2.so") err := p.Initialize() if err != nil { panic(err) } defer p.Destroy() defer p.Finalize() slots, err := p.GetSlotList(true) if err != nil { panic(err) } session, err := p.OpenSession(slots[0], pkcs11.CKF_SERIAL_SESSION|pkcs11.CKF_RW_SESSION) if err != nil { panic(err) } defer p.CloseSession(session) err = p.Login(session, pkcs11.CKU_USER, "1234") if err != nil { panic(err) } defer p.Logout(session) p.DigestInit(session, []*pkcs11.Mechanism{pkcs11.NewMechanism(pkcs11.CKM_SHA_1, nil)}) hash, err := p.Digest(session, []byte("this is a string")) if err != nil { panic(err) } for _, d := range hash { fmt.Printf("%x", d) } fmt.Println() ``` -------------------------------- ### Example smithy-build.json for Go Codegen Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/aws/smithy-go/README.md Provides an example `smithy-build.json` configuration demonstrating how to apply the `go-codegen` build plugin to a Smithy model, including service, module, and Go version settings. ```json { "version": "1.0", "sources": [ "models" ], "maven": { "dependencies": [ "software.amazon.smithy.go:smithy-go-codegen:0.1.0" ] }, "plugins": { "go-codegen": { "service": "example.weather#Weather", "module": "github.com/example/weather", "generateGoMod": true, "goDirective": "1.20" } } } ``` -------------------------------- ### Universal Translator Go Usage Examples Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/go-playground/universal-translator/README.md Provides links to example implementations of the Universal Translator library in Go. These examples cover basic usage, advanced features without file loading, and usage with external translation files. ```go // Basic usage example: // https://github.com/go-playground/universal-translator/tree/master/_examples/basic // Full usage without files: // https://github.com/go-playground/universal-translator/tree/master/_examples/full-no-files // Full usage with files: // https://github.com/go-playground/universal-translator/tree/master/_examples/full-with-files ``` -------------------------------- ### DSN Format and Examples Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/go-sql-driver/mysql/README.md Illustrates the common format of Data Source Names (DSN) used in database connections, including optional components and examples of full and minimal DSN strings. It also shows how database names with slashes are escaped. ```APIDOC DSN Format: [username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN] Full DSN Example: username:password@protocol(address)/dbname?param=value Minimal DSN Example: /dbname DSN with empty dbname: / Escaped DSN with slash: /dbname%2Fwithslash ``` -------------------------------- ### Port Configuration Example Source: https://github.com/letsencrypt/boulder/wiki/Config-plan Illustrates a common pattern where configuration for ports is defined separately from the component that uses them. This separation aims to improve clarity and manage dependencies. ```go type PortConfig struct { HTTPPort int TLSPort int } type ValidationAuthorityImpl struct { ... httpPort int tlsPort int ... } ``` -------------------------------- ### Run Challenge Server Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/letsencrypt/challtestsrv/README.md Starts the challenge server and its associated subservers in a separate Go routine, allowing it to begin listening for and responding to ACME challenges. ```go // Start the Challenge server in its own Go routine go challSrv.Run() ``` -------------------------------- ### Install uuid Package Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/google/uuid/README.md Installs the uuid package using the go get command. This command downloads and installs the package and its dependencies. ```sh go get github.com/google/uuid ``` -------------------------------- ### Database Table Initialization (Go) Source: https://github.com/letsencrypt/boulder/blob/main/docs/CONTRIBUTING.md Illustrates how to initialize database tables using borp, specifically handling versioned model structs based on feature flags. It shows how to add tables with specific names and potentially configure keys and version columns. ```go func initTables(dbMap *borp.DbMap) { if features.Enabled(features.AllowWizards) { dbMap.AddTableWithName(personModelv2, "person") } else { dbMap.AddTableWithName(personModelv1, "person") } } ``` -------------------------------- ### Install Go Locales Package Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/go-playground/locales/README.md Instructions for installing the Go Locales library using the go get command. ```shell go get github.com/go-playground/locales ``` -------------------------------- ### Local Testing Setup for go-redis Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/redis/go-redis/v9/README.md Details the steps required to set up and run tests locally for the go-redis project. This involves specifying the paths to the redis-server binary and configuration file, and then executing the tests using the standard Go testing command. ```go var ( redisServerBin, _ = filepath.Abs(filepath.Join("testdata", "redis", "src", "redis-server")) redisServerConf, _ = filepath.Abs(filepath.Join("testdata", "redis", "redis.conf")) ) ``` -------------------------------- ### Start Local Prometheus Instance Source: https://github.com/letsencrypt/boulder/blob/main/cmd/boulder-observer/README.md Command to start a local Prometheus instance for development. This command assumes a local Prometheus binary is installed and uses the configuration file located at `boulder/test/prometheus/prometheus.yml`. ```shell prometheus --config.file=boulder/test/prometheus/prometheus.yml ``` -------------------------------- ### Basic Redis Client Usage Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/redis/go-redis/v9/README.md Demonstrates initializing a Redis client, setting a key-value pair, and retrieving values. It also shows how to handle cases where a key does not exist. ```go import ( "context" "fmt" "github.com/redis/go-redis/v9" ) var ctx = context.Background() func ExampleClient() { rdb := redis.NewClient(&redis.Options{ Addr: "localhost:6379", Password: "", // no password set DB: 0, // use default DB }) err := rdb.Set(ctx, "key", "value", 0).Err() if err != nil { panic(err) } val, err := rdb.Get(ctx, "key").Result() if err != nil { panic(err) } fmt.Println("key", val) val2, err := rdb.Get(ctx, "key2").Result() if err == redis.Nil { fmt.Println("key2 does not exist") } else if err != nil { panic(err) } else { fmt.Println("key2", val2) } // Output: key value // key2 does not exist } ``` -------------------------------- ### MySQL Connection String Examples Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/go-sql-driver/mysql/README.md Demonstrates various DSN (Data Source Name) formats for connecting to MySQL databases, including different protocols (unix, tcp), authentication methods, host/port specifications, and query parameters for configuration. ```go user@unix(/path/to/socket)/dbname ``` ```go root:pw@unix(/tmp/mysql.sock)/myDatabase?loc=Local ``` ```go user:password@tcp(localhost:5555)/dbname?tls=skip-verify&autocommit=true ``` ```go user:password@/dbname?sql_mode=TRADITIONAL ``` ```go user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s&collation=utf8mb4_unicode_ci ``` ```go id:password@tcp(your-amazonaws-uri.com:3306)/dbname ``` ```go user:password@unix(/cloudsql/project-id:region-name:instance-name)/dbname ``` ```go user:password@tcp/dbname?charset=utf8mb4,utf8&sys_var=esc%40ped ``` ```go user:password@/dbname ``` ```go user:password@/ ``` -------------------------------- ### Docker Setup for Cross-Platform Builds (Ubuntu) Source: https://github.com/letsencrypt/boulder/blob/main/test/boulder-tools/README.md Installs necessary tools and creates a Docker buildx instance for cross-platform builds on Ubuntu systems. This enables building for architectures like amd64 and arm64. ```sh sudo apt-get install qemu binfmt-support qemu-user-static docker buildx create --use --name=cross ``` -------------------------------- ### gRPC Client Host Configuration Example Source: https://github.com/letsencrypt/boulder/wiki/gRPC-notes Illustrates how a gRPC client might be configured to specify the hosts it can connect to. This can be done via command-line flags or configuration files. ```go package main import ( "flag" "fmt" "strings" "google.golang.org/grpc" ) var ( // Example: WFE would gain flags like -ra_hosts and -sa_hosts raHosts = flag.String("ra_hosts", "", "Comma-separated list of Ra service hosts (host:port)") saHosts = flag.String("sa_hosts", "", "Comma-separated list of SA service hosts (host:port)") ) func main() { flag.Parse() // Example of how to use the flags to establish gRPC connections if *raHosts != "" { hosts := strings.Split(*raHosts, ",") for _, host := range hosts { // Establish gRPC connection to host conn, err := grpc.Dial(host, grpc.WithInsecure()) // Use appropriate security options if err != nil { fmt.Printf("Failed to connect to %s: %v\n", host, err) continue } defer conn.Close() fmt.Printf("Connected to Ra host: %s\n", host) // Use the connection for RPC calls } } if *saHosts != "" { hosts := strings.Split(*saHosts, ",") for _, host := range hosts { // Establish gRPC connection to host conn, err := grpc.Dial(host, grpc.WithInsecure()) // Use appropriate security options if err != nil { fmt.Printf("Failed to connect to %s: %v\n", host, err) continue } defer conn.Close() fmt.Printf("Connected to SA host: %s\n", host) // Use the connection for RPC calls } } } ``` -------------------------------- ### Boulder Configuration: TLS Section Example Source: https://github.com/letsencrypt/boulder/wiki/Deployment-&-Implementation-Guide Illustrates the structure of the `tls` section within a Boulder component's JSON configuration file, where CA, certificate, and key paths are specified. ```json { "tls": { "ca": "/path/to/ca.pem", "cert": "/path/to/component.pem", "key": "/path/to/component.key" } } ``` -------------------------------- ### Example Docker Buildx List Output (Stopped Instance) Source: https://github.com/letsencrypt/boulder/blob/main/test/boulder-tools/README.md This output from `docker buildx ls` shows a 'cross' builder instance in a stopped state. The documentation clarifies that this is generally acceptable, as the instance will be automatically started when a build command like `tag_and_upload.sh` is executed. ```sh cross0 unix:///var/run/docker.sock stopped ``` -------------------------------- ### Basic Database Connection Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/go-sql-driver/mysql/README.md Demonstrates how to open a database connection using the Go-MySQL-Driver with the database/sql package. Includes setting connection pool parameters. ```go import ( "database/sql" "time" _ "github.com/go-sql-driver/mysql" ) // ... db, err := sql.Open("mysql", "user:password@/dbname") if err != nil { panic(err) } // See "Important settings" section. db.SetConnMaxLifetime(time.Minute * 3) db.SetMaxOpenConns(10) db.SetMaxIdleConns(10) ``` -------------------------------- ### Running Local Go Doc Site Source: https://github.com/letsencrypt/boulder/blob/main/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Instructions to install and run a local Go Doc site for viewing package documentation. This is useful for checking how your package documentation will appear to users. ```sh go install golang.org/x/pkgsite/cmd/pkgsite@latest pkgsite ``` -------------------------------- ### Install nxadm/tail Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/nxadm/tail/README.md Command to install the nxadm/tail library using Go modules. ```Shell go get github.com/nxadm/tail/... ``` -------------------------------- ### YAML Data Example Source: https://github.com/letsencrypt/boulder/blob/main/vendor/gopkg.in/yaml.v3/README.md A sample YAML string used in the Go example to demonstrate unmarshalling into Go data structures. ```YAML a: Easy! b: c: 2 d: [3, 4] ``` -------------------------------- ### Boulder Remote VA Configuration Examples Source: https://github.com/letsencrypt/boulder/blob/main/docs/multi-va.md Provides example configuration files for Boulder's remote VA instances. ```json { // Configuration for remoteva-a.json // ... } ``` ```json { // Configuration for remoteva-b.json // ... } ``` -------------------------------- ### Initialize Challenge Server Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/letsencrypt/challtestsrv/README.md Creates a new challenge server instance configured to respond to HTTP-01 and DNS-01 challenges on specified network addresses. It requires a configuration struct specifying the listening addresses for each challenge type. ```go import "github.com/letsencrypt/pebble/challtestsrv" challSrv, err := challtestsrv.New(challsrv.Config{ HTTPOneAddr: []string{":8888"}, DNSOneAddr: []string{":9999", "10.0.0.1:9998"}, }) if err != nil { panic(err) } ``` -------------------------------- ### Initialize Block Device FS and Get Disk Stats Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/prometheus/procfs/README.md Shows how to initialize a filesystem that accesses both /proc and /sys to retrieve disk statistics for block devices. ```go fs, err := blockdevice.NewFS("/proc", "/sys") stats, err := fs.ProcDiskstats() ``` -------------------------------- ### Listing Available Invoke Tasks Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/redis/go-redis/v9/CONTRIBUTING.md Displays all available tasks that can be run using the 'invoke' command. ```bash invoke -l ``` -------------------------------- ### Start Redis Docker Compose Source: https://github.com/letsencrypt/boulder/blob/main/docs/redis.md Starts the Boulder development environment, including Redis nodes, using Docker Compose. ```shell docker compose up boulder ``` -------------------------------- ### Start Boulder with Docker Compose Source: https://github.com/letsencrypt/boulder/blob/main/README.md Starts Boulder and its dependencies using Docker Compose. Requires Docker Engine and Docker Compose. ```shell docker compose up ``` -------------------------------- ### Syslog Configuration Example Source: https://github.com/letsencrypt/boulder/blob/main/docs/logging.md Example of syslog configuration within Boulder's JSON configuration file, specifying log levels for stdout and syslog destinations. ```json { "syslog": { "stdoutlevel": 4, "sysloglevel": 6 } } ``` -------------------------------- ### Struct Tag Examples (JSON) Source: https://github.com/letsencrypt/boulder/blob/main/docs/config-validation.md Illustrates the usage of 'required' and 'min=1' struct tags in JSON configuration, showing valid and invalid examples for slice-valued fields. ```json { "foo": [], } ``` ```json { "foo": ["bar"], } ``` -------------------------------- ### Contact-Auditor Successful Run Output Example Source: https://github.com/letsencrypt/boulder/blob/main/cmd/contact-auditor/README.md An example of the log output when the Contact-Auditor runs successfully with no policy violations encountered and the results are configured to be written to a file. ```text I004823 contact-auditor nfWK_gM Running contact-auditor I004823 contact-auditor qJ_zsQ4 Beginning database query I004823 contact-auditor je7V9QM Query completed successfully I004823 contact-auditor 7LzGvQI Audit finished successfully I004823 contact-auditor 5Pbk_QM Audit results were written to: audit-2006-01-02T15:04.tsv ``` -------------------------------- ### Monitors Configuration Schema and Example Source: https://github.com/letsencrypt/boulder/blob/main/cmd/boulder-observer/README.md Defines the schema for configuring monitors, specifying the probing interval, the type of prober to use, and specific settings for that prober. Includes an example. ```yaml monitors: - period: 5s kind: DNS settings: ... ``` -------------------------------- ### Structured Logging Examples (Go) Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/go-logr/logr/README.md Demonstrates the conversion of traditional format string logging to structured key-value logging in Go, following best practices for clarity and searchability. ```go klog.V(4).Infof("Client is returning errors: code %v, error %v", responseCode, err) becomes logger.Error(err, "client returned an error", "code", responseCode) ``` ```go klog.V(4).Infof("Got a Retry-After %ds response for attempt %d to %v", seconds, retries, url) becomes logger.V(4).Info("got a retry-after response when requesting url", "attempt", retries, "after seconds", seconds, "url", url) ``` ```go log.Printf("unable to reflect over type %T") becomes logger.Info("unable to reflect over type", "type", fmt.Sprintf("%T")) ``` -------------------------------- ### Running go-redis Tests Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/redis/go-redis/v9/README.md Shows the command to execute the tests for the go-redis project after setting up the environment. It also demonstrates how to run tests against a Redis instance running on a different port by setting the REDIS_PORT environment variable. ```shell go test REDIS_PORT=9999 go test ``` -------------------------------- ### Install der2text Tools Source: https://github.com/letsencrypt/boulder/blob/main/linter/lints/test/README.md Installs the der2text and text2der command-line tools necessary for manipulating CRL files. These tools are essential for creating and editing test CRLs. ```sh go install github.com/syncsynchalt/der2text/cmds/text2der@latest go install github.com/syncsynchalt/der2text/cmds/der2text@latest ``` -------------------------------- ### Boulder ORM Quickstart Source: https://github.com/letsencrypt/boulder/blob/main/vendor/github.com/letsencrypt/borp/README.md Demonstrates the basic usage of the Boulder ORM (a fork of Gorp) for database operations. It covers initializing the DbMap, inserting, updating, selecting, and deleting data from a 'posts' table. ```go package main import ( "database/sql" "github.com/letsencrypt/borp" _ "github.com/mattn/go-sqlite3" "log" "time" ) func main() { // initialize the DbMap dbmap := initDb() defer dbmap.Db.Close() // delete any existing rows err := dbmap.TruncateTables() checkErr(err, "TruncateTables failed") // create two posts p1 := newPost("Go 1.1 released!", "Lorem ipsum lorem ipsum") p2 := newPost("Go 1.2 released!", "Lorem ipsum lorem ipsum") // insert rows - auto increment PKs will be set properly after the insert err = dbmap.Insert(&p1, &p2) checkErr(err, "Insert failed") // use convenience SelectInt count, err := dbmap.SelectInt("select count(*) from posts") checkErr(err, "select count(*) failed") log.Println("Rows after inserting:", count) // update a row p2.Title = "Go 1.2 is better than ever" count, err = dbmap.Update(&p2) checkErr(err, "Update failed") log.Println("Rows updated:", count) // fetch one row - note use of "post_id" instead of "Id" since column is aliased // // Postgres users should use $1 instead of ? placeholders // See 'Known Issues' below err = dbmap.SelectOne(&p2, "select * from posts where post_id=?", p2.Id) checkErr(err, "SelectOne failed") log.Println("p2 row:", p2) // fetch all rows var posts []Post _, err = dbmap.Select(&posts, "select * from posts order by post_id") checkErr(err, "Select failed") log.Println("All rows:") for x, p := range posts { log.Printf(" %d: %v\n", x, p) } // delete row by PK count, err = dbmap.Delete(&p1) checkErr(err, "Delete failed") log.Println("Rows deleted:", count) // delete row manually via Exec _, err = dbmap.Exec("delete from posts where post_id=?", p2.Id) checkErr(err, "Exec failed") // confirm count is zero count, err = dbmap.SelectInt("select count(*) from posts") checkErr(err, "select count(*) failed") log.Println("Row count - should be zero:", count) log.Println("Done!") } type Post struct { // db tag lets you specify the column name if it differs from the struct field Id int64 `db:"post_id"` Created int64 Title string `db:",size:50"` // Column size set to 50 Body string `db:"article_body,size:1024"` // Set both column name and size } func newPost(title, body string) Post { return Post{ Created: time.Now().UnixNano(), Title: title, Body: body, } } func initDb() *borp.DbMap { // connect to db using standard Go database/sql API // use whatever database/sql driver you wish db, err := sql.Open("sqlite3", "/tmp/post_db.bin") checkErr(err, "sql.Open failed") // construct a borp DbMap dbmap := &borp.DbMap{Db: db, Dialect: borp.SqliteDialect{}} // add a table, setting the table name to 'posts' and // specifying that the Id property is an auto incrementing PK dbmap.AddTableWithName(Post{}, "posts").SetKeys(true, "Id") // create the table. in a production system you'd generally // use a migration tool, or create the tables via scripts err = dbmap.CreateTablesIfNotExists() checkErr(err, "Create tables failed") return dbmap } func checkErr(err error, msg string) { if err != nil { log.Fatalln(msg, err) } } ```