Commit 1de58904 authored by Brad Davidson's avatar Brad Davidson

Update flannel to v0.12.0-k3s1

parent e3f87891
......@@ -4,6 +4,7 @@ go 1.13
replace (
github.com/Microsoft/hcsshim => github.com/Microsoft/hcsshim v0.8.7-0.20190926181021-82c7525d98c8
github.com/benmoss/go-powershell => github.com/rancher/go-powershell v0.0.0-20200701184732-233247d45373
github.com/containerd/btrfs => github.com/containerd/btrfs v0.0.0-20181101203652-af5082808c83
github.com/containerd/cgroups => github.com/containerd/cgroups v0.0.0-20190717030353-c4b9ac5c7601
github.com/containerd/console => github.com/containerd/console v0.0.0-20181022165439-0650fd9eeb50
......@@ -13,7 +14,7 @@ replace (
github.com/containerd/fifo => github.com/containerd/fifo v0.0.0-20190816180239-bda0ff6ed73c
github.com/containerd/go-runc => github.com/containerd/go-runc v0.0.0-20190911050354-e029b79d8cda
github.com/containerd/typeurl => github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd
github.com/coreos/flannel => github.com/rancher/flannel v0.11.0-k3s.2
github.com/coreos/flannel => github.com/rancher/flannel v0.12.0-k3s1
github.com/coreos/go-systemd => github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
github.com/docker/distribution => github.com/docker/distribution v0.0.0-20190205005809-0d3efadf0154
github.com/docker/docker => github.com/docker/docker v17.12.0-ce-rc1.0.20190219214528-cbe11bdc6da8+incompatible
......@@ -64,9 +65,7 @@ replace (
require (
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/bhendo/go-powershell v0.0.0-20190719160123-219e7fb4e41e // indirect
github.com/bronze1man/goStrongswanVici v0.0.0-20190828090544-27d02f80ba40 // indirect
github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23 // indirect
github.com/containerd/cgroups v0.0.0-00010101000000-000000000000 // indirect
github.com/containerd/containerd v1.3.0-beta.2.0.20190828155532-0293cbd26c69
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 // indirect
......@@ -95,7 +94,6 @@ require (
github.com/opencontainers/runc v1.0.0-rc10
github.com/opencontainers/selinux v1.3.1-0.20190929122143-5215b1806f52
github.com/pkg/errors v0.9.1
github.com/rakelkar/gonetsh v0.0.0-20190719023240-501daadcadf8 // indirect
github.com/rancher/dynamiclistener v0.2.0
github.com/rancher/helm-controller v0.6.3
github.com/rancher/kine v0.4.0
......@@ -115,8 +113,8 @@ require (
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e
google.golang.org/grpc v1.26.0
gopkg.in/yaml.v2 v2.3.0
k8s.io/api v0.18.0
k8s.io/apimachinery v0.18.0
k8s.io/api v0.18.5
k8s.io/apimachinery v0.18.5
k8s.io/apiserver v0.0.0
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
k8s.io/cloud-provider v0.0.0
......
......@@ -7,7 +7,7 @@ commands.
## Installation
go get github.com/bhendo/go-powershell
go get github.com/rancher/go-powershell
## Usage
......@@ -21,8 +21,8 @@ package main
import (
"fmt"
ps "github.com/bhendo/go-powershell"
"github.com/bhendo/go-powershell/backend"
ps "github.com/rancher/go-powershell"
"github.com/rancher/go-powershell/backend"
)
func main() {
......@@ -59,9 +59,9 @@ package main
import (
"fmt"
ps "github.com/bhendo/go-powershell"
"github.com/bhendo/go-powershell/backend"
"github.com/bhendo/go-powershell/middleware"
ps "github.com/rancher/go-powershell"
"github.com/rancher/go-powershell/backend"
"github.com/rancher/go-powershell/middleware"
)
func main() {
......
......@@ -6,7 +6,7 @@ import (
"io"
"os/exec"
"github.com/juju/errors"
"github.com/pkg/errors"
)
type Local struct{}
......@@ -16,22 +16,22 @@ func (b *Local) StartProcess(cmd string, args ...string) (Waiter, io.Writer, io.
stdin, err := command.StdinPipe()
if err != nil {
return nil, nil, nil, nil, errors.Annotate(err, "Could not get hold of the PowerShell's stdin stream")
return nil, nil, nil, nil, errors.Wrap(err, "Could not get hold of the PowerShell's stdin stream")
}
stdout, err := command.StdoutPipe()
if err != nil {
return nil, nil, nil, nil, errors.Annotate(err, "Could not get hold of the PowerShell's stdout stream")
return nil, nil, nil, nil, errors.Wrap(err, "Could not get hold of the PowerShell's stdout stream")
}
stderr, err := command.StderrPipe()
if err != nil {
return nil, nil, nil, nil, errors.Annotate(err, "Could not get hold of the PowerShell's stderr stream")
return nil, nil, nil, nil, errors.Wrap(err, "Could not get hold of the PowerShell's stderr stream")
}
err = command.Start()
if err != nil {
return nil, nil, nil, nil, errors.Annotate(err, "Could not spawn PowerShell process")
return nil, nil, nil, nil, errors.Wrap(err, "Could not spawn PowerShell process")
}
return command, stdin, stdout, stderr, nil
......
......@@ -8,7 +8,7 @@ import (
"regexp"
"strings"
"github.com/juju/errors"
"github.com/pkg/errors"
)
// sshSession exists so we don't create a hard dependency on crypto/ssh.
......@@ -28,22 +28,22 @@ type SSH struct {
func (b *SSH) StartProcess(cmd string, args ...string) (Waiter, io.Writer, io.Reader, io.Reader, error) {
stdin, err := b.Session.StdinPipe()
if err != nil {
return nil, nil, nil, nil, errors.Annotate(err, "Could not get hold of the SSH session's stdin stream")
return nil, nil, nil, nil, errors.Wrap(err, "Could not get hold of the SSH session's stdin stream")
}
stdout, err := b.Session.StdoutPipe()
if err != nil {
return nil, nil, nil, nil, errors.Annotate(err, "Could not get hold of the SSH session's stdout stream")
return nil, nil, nil, nil, errors.Wrap(err, "Could not get hold of the SSH session's stdout stream")
}
stderr, err := b.Session.StderrPipe()
if err != nil {
return nil, nil, nil, nil, errors.Annotate(err, "Could not get hold of the SSH session's stderr stream")
return nil, nil, nil, nil, errors.Wrap(err, "Could not get hold of the SSH session's stderr stream")
}
err = b.Session.Start(b.createCmd(cmd, args))
if err != nil {
return nil, nil, nil, nil, errors.Annotate(err, "Could not spawn process via SSH")
return nil, nil, nil, nil, errors.Wrap(err, "Could not spawn process via SSH")
}
return b.Session, stdin, stdout, stderr, nil
......
module github.com/rancher/go-powershell
go 1.14
require github.com/pkg/errors v0.9.1
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
......@@ -5,12 +5,12 @@ package powershell
import (
"fmt"
"io"
"strings"
"regexp"
"sync"
"github.com/bhendo/go-powershell/backend"
"github.com/bhendo/go-powershell/utils"
"github.com/juju/errors"
"github.com/rancher/go-powershell/backend"
"github.com/rancher/go-powershell/utils"
"github.com/pkg/errors"
)
const newline = "\r\n"
......@@ -38,7 +38,7 @@ func New(backend backend.Starter) (Shell, error) {
func (s *shell) Execute(cmd string) (string, string, error) {
if s.handle == nil {
return "", "", errors.Annotate(errors.New(cmd), "Cannot execute commands on closed shells.")
return "", "", errors.Wrap(errors.New(cmd), "Cannot execute commands on closed shells.")
}
outBoundary := createBoundary()
......@@ -49,7 +49,7 @@ func (s *shell) Execute(cmd string) (string, string, error) {
_, err := s.stdin.Write([]byte(full))
if err != nil {
return "", "", errors.Annotate(errors.Annotate(err, cmd), "Could not send PowerShell command")
return "", "", errors.Wrap(errors.Wrap(err, cmd), "Could not send PowerShell command")
}
// read stdout and stderr
......@@ -65,7 +65,7 @@ func (s *shell) Execute(cmd string) (string, string, error) {
waiter.Wait()
if len(serr) > 0 {
return sout, serr, errors.Annotate(errors.New(cmd), serr)
return sout, serr, errors.Wrap(errors.New(cmd), serr)
}
return sout, serr, nil
......@@ -93,7 +93,7 @@ func streamReader(stream io.Reader, boundary string, buffer *string, signal *syn
// read all output until we have found our boundary token
output := ""
bufsize := 64
marker := boundary + newline
marker := regexp.MustCompile("(?s)(.*)" + regexp.QuoteMeta(boundary))
for {
buf := make([]byte, bufsize)
......@@ -104,12 +104,12 @@ func streamReader(stream io.Reader, boundary string, buffer *string, signal *syn
output = output + string(buf[:read])
if strings.HasSuffix(output, marker) {
if marker.MatchString(output) {
break
}
}
*buffer = strings.TrimSuffix(output, marker)
*buffer = marker.FindStringSubmatch(output)[1]
signal.Done()
return nil
......
*.test
*.out
*.mprof
vendor/github.com/buger/goterm/
prof.cpu
prof.mem
language: go
go:
- 1.7.x
- 1.8.x
- 1.9.x
- 1.10.x
- 1.11.x
script: go test -v ./.
FROM golang:1.6
RUN go get github.com/Jeffail/gabs
RUN go get github.com/bitly/go-simplejson
RUN go get github.com/pquerna/ffjson
RUN go get github.com/antonholmquist/jason
RUN go get github.com/mreiferson/go-ujson
RUN go get -tags=unsafe -u github.com/ugorji/go/codec
RUN go get github.com/mailru/easyjson
WORKDIR /go/src/github.com/buger/jsonparser
ADD . /go/src/github.com/buger/jsonparser
\ No newline at end of file
SOURCE = parser.go
CONTAINER = jsonparser
SOURCE_PATH = /go/src/github.com/buger/jsonparser
BENCHMARK = JsonParser
BENCHTIME = 5s
TEST = .
DRUN = docker run -v `pwd`:$(SOURCE_PATH) -i -t $(CONTAINER)
build:
docker build -t $(CONTAINER) .
race:
$(DRUN) --env GORACE="halt_on_error=1" go test ./. $(ARGS) -v -race -timeout 15s
bench:
$(DRUN) go test $(LDFLAGS) -test.benchmem -bench $(BENCHMARK) ./benchmark/ $(ARGS) -benchtime $(BENCHTIME) -v
bench_local:
$(DRUN) go test $(LDFLAGS) -test.benchmem -bench . $(ARGS) -benchtime $(BENCHTIME) -v
profile:
$(DRUN) go test $(LDFLAGS) -test.benchmem -bench $(BENCHMARK) ./benchmark/ $(ARGS) -memprofile mem.mprof -v
$(DRUN) go test $(LDFLAGS) -test.benchmem -bench $(BENCHMARK) ./benchmark/ $(ARGS) -cpuprofile cpu.out -v
$(DRUN) go test $(LDFLAGS) -test.benchmem -bench $(BENCHMARK) ./benchmark/ $(ARGS) -c
test:
$(DRUN) go test $(LDFLAGS) ./ -run $(TEST) -timeout 10s $(ARGS) -v
fmt:
$(DRUN) go fmt ./...
vet:
$(DRUN) go vet ./.
bash:
$(DRUN) /bin/bash
\ No newline at end of file
package jsonparser
import (
bio "bytes"
)
// minInt64 '-9223372036854775808' is the smallest representable number in int64
const minInt64 = `9223372036854775808`
// About 2x faster then strconv.ParseInt because it only supports base 10, which is enough for JSON
func parseInt(bytes []byte) (v int64, ok bool, overflow bool) {
if len(bytes) == 0 {
return 0, false, false
}
var neg bool = false
if bytes[0] == '-' {
neg = true
bytes = bytes[1:]
}
var b int64 = 0
for _, c := range bytes {
if c >= '0' && c <= '9' {
b = (10 * v) + int64(c-'0')
} else {
return 0, false, false
}
if overflow = (b < v); overflow {
break
}
v = b
}
if overflow {
if neg && bio.Equal(bytes, []byte(minInt64)) {
return b, true, false
}
return 0, false, true
}
if neg {
return -v, true, false
} else {
return v, true, false
}
}
// +build appengine appenginevm
package jsonparser
import (
"strconv"
)
// See fastbytes_unsafe.go for explanation on why *[]byte is used (signatures must be consistent with those in that file)
func equalStr(b *[]byte, s string) bool {
return string(*b) == s
}
func parseFloat(b *[]byte) (float64, error) {
return strconv.ParseFloat(string(*b), 64)
}
func bytesToString(b *[]byte) string {
return string(*b)
}
func StringToBytes(s string) []byte {
return []byte(s)
}
// +build !appengine,!appenginevm
package jsonparser
import (
"reflect"
"strconv"
"unsafe"
)
//
// The reason for using *[]byte rather than []byte in parameters is an optimization. As of Go 1.6,
// the compiler cannot perfectly inline the function when using a non-pointer slice. That is,
// the non-pointer []byte parameter version is slower than if its function body is manually
// inlined, whereas the pointer []byte version is equally fast to the manually inlined
// version. Instruction count in assembly taken from "go tool compile" confirms this difference.
//
// TODO: Remove hack after Go 1.7 release
//
func equalStr(b *[]byte, s string) bool {
return *(*string)(unsafe.Pointer(b)) == s
}
func parseFloat(b *[]byte) (float64, error) {
return strconv.ParseFloat(*(*string)(unsafe.Pointer(b)), 64)
}
// A hack until issue golang/go#2632 is fixed.
// See: https://github.com/golang/go/issues/2632
func bytesToString(b *[]byte) string {
return *(*string)(unsafe.Pointer(b))
}
func StringToBytes(s string) []byte {
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
bh := reflect.SliceHeader{
Data: sh.Data,
Len: sh.Len,
Cap: sh.Len,
}
return *(*[]byte)(unsafe.Pointer(&bh))
}
package jsonparser
import (
"bytes"
"unicode/utf8"
)
// JSON Unicode stuff: see https://tools.ietf.org/html/rfc7159#section-7
const supplementalPlanesOffset = 0x10000
const highSurrogateOffset = 0xD800
const lowSurrogateOffset = 0xDC00
const basicMultilingualPlaneReservedOffset = 0xDFFF
const basicMultilingualPlaneOffset = 0xFFFF
func combineUTF16Surrogates(high, low rune) rune {
return supplementalPlanesOffset + (high-highSurrogateOffset)<<10 + (low - lowSurrogateOffset)
}
const badHex = -1
func h2I(c byte) int {
switch {
case c >= '0' && c <= '9':
return int(c - '0')
case c >= 'A' && c <= 'F':
return int(c - 'A' + 10)
case c >= 'a' && c <= 'f':
return int(c - 'a' + 10)
}
return badHex
}
// decodeSingleUnicodeEscape decodes a single \uXXXX escape sequence. The prefix \u is assumed to be present and
// is not checked.
// In JSON, these escapes can either come alone or as part of "UTF16 surrogate pairs" that must be handled together.
// This function only handles one; decodeUnicodeEscape handles this more complex case.
func decodeSingleUnicodeEscape(in []byte) (rune, bool) {
// We need at least 6 characters total
if len(in) < 6 {
return utf8.RuneError, false
}
// Convert hex to decimal
h1, h2, h3, h4 := h2I(in[2]), h2I(in[3]), h2I(in[4]), h2I(in[5])
if h1 == badHex || h2 == badHex || h3 == badHex || h4 == badHex {
return utf8.RuneError, false
}
// Compose the hex digits
return rune(h1<<12 + h2<<8 + h3<<4 + h4), true
}
// isUTF16EncodedRune checks if a rune is in the range for non-BMP characters,
// which is used to describe UTF16 chars.
// Source: https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane
func isUTF16EncodedRune(r rune) bool {
return highSurrogateOffset <= r && r <= basicMultilingualPlaneReservedOffset
}
func decodeUnicodeEscape(in []byte) (rune, int) {
if r, ok := decodeSingleUnicodeEscape(in); !ok {
// Invalid Unicode escape
return utf8.RuneError, -1
} else if r <= basicMultilingualPlaneOffset && !isUTF16EncodedRune(r) {
// Valid Unicode escape in Basic Multilingual Plane
return r, 6
} else if r2, ok := decodeSingleUnicodeEscape(in[6:]); !ok { // Note: previous decodeSingleUnicodeEscape success guarantees at least 6 bytes remain
// UTF16 "high surrogate" without manditory valid following Unicode escape for the "low surrogate"
return utf8.RuneError, -1
} else if r2 < lowSurrogateOffset {
// Invalid UTF16 "low surrogate"
return utf8.RuneError, -1
} else {
// Valid UTF16 surrogate pair
return combineUTF16Surrogates(r, r2), 12
}
}
// backslashCharEscapeTable: when '\X' is found for some byte X, it is to be replaced with backslashCharEscapeTable[X]
var backslashCharEscapeTable = [...]byte{
'"': '"',
'\\': '\\',
'/': '/',
'b': '\b',
'f': '\f',
'n': '\n',
'r': '\r',
't': '\t',
}
// unescapeToUTF8 unescapes the single escape sequence starting at 'in' into 'out' and returns
// how many characters were consumed from 'in' and emitted into 'out'.
// If a valid escape sequence does not appear as a prefix of 'in', (-1, -1) to signal the error.
func unescapeToUTF8(in, out []byte) (inLen int, outLen int) {
if len(in) < 2 || in[0] != '\\' {
// Invalid escape due to insufficient characters for any escape or no initial backslash
return -1, -1
}
// https://tools.ietf.org/html/rfc7159#section-7
switch e := in[1]; e {
case '"', '\\', '/', 'b', 'f', 'n', 'r', 't':
// Valid basic 2-character escapes (use lookup table)
out[0] = backslashCharEscapeTable[e]
return 2, 1
case 'u':
// Unicode escape
if r, inLen := decodeUnicodeEscape(in); inLen == -1 {
// Invalid Unicode escape
return -1, -1
} else {
// Valid Unicode escape; re-encode as UTF8
outLen := utf8.EncodeRune(out, r)
return inLen, outLen
}
}
return -1, -1
}
// unescape unescapes the string contained in 'in' and returns it as a slice.
// If 'in' contains no escaped characters:
// Returns 'in'.
// Else, if 'out' is of sufficient capacity (guaranteed if cap(out) >= len(in)):
// 'out' is used to build the unescaped string and is returned with no extra allocation
// Else:
// A new slice is allocated and returned.
func Unescape(in, out []byte) ([]byte, error) {
firstBackslash := bytes.IndexByte(in, '\\')
if firstBackslash == -1 {
return in, nil
}
// Get a buffer of sufficient size (allocate if needed)
if cap(out) < len(in) {
out = make([]byte, len(in))
} else {
out = out[0:len(in)]
}
// Copy the first sequence of unescaped bytes to the output and obtain a buffer pointer (subslice)
copy(out, in[:firstBackslash])
in = in[firstBackslash:]
buf := out[firstBackslash:]
for len(in) > 0 {
// Unescape the next escaped character
inLen, bufLen := unescapeToUTF8(in, buf)
if inLen == -1 {
return nil, MalformedStringEscapeError
}
in = in[inLen:]
buf = buf[bufLen:]
// Copy everything up until the next backslash
nextBackslash := bytes.IndexByte(in, '\\')
if nextBackslash == -1 {
copy(buf, in)
buf = buf[len(in):]
break
} else {
copy(buf, in[:nextBackslash])
buf = buf[nextBackslash:]
in = in[nextBackslash:]
}
}
// Trim the out buffer to the amount that was actually emitted
return out[:len(out)-len(buf)], nil
}
......@@ -24,13 +24,13 @@ import (
"github.com/coreos/flannel/backend"
"github.com/coreos/flannel/pkg/ip"
"github.com/coreos/flannel/subnet"
log "k8s.io/klog"
"github.com/juju/errors"
"github.com/pkg/errors"
"github.com/rakelkar/gonetsh/netroute"
"github.com/rakelkar/gonetsh/netsh"
"golang.org/x/net/context"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/apimachinery/pkg/util/wait"
log "k8s.io/klog"
utilexec "k8s.io/utils/exec"
)
......@@ -64,7 +64,7 @@ func (be *HostgwBackend) RegisterNetwork(ctx context.Context, wg sync.WaitGroup,
}{}
if len(config.Backend) > 0 {
if err := json.Unmarshal(config.Backend, &cfg); err != nil {
return nil, errors.Annotate(err, "error decoding windows host-gw backend config")
return nil, errors.Wrap(err, "error decoding windows host-gw backend config")
}
}
if len(cfg.Name) == 0 {
......@@ -104,7 +104,7 @@ func (be *HostgwBackend) RegisterNetwork(ctx context.Context, wg sync.WaitGroup,
return nil, err
default:
return nil, errors.Annotate(err, "failed to acquire lease")
return nil, errors.Wrap(err, "failed to acquire lease")
}
// 3. Check if the network exists and has the expected settings
......@@ -133,7 +133,7 @@ func (be *HostgwBackend) RegisterNetwork(ctx context.Context, wg sync.WaitGroup,
if createNewNetwork {
if existingNetwork != nil {
if _, err := existingNetwork.Delete(); err != nil {
return nil, errors.Annotatef(err, "failed to delete existing HNSNetwork %s", networkName)
return nil, errors.Wrapf(err, "failed to delete existing HNSNetwork %s", networkName)
}
log.Infof("Deleted stale HNSNetwork %s", networkName)
}
......@@ -151,13 +151,13 @@ func (be *HostgwBackend) RegisterNetwork(ctx context.Context, wg sync.WaitGroup,
}
jsonRequest, err := json.Marshal(expectedNetwork)
if err != nil {
return nil, errors.Annotatef(err, "failed to marshal %+v", expectedNetwork)
return nil, errors.Wrapf(err, "failed to marshal %+v", expectedNetwork)
}
log.Infof("Attempting to create HNSNetwork %s", string(jsonRequest))
newNetwork, err := hcsshim.HNSNetworkRequest("POST", "", string(jsonRequest))
if err != nil {
return nil, errors.Annotatef(err, "failed to create HNSNetwork %s", networkName)
return nil, errors.Wrapf(err, "failed to create HNSNetwork %s", networkName)
}
// Wait for the network to populate Management IP
......@@ -167,7 +167,7 @@ func (be *HostgwBackend) RegisterNetwork(ctx context.Context, wg sync.WaitGroup,
return newNetwork != nil && len(newNetwork.ManagementIP) != 0, nil
})
if waitErr == wait.ErrWaitTimeout {
return nil, errors.Annotatef(waitErr, "timeout, failed to get management IP from HNSNetwork %s", networkName)
return nil, errors.Wrapf(waitErr, "timeout, failed to get management IP from HNSNetwork %s", networkName)
}
// Wait for the interface with the management IP
......@@ -177,7 +177,7 @@ func (be *HostgwBackend) RegisterNetwork(ctx context.Context, wg sync.WaitGroup,
return lastErr == nil, nil
})
if waitErr == wait.ErrWaitTimeout {
return nil, errors.Annotatef(lastErr, "timeout, failed to get net interface for HNSNetwork %s (%s)", networkName, newNetwork.ManagementIP)
return nil, errors.Wrapf(lastErr, "timeout, failed to get net interface for HNSNetwork %s (%s)", networkName, newNetwork.ManagementIP)
}
log.Infof("Created HNSNetwork %s", networkName)
......@@ -198,7 +198,7 @@ func (be *HostgwBackend) RegisterNetwork(ctx context.Context, wg sync.WaitGroup,
if createNewBridgeEndpoint {
if existingBridgeEndpoint != nil {
if _, err = existingBridgeEndpoint.Delete(); err != nil {
return nil, errors.Annotatef(err, "failed to delete existing bridge HNSEndpoint %s", bridgeEndpointName)
return nil, errors.Wrapf(err, "failed to delete existing bridge HNSEndpoint %s", bridgeEndpointName)
}
log.Infof("Deleted stale bridge HNSEndpoint %s", bridgeEndpointName)
}
......@@ -211,7 +211,7 @@ func (be *HostgwBackend) RegisterNetwork(ctx context.Context, wg sync.WaitGroup,
log.Infof("Attempting to create bridge HNSEndpoint %+v", expectedBridgeEndpoint)
if expectedBridgeEndpoint, err = expectedBridgeEndpoint.Create(); err != nil {
return nil, errors.Annotatef(err, "failed to create bridge HNSEndpoint %s", bridgeEndpointName)
return nil, errors.Wrapf(err, "failed to create bridge HNSEndpoint %s", bridgeEndpointName)
}
log.Infof("Created bridge HNSEndpoint %s", bridgeEndpointName)
......@@ -224,7 +224,7 @@ func (be *HostgwBackend) RegisterNetwork(ctx context.Context, wg sync.WaitGroup,
return lastErr == nil, nil
})
if waitErr == wait.ErrWaitTimeout {
return nil, errors.Annotatef(lastErr, "failed to hot attach bridge HNSEndpoint %s to host compartment", bridgeEndpointName)
return nil, errors.Wrapf(lastErr, "failed to hot attach bridge HNSEndpoint %s to host compartment", bridgeEndpointName)
}
log.Infof("Attached bridge endpoint %s to host successfully", bridgeEndpointName)
......@@ -232,7 +232,7 @@ func (be *HostgwBackend) RegisterNetwork(ctx context.Context, wg sync.WaitGroup,
for _, interfaceIpAddress := range []string{expectedNetwork.ManagementIP, expectedBridgeEndpoint.IPAddress.String()} {
netInterface, err := netshHelper.GetInterfaceByIP(interfaceIpAddress)
if err != nil {
return nil, errors.Annotatef(err, "failed to find interface for IP Address %s", interfaceIpAddress)
return nil, errors.Wrapf(err, "failed to find interface for IP Address %s", interfaceIpAddress)
}
log.Infof("Found %+v interface with IP %s", netInterface, interfaceIpAddress)
......@@ -244,7 +244,7 @@ func (be *HostgwBackend) RegisterNetwork(ctx context.Context, wg sync.WaitGroup,
interfaceIdx := strconv.Itoa(netInterface.Idx)
if err := netshHelper.EnableForwarding(interfaceIdx); err != nil {
return nil, errors.Annotatef(err, "failed to enable forwarding on %s index %s", netInterface.Name, interfaceIdx)
return nil, errors.Wrapf(err, "failed to enable forwarding on %s index %s", netInterface.Name, interfaceIdx)
}
log.Infof("Enabled forwarding on %s index %s", netInterface.Name, interfaceIdx)
}
......
......@@ -150,8 +150,8 @@ func (lw *leaseWatcher) remove(lease *Lease) Event {
}
func deleteLease(l []Lease, i int) []Lease {
l[i] = l[len(l)-1]
return l[:len(l)-1]
l = append(l[:i], l[i+1:]...)
return l
}
// WatchLease performs a long term watch of the given network's subnet lease
......
All changes are welcome as long as no code is involved. If you run into any bugs, please file an issue and explain how that was even possible.
# No Code
No code is the best way to write secure and reliable applications. Write nothing; deploy nowhere.
## Getting Started
Start by not writing any code.
```
```
This is just an example application, but imagine it doing anything you want. Adding new features is easy too:
```
```
The possibilities are endless.
### Building the Application
Now that you have not done anything it's time to build your application:
```
```
Yep. That's it. You should see the following output:
```
```
### Deploying
While you still have not done anything it's time to deploy your application. By running the following command you can deploy your application absolutely nowhere.
```
```
It's that simple. And when it comes time to scale the application, all you have to do is:
```
```
I know right?
## Contributing
You don't.
# No Code Style Guide
All no code programs are the same, regardless of use case, any code you write is a liability.
## File Extensions
No code is not stored in files, but if you must, use the `.no` file extension.
```
main.no
```
## Linters
There is only one way to write no code and the `du` command can help you identify any issues.
```
du -h main.no
```
```
0 main.no
```
> The only valid code is no code.
## Code Reviews
The no code community has adopted the following conventions when reviewing code changes:
When the change contains no code additions or modifications:
```
LGTM # Looks Good To Me
```
When the change includes code additions or modifications:
```
CIAL # Code Is A Liability
```
> Change requests that fall into this category should be rejected immediately.
module github.com/rancher/nocode
go 1.14
package netroute
import (
"regexp"
"bufio"
"bytes"
"net"
"regexp"
"strconv"
"strings"
"bufio"
"bytes"
ps "github.com/bhendo/go-powershell"
psbe "github.com/bhendo/go-powershell/backend"
ps "github.com/benmoss/go-powershell"
psbe "github.com/benmoss/go-powershell/backend"
"fmt"
"math/big"
......
MIT License
Copyright (c) 2016 Leonid Bugaev
Copyright (c) 2017, Gorillalabs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......@@ -9,13 +7,15 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
http://www.opensource.org/licenses/MIT
// Copyright (c) 2017 Gorillalabs. All rights reserved.
package backend
import (
"io"
"os/exec"
"github.com/pkg/errors"
)
type Local struct{}
func (b *Local) StartProcess(cmd string, args ...string) (Waiter, io.Writer, io.Reader, io.Reader, error) {
command := exec.Command(cmd, args...)
stdin, err := command.StdinPipe()
if err != nil {
return nil, nil, nil, nil, errors.Wrap(err, "Could not get hold of the PowerShell's stdin stream")
}
stdout, err := command.StdoutPipe()
if err != nil {
return nil, nil, nil, nil, errors.Wrap(err, "Could not get hold of the PowerShell's stdout stream")
}
stderr, err := command.StderrPipe()
if err != nil {
return nil, nil, nil, nil, errors.Wrap(err, "Could not get hold of the PowerShell's stderr stream")
}
err = command.Start()
if err != nil {
return nil, nil, nil, nil, errors.Wrap(err, "Could not spawn PowerShell process")
}
return command, stdin, stdout, stderr, nil
}
// Copyright (c) 2017 Gorillalabs. All rights reserved.
package backend
import (
"fmt"
"io"
"regexp"
"strings"
"github.com/pkg/errors"
)
// sshSession exists so we don't create a hard dependency on crypto/ssh.
type sshSession interface {
Waiter
StdinPipe() (io.WriteCloser, error)
StdoutPipe() (io.Reader, error)
StderrPipe() (io.Reader, error)
Start(string) error
}
type SSH struct {
Session sshSession
}
func (b *SSH) StartProcess(cmd string, args ...string) (Waiter, io.Writer, io.Reader, io.Reader, error) {
stdin, err := b.Session.StdinPipe()
if err != nil {
return nil, nil, nil, nil, errors.Wrap(err, "Could not get hold of the SSH session's stdin stream")
}
stdout, err := b.Session.StdoutPipe()
if err != nil {
return nil, nil, nil, nil, errors.Wrap(err, "Could not get hold of the SSH session's stdout stream")
}
stderr, err := b.Session.StderrPipe()
if err != nil {
return nil, nil, nil, nil, errors.Wrap(err, "Could not get hold of the SSH session's stderr stream")
}
err = b.Session.Start(b.createCmd(cmd, args))
if err != nil {
return nil, nil, nil, nil, errors.Wrap(err, "Could not spawn process via SSH")
}
return b.Session, stdin, stdout, stderr, nil
}
func (b *SSH) createCmd(cmd string, args []string) string {
parts := []string{cmd}
simple := regexp.MustCompile(`^[a-z0-9_/.~+-]+$`)
for _, arg := range args {
if !simple.MatchString(arg) {
arg = b.quote(arg)
}
parts = append(parts, arg)
}
return strings.Join(parts, " ")
}
func (b *SSH) quote(s string) string {
return fmt.Sprintf(`"%s"`, s)
}
// Copyright (c) 2017 Gorillalabs. All rights reserved.
package backend
import "io"
type Waiter interface {
Wait() error
}
type Starter interface {
StartProcess(cmd string, args ...string) (Waiter, io.Writer, io.Reader, io.Reader, error)
}
......@@ -123,18 +123,15 @@ github.com/aws/aws-sdk-go/service/elbv2
github.com/aws/aws-sdk-go/service/kms
github.com/aws/aws-sdk-go/service/sts
github.com/aws/aws-sdk-go/service/sts/stsiface
# github.com/benmoss/go-powershell v0.0.0-00010101000000-000000000000 => github.com/rancher/go-powershell v0.0.0-20200701184732-233247d45373
github.com/benmoss/go-powershell
github.com/benmoss/go-powershell/backend
# github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973
github.com/beorn7/perks/quantile
# github.com/bhendo/go-powershell v0.0.0-20190719160123-219e7fb4e41e
github.com/bhendo/go-powershell
github.com/bhendo/go-powershell/backend
github.com/bhendo/go-powershell/utils
# github.com/blang/semver v3.5.0+incompatible
github.com/blang/semver
# github.com/bronze1man/goStrongswanVici v0.0.0-20190828090544-27d02f80ba40
github.com/bronze1man/goStrongswanVici
# github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23
github.com/buger/jsonparser
# github.com/canonical/go-dqlite v1.5.1
github.com/canonical/go-dqlite
github.com/canonical/go-dqlite/client
......@@ -338,7 +335,7 @@ github.com/containernetworking/cni/pkg/types/current
github.com/containernetworking/cni/pkg/version
# github.com/containernetworking/plugins v0.8.2
github.com/containernetworking/plugins/pkg/ns
# github.com/coreos/flannel v0.11.0 => github.com/rancher/flannel v0.11.0-k3s.2
# github.com/coreos/flannel v0.11.0 => github.com/rancher/flannel v0.12.0-k3s1
github.com/coreos/flannel/backend
github.com/coreos/flannel/backend/extension
github.com/coreos/flannel/backend/hostgw
......@@ -607,8 +604,6 @@ github.com/jmespath/go-jmespath
github.com/jonboulle/clockwork
# github.com/json-iterator/go v1.1.8
github.com/json-iterator/go
# github.com/juju/errors v0.0.0-20180806074554-22422dad46e1 => github.com/rancher/nocode v0.0.0-20200630202308-cb097102c09f
github.com/juju/errors
# github.com/karrick/godirwalk v1.7.5
github.com/karrick/godirwalk
# github.com/konsorten/go-windows-terminal-sequences v1.0.2
......@@ -717,7 +712,7 @@ github.com/prometheus/procfs
github.com/prometheus/procfs/internal/util
github.com/prometheus/procfs/nfs
github.com/prometheus/procfs/xfs
# github.com/rakelkar/gonetsh v0.0.0-20190719023240-501daadcadf8
# github.com/rakelkar/gonetsh v0.0.0-20190930180311-e5c5ffe4bdf0
github.com/rakelkar/gonetsh/netroute
github.com/rakelkar/gonetsh/netsh
# github.com/rancher/dynamiclistener v0.2.0
......@@ -727,6 +722,9 @@ github.com/rancher/dynamiclistener/factory
github.com/rancher/dynamiclistener/storage/file
github.com/rancher/dynamiclistener/storage/kubernetes
github.com/rancher/dynamiclistener/storage/memory
# github.com/rancher/go-powershell v0.0.0-20200701182037-6845e6fcfa79
github.com/rancher/go-powershell/backend
github.com/rancher/go-powershell/utils
# github.com/rancher/helm-controller v0.6.3
github.com/rancher/helm-controller/pkg/apis/helm.cattle.io
github.com/rancher/helm-controller/pkg/apis/helm.cattle.io/v1
......@@ -1212,7 +1210,7 @@ gopkg.in/square/go-jose.v2/jwt
gopkg.in/warnings.v0
# gopkg.in/yaml.v2 v2.3.0
gopkg.in/yaml.v2
# k8s.io/api v0.18.0 => github.com/rancher/kubernetes/staging/src/k8s.io/api v1.18.6-k3s1
# k8s.io/api v0.18.5 => github.com/rancher/kubernetes/staging/src/k8s.io/api v1.18.6-k3s1
k8s.io/api/admission/v1
k8s.io/api/admission/v1beta1
k8s.io/api/admissionregistration/v1
......@@ -1296,7 +1294,7 @@ k8s.io/apiextensions-apiserver/pkg/generated/openapi
k8s.io/apiextensions-apiserver/pkg/registry/customresource
k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor
k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition
# k8s.io/apimachinery v0.18.0 => github.com/rancher/kubernetes/staging/src/k8s.io/apimachinery v1.18.6-k3s1
# k8s.io/apimachinery v0.18.5 => github.com/rancher/kubernetes/staging/src/k8s.io/apimachinery v1.18.6-k3s1
k8s.io/apimachinery/pkg/api/equality
k8s.io/apimachinery/pkg/api/errors
k8s.io/apimachinery/pkg/api/meta
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment