Skip to content

Instantly share code, notes, and snippets.

View crhntr's full-sized avatar

Christopher Hunter crhntr

View GitHub Profile
package main
import (
"slices"
"strconv"
"testing"
)
func Test_partition(t *testing.T) {
t.Run("strings", func(t *testing.T) {
package main
import (
"encoding/json"
"io"
"log"
"os"
"path/filepath"
)
@crhntr
crhntr / parse_key_val_query.go
Last active September 14, 2023 20:51
My answer to a slack question: "Anyone know of a package for parsing semi-structured queries of the style title:something description:"something else" visibility:public?"
package main
import (
"fmt"
"strconv"
"strings"
"text/scanner"
)
func main() {
package main
import (
"context"
"os"
"os/signal"
"sync"
)
package main
import "golang.org/x/exp/slices"
func FilterFunc[T any](list []T, keep func(T) bool) []T {
filtered := make([]T, 0, len(list))
for _, e := range list {
if keep(e) {
filtered = append(filtered, e)
}
package main
import "golang.org/x/exp/maps"
type Set[T comparable] map[T]struct{}
func (s Set[T]) Add(v T) { s[v] = struct{}{} }
func (s Set[T]) Remove(v T) { delete(s, v) }
func (s Set[T]) Has(v T) bool { _, has := s[v]; return has }
func (s Set[T]) List() []T { return maps.Keys(s) }
package main
import (
"bufio"
"context"
"fmt"
"os"
"os/exec"
"os/signal"
"regexp"
<div>
<style>
#result {
width: 100%;
padding: 1rem;
font-size: 2rem;
border-top-left-radius: 1rem;
border-top-right-radius: 1rem;
background: HSLA(336, 20%, 9%, 1.00);
color: white;
@crhntr
crhntr / load_config.go
Created October 1, 2021 02:53
load config from env
package main
import "reflect"
func loadConfig(data interface{}) {
v := reflect.ValueOf(data)
if v.Kind() != reflect.Ptr || v.Type().Elem().Kind() != reflect.Struct {
panic("expected a pointer to a struct")
}
It would be so cool if we could have vsphere environemnts act more like other iaas environments.
- It would make VSphere tests more like the other IAAS test pipelines.
- It would allow us to use the same workspace scripts (maybe) to interact with the environments.
- It would allow us to have a smaller pool of environments (because we install ops manager in the test pipeline)
The following outline is an exploration tracing the usage of the environment resource through the test pipelines. The
test pipeline ert::2.11 is used throughout as a the template I am following the GCP clean test:
- job: acquire-lock-gcp-clean
description: acquire a lock from the releng-env-resource pool. This writes an empty file to the gate-locks directory