Skip to content

Instantly share code, notes, and snippets.

View embano1's full-sized avatar

Michael Gasch embano1

View GitHub Profile
@embano1
embano1 / README.md
Created April 15, 2021 15:51
Delete git tags locally/remote
# delete all tags on remote
git tag -l | xargs -I {} git push origin :refs/tags/{}

# delete all tags locally
git tag -l | xargs git tag -d
@embano1
embano1 / README.md
Created April 15, 2021 07:47
Examples: gh api

Delete all runs for a given workflow

# get and verify runs by last run time
# workflow ID can be replaced with file name
gh api -q '.workflow_runs[].created_at' /repos/:owner/:repo/actions/workflows/govmomi-tests.yaml/runs

# delete them
gh api -q '.workflow_runs[].id' /repos/:owner/:repo/actions/workflows/govmomi-tests.yaml/runs | xargs -I {} gh api -X DELETE /repos/:owner/:repo/actions/runs/{}

Example vSphere Alarm events sent from VMware Event Router and enriched with the vSphere Alarm Server

AlarmStatusChangedEvent Datastore Disk Usage

Configuration rule in UI: "IF Datastore Disk Usage IS ABOVE 5% TRIGGER THE ALARM AND Show as Warning"

Metadata

id:
@embano1
embano1 / Dockerfile
Created March 8, 2021 09:32
Dockerfile scratch for vcsim and govc
# golang:1.16.0-buster amd64
FROM golang@sha256:f254180c5defa2653955e963fb0626e3d4fbbb162f7cff6490e94607d1d867ff AS builder
WORKDIR /src
COPY go.mod .
COPY go.sum .
RUN go mod download
RUN groupadd -g 61000 vcsim
RUN useradd -g 61000 -l -m -s /bin/false -u 61000 vcsim
@embano1
embano1 / ce-xml.md
Created February 4, 2021 08:56
CloudEvents XML pretty print representation
# DrsPoweredOnEvent
{'attributes': {'specversion': '1.0', 'id': '8583', 'source': '10.161.153.226', 'type': 'com.vmware.vsphere.DrsVmPoweredOnEvent', 'datacontenttype': 'application/xml', 'time': '2021-02-04T08:53:57.182999Z', 'eventclass': 'event'}, 'data': b'<DrsVmPoweredOnEvent><key>8583</key><chainId>8577</chainId><createdTime>2021-02-04T08:53:57.182999Z</createdTime><userName>VSPHERE.LOCAL\\Administrator</userName><datacenter><name>vcqaDC</name><datacenter type="Datacenter">datacenter-2</datacenter></datacenter><computeResource><name>cls</name><computeResource type="ClusterComputeResource">domain-c7</computeResource></computeResource><host><name>10.161.139.167</name><host type="HostSystem">host-27</host></host><vm><name>test-01</name><vm type="VirtualMachine">vm-56</vm></vm><fullFormattedMessage>DRS powered On test-01 on 10.161.139.167 in vcqaDC</fullFormattedMessage><template>false</template></DrsVmPoweredOnEvent>'}
# EventEx
{'attributes': {'specversion': '1.0', 'id': '8574', 'sour
package main
import "sync"
type MetricEnum int
type Metric struct {
Value float64
}
@embano1
embano1 / main.go
Created April 2, 2020 18:56
Playing with stateFn and a stupid counter
// inspired by
// https://github.com/golang/go/blob/8d7be1e3c9a98191f8c900087025c5e78b73d962/src/text/template/parse/lex.go#L228
package main
import (
"fmt"
"log"
)
type stateFn func(s *state) stateFn
@embano1
embano1 / doc.md
Created March 31, 2020 19:33
for patrick
@embano1
embano1 / README.MD
Last active February 18, 2020 19:12
Benchmark fmt.Sprintf %v vs %s
go test -bench=. -benchmem                    
goos: darwin
goarch: amd64
pkg: fmt-perf
BenchmarkFmtV-16         6899274               174 ns/op              64 B/op          1 allocs/op
BenchmarkFmtS-16         9181304               129 ns/op              80 B/op          2 allocs/op
PASS
ok      fmt-perf        4.138s
@embano1
embano1 / client.go
Last active November 20, 2024 18:49
gRPC Graceful Shutdown on Client and Server
package main
import (
"context"
"grpc-tutorial/greeter"
"io"
"log"
"os"
"os/signal"
"sync"