diff --git a/.lintignore b/.lintignore new file mode 100644 index 0000000000..70e5e54f89 --- /dev/null +++ b/.lintignore @@ -0,0 +1,4 @@ +# Generated files +./cri/runtime/api.pb.go +# Files from different repo +./tools/* diff --git a/Makefile b/Makefile index 2a318409b9..c9e8283afb 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ shell: tests: $(CODECGEN_TARGETS) prog/staticui/staticui.go prog/externalui/externalui.go ./tools/test -no-go-get -tags $(GO_BUILD_TAGS) -lint: +lint: prog/staticui/staticui.go prog/externalui/externalui.go ./tools/lint prog/staticui/staticui.go: @@ -278,7 +278,7 @@ realclean: clean $(DOCKERHUB_USER)/scope $(DOCKERHUB_USER)/cloud-agent \ $(DOCKERHUB_USER)/scope:$(IMAGE_TAG) $(DOCKERHUB_USER)/cloud-agent:$(IMAGE_TAG) \ weaveworks/weaveexec:$(WEAVENET_VERSION) \ - ubuntu:yakkety alpine:3.5 node:6.9.0 2>/dev/null || true + ubuntu:bionic alpine:3.11 node:6.9.0 2>/dev/null || true # Dependencies are intentionally build without enforcing any tags # since they are build on the host diff --git a/app/api_topology.go b/app/api_topology.go index 9a811bcfab..8e4385755d 100644 --- a/app/api_topology.go +++ b/app/api_topology.go @@ -166,7 +166,7 @@ type websocketState struct { } func (wc *websocketState) update(ctx context.Context) error { - span := ot.StartSpan("websocket.Render", ot.Tag{"topology", wc.topologyID}) + span := ot.StartSpan("websocket.Render", ot.Tag{Key: "topology", Value: wc.topologyID}) defer span.Finish() ctx = ot.ContextWithSpan(ctx, span) // We measure how much time has passed since the channel was opened diff --git a/app/multitenant/aws_collector.go b/app/multitenant/aws_collector.go index 39b2edcede..03c7203d7d 100644 --- a/app/multitenant/aws_collector.go +++ b/app/multitenant/aws_collector.go @@ -213,7 +213,7 @@ func NewAWSCollector(config AWSCollectorConfig) (AWSCollector, error) { } func (c *awsCollector) flushLoop() { - for _ = range c.ticker.C { + for range c.ticker.C { c.flushPending(context.Background()) } } diff --git a/app/multitenant/consul_client.go b/app/multitenant/consul_client.go index 42613ca069..a06db05dad 100644 --- a/app/multitenant/consul_client.go +++ b/app/multitenant/consul_client.go @@ -61,7 +61,7 @@ type consulClient struct { // Get and deserialise a JSON value from consul. func (c *consulClient) Get(ctx context.Context, key string, out interface{}) error { - span, ctx := opentracing.StartSpanFromContext(ctx, "Consul Get", opentracing.Tag{"key", key}) + span, ctx := opentracing.StartSpanFromContext(ctx, "Consul Get", opentracing.Tag{Key: "key", Value: key}) defer span.Finish() kvp, _, err := c.kv.Get(key, queryOptions) if err != nil { @@ -76,7 +76,7 @@ func (c *consulClient) Get(ctx context.Context, key string, out interface{}) err // CAS atomically modify a value in a callback. // If value doesn't exist you'll get nil as a argument to your callback. func (c *consulClient) CAS(ctx context.Context, key string, out interface{}, f CASCallback) error { - span, ctx := opentracing.StartSpanFromContext(ctx, "Consul CAS", opentracing.Tag{"key", key}) + span, ctx := opentracing.StartSpanFromContext(ctx, "Consul CAS", opentracing.Tag{Key: "key", Value: key}) defer span.Finish() var ( index = uint64(0) diff --git a/app/multitenant/consul_pipe_router.go b/app/multitenant/consul_pipe_router.go index 7546c1a8a3..53e828f365 100644 --- a/app/multitenant/consul_pipe_router.go +++ b/app/multitenant/consul_pipe_router.go @@ -9,6 +9,7 @@ import ( "time" "context" + "github.com/gorilla/mux" "github.com/gorilla/websocket" opentracing "github.com/opentracing/opentracing-go" @@ -289,7 +290,7 @@ func (pr *consulPipeRouter) Get(ctx context.Context, id string, e app.End) (xfer } key := fmt.Sprintf("%s%s-%s", pr.prefix, userID, id) log.Infof("Get %s:%s", key, e) - span, ctx := opentracing.StartSpanFromContext(ctx, "PipeRouter Get", opentracing.Tag{"key", key}) + span, ctx := opentracing.StartSpanFromContext(ctx, "PipeRouter Get", opentracing.Tag{Key: "key", Value: key}) defer span.Finish() // Try to ensure the given end of the given pipe @@ -333,7 +334,7 @@ func (pr *consulPipeRouter) Release(ctx context.Context, id string, e app.End) e } key := fmt.Sprintf("%s%s-%s", pr.prefix, userID, id) log.Infof("Release %s:%s", key, e) - span, ctx := opentracing.StartSpanFromContext(ctx, "PipeRouter Release", opentracing.Tag{"key", key}) + span, ctx := opentracing.StartSpanFromContext(ctx, "PipeRouter Release", opentracing.Tag{Key: "key", Value: key}) defer span.Finish() // atomically clear my end of the pipe in consul @@ -360,7 +361,7 @@ func (pr *consulPipeRouter) Delete(ctx context.Context, id string) error { } key := fmt.Sprintf("%s%s-%s", pr.prefix, userID, id) log.Infof("Delete %s", key) - span, ctx := opentracing.StartSpanFromContext(ctx, "PipeRouter Delete", opentracing.Tag{"key", key}) + span, ctx := opentracing.StartSpanFromContext(ctx, "PipeRouter Delete", opentracing.Tag{Key: "key", Value: key}) defer span.Finish() return pr.client.CAS(ctx, key, &consulPipe{}, func(in interface{}) (interface{}, bool, error) { diff --git a/bin/release b/bin/release index 9328c8ae21..b988506edd 100755 --- a/bin/release +++ b/bin/release @@ -39,7 +39,7 @@ setup() { else echo "Cannot determine version - multiple tags point at HEAD:" >&2 for TAG in $HEAD_TAGS; do - echo -e "\t$TAG" >&2 + echo -e "\\t$TAG" >&2 done exit 1 fi @@ -65,8 +65,8 @@ build() { echo "== Clone repo at $LATEST_TAG for version $VERSION" if [ -d "$RELEASE_DIR" ]; then - echo -e "\u2757 Release directory $RELEASE_DIR already exists, you may want to" >&2 - echo -e "\trm -rf $RELEASE_DIR" >&2 + echo -e "\\u2757 Release directory $RELEASE_DIR already exists, you may want to" >&2 + echo -e "\\trm -rf $RELEASE_DIR" >&2 exit 1 fi @@ -78,7 +78,7 @@ build() { ## Check that the top changelog entry is this version if ! latest_changelog=$(perl -nle'print $& if m{(?<=^## Release ).*}' ./CHANGELOG.md | head -1) \ || ! [ "$latest_changelog" = "$VERSION" ]; then - echo -e "\u2757 Latest changelog entry \"$latest_changelog\" does not match the release version $VERSION" >&2 + echo -e "\\u2757 Latest changelog entry \"$latest_changelog\" does not match the release version $VERSION" >&2 exit 1 fi @@ -93,7 +93,7 @@ build() { if make tests SUDO="$SUDO"; then echo -e '\u2713 Tests pass' else - echo -e "\u2757 Tests failed, probably best not publish this one" >&2 + echo -e "\\u2757 Tests failed, probably best not publish this one" >&2 exit 1 fi @@ -119,20 +119,20 @@ draft() { ## Check that the tag exists by looking at github if ! curl -sSf "https://api.github.com/repos/$GITHUB_USER/scope/git/tags/$LATEST_TAG_SHA" >/dev/null 2>&1; then - echo -e "\u2757 Tag $LATEST_TAG is not on GitHub, or is not the same as the local tag" >&2 - echo -e "\thttps://github.com/$GITHUB_USER/scope/tags" >&2 + echo -e "\\u2757 Tag $LATEST_TAG is not on GitHub, or is not the same as the local tag" >&2 + echo -e "\\thttps://github.com/$GITHUB_USER/scope/tags" >&2 echo "You may need to" >&2 - echo -e "\tgit push git@github.com:$GITHUB_USER/scope $LATEST_TAG" + echo -e "\\tgit push git@github.com:$GITHUB_USER/scope $LATEST_TAG" exit 1 fi - echo -e "\u2713 Tag $LATEST_TAG exists in GitHub repo $GITHUB_USER/scope" + echo -e "\\u2713 Tag $LATEST_TAG exists in GitHub repo $GITHUB_USER/scope" ## Check that the version does not already exist by looking at github ## releases if github-release info --user "$GITHUB_USER" --repo scope --tag "$LATEST_TAG" >/dev/null 2>&1; then - echo -e "\u2757 Release $LATEST_TAG already exists on GitHub" >&2 - echo -e "\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG" >&2 + echo -e "\\u2757 Release $LATEST_TAG already exists on GitHub" >&2 + echo -e "\\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG" >&2 exit 1 fi @@ -144,7 +144,7 @@ draft() { fi echo "== Creating GitHub release $RELEASE_ARGS $RELEASE_NAME $VERSION" - github-release release $RELEASE_ARGS \ + github-release release "$RELEASE_ARGS" \ --user "$GITHUB_USER" \ --repo scope \ --tag "$LATEST_TAG" \ @@ -159,7 +159,7 @@ draft() { --file "./scope" echo "** Draft $TYPE $RELEASE_NAME $VERSION created at" - echo -e "\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG" + echo -e "\\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG" } publish() { @@ -177,22 +177,22 @@ publish() { --tag "$LATEST_TAG" echo "** Pre-release $RELEASE_NAME $VERSION published at" - echo -e "\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG" + echo -e "\\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG" else echo "== Sanity checks" if ! [ "$LATEST_TAG_COMMIT_SHA" == "$LATEST_RELEASE_COMMIT_SHA" ]; then - echo -e "\u2757 The tag latest_release does not point to the same commit as $LATEST_TAG" >&2 + echo -e "\\u2757 The tag latest_release does not point to the same commit as $LATEST_TAG" >&2 echo "You may need to" >&2 - echo -e "\tgit tag -af latest_release $LATEST_TAG" >&2 + echo -e "\\tgit tag -af latest_release $LATEST_TAG" >&2 exit 1 fi ## Check that the 'latest_release' tag exists by looking at github if ! curl -sSf "https://api.github.com/repos/$GITHUB_USER/scope/git/tags/$LATEST_RELEASE_SHA" >/dev/null 2>&1; then - echo -e "\u2757 Tag latest_release is not on GitHub, or is not the same as the local tag" >&2 - echo -e "\thttps://github.com/$GITHUB_USER/scope/tags" >&2 + echo -e "\\u2757 Tag latest_release is not on GitHub, or is not the same as the local tag" >&2 + echo -e "\\thttps://github.com/$GITHUB_USER/scope/tags" >&2 echo "You may need to" >&2 - echo -e "\tgit push -f git@github.com:$GITHUB_USER/scope latest_release" >&2 + echo -e "\\tgit push -f git@github.com:$GITHUB_USER/scope latest_release" >&2 exit 1 fi echo '** Sanity checks OK for publishing tag' "$LATEST_TAG" as "$DOCKERHUB_USER/scope:$VERSION" @@ -229,8 +229,8 @@ publish() { --file "./scope" echo "** Release $RELEASE_NAME $VERSION published at" - echo -e "\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG" - echo -e "\thttps://github.com/$GITHUB_USER/scope/releases/latest_release" + echo -e "\\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG" + echo -e "\\thttps://github.com/$GITHUB_USER/scope/releases/latest_release" fi } @@ -254,19 +254,19 @@ push_images() { usage() { echo "Usage:" - echo -e "\t./bin/release build" + echo -e "\\t./bin/release build" echo "-- Build artefacts for the latest version tag" - echo -e "\t./bin/release draft" + echo -e "\\t./bin/release draft" echo "-- Create draft release with artefacts in GitHub" - echo -e "\t./bin/release publish" + echo -e "\\t./bin/release publish" echo "-- Publish the GitHub release and update DockerHub" exit 1 } # Ensure required tooling is installed -if ! which github-release >/dev/null; then +if ! command -v github-release >/dev/null; then echo "Please install git-release:" >&2 - echo -e "\tgo get github.com/weaveworks/github-release" >&2 + echo -e "\\tgo get github.com/weaveworks/github-release" >&2 echo "and create a git token per https://github.com/weaveworks/github-release" >&2 exit 1 fi diff --git a/cri/runtime/api.pb.go b/cri/runtime/api.pb.go index 38def0b5c2..ad3023b4b6 100644 --- a/cri/runtime/api.pb.go +++ b/cri/runtime/api.pb.go @@ -5171,7 +5171,7 @@ func (m *LinuxPodSandboxConfig) MarshalTo(dAtA []byte) (int, error) { i += n7 } if len(m.Sysctls) > 0 { - for k, _ := range m.Sysctls { + for k := range m.Sysctls { dAtA[i] = 0x1a i++ v := m.Sysctls[k] @@ -5291,7 +5291,7 @@ func (m *PodSandboxConfig) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Labels) > 0 { - for k, _ := range m.Labels { + for k := range m.Labels { dAtA[i] = 0x32 i++ v := m.Labels[k] @@ -5308,7 +5308,7 @@ func (m *PodSandboxConfig) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Annotations) > 0 { - for k, _ := range m.Annotations { + for k := range m.Annotations { dAtA[i] = 0x3a i++ v := m.Annotations[k] @@ -5649,7 +5649,7 @@ func (m *PodSandboxStatus) MarshalTo(dAtA []byte) (int, error) { i += n16 } if len(m.Labels) > 0 { - for k, _ := range m.Labels { + for k := range m.Labels { dAtA[i] = 0x3a i++ v := m.Labels[k] @@ -5666,7 +5666,7 @@ func (m *PodSandboxStatus) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Annotations) > 0 { - for k, _ := range m.Annotations { + for k := range m.Annotations { dAtA[i] = 0x42 i++ v := m.Annotations[k] @@ -5711,7 +5711,7 @@ func (m *PodSandboxStatusResponse) MarshalTo(dAtA []byte) (int, error) { i += n17 } if len(m.Info) > 0 { - for k, _ := range m.Info { + for k := range m.Info { dAtA[i] = 0x12 i++ v := m.Info[k] @@ -5785,7 +5785,7 @@ func (m *PodSandboxFilter) MarshalTo(dAtA []byte) (int, error) { i += n18 } if len(m.LabelSelector) > 0 { - for k, _ := range m.LabelSelector { + for k := range m.LabelSelector { dAtA[i] = 0x1a i++ v := m.LabelSelector[k] @@ -5874,7 +5874,7 @@ func (m *PodSandbox) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintApi(dAtA, i, uint64(m.CreatedAt)) } if len(m.Labels) > 0 { - for k, _ := range m.Labels { + for k := range m.Labels { dAtA[i] = 0x2a i++ v := m.Labels[k] @@ -5891,7 +5891,7 @@ func (m *PodSandbox) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Annotations) > 0 { - for k, _ := range m.Annotations { + for k := range m.Annotations { dAtA[i] = 0x32 i++ v := m.Annotations[k] @@ -6550,7 +6550,7 @@ func (m *ContainerConfig) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Labels) > 0 { - for k, _ := range m.Labels { + for k := range m.Labels { dAtA[i] = 0x4a i++ v := m.Labels[k] @@ -6567,7 +6567,7 @@ func (m *ContainerConfig) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Annotations) > 0 { - for k, _ := range m.Annotations { + for k := range m.Annotations { dAtA[i] = 0x52 i++ v := m.Annotations[k] @@ -6904,7 +6904,7 @@ func (m *ContainerFilter) MarshalTo(dAtA []byte) (int, error) { i += copy(dAtA[i:], m.PodSandboxId) } if len(m.LabelSelector) > 0 { - for k, _ := range m.LabelSelector { + for k := range m.LabelSelector { dAtA[i] = 0x22 i++ v := m.LabelSelector[k] @@ -7015,7 +7015,7 @@ func (m *Container) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintApi(dAtA, i, uint64(m.CreatedAt)) } if len(m.Labels) > 0 { - for k, _ := range m.Labels { + for k := range m.Labels { dAtA[i] = 0x42 i++ v := m.Labels[k] @@ -7032,7 +7032,7 @@ func (m *Container) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Annotations) > 0 { - for k, _ := range m.Annotations { + for k := range m.Annotations { dAtA[i] = 0x4a i++ v := m.Annotations[k] @@ -7200,7 +7200,7 @@ func (m *ContainerStatus) MarshalTo(dAtA []byte) (int, error) { i += copy(dAtA[i:], m.Message) } if len(m.Labels) > 0 { - for k, _ := range m.Labels { + for k := range m.Labels { dAtA[i] = 0x62 i++ v := m.Labels[k] @@ -7217,7 +7217,7 @@ func (m *ContainerStatus) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Annotations) > 0 { - for k, _ := range m.Annotations { + for k := range m.Annotations { dAtA[i] = 0x6a i++ v := m.Annotations[k] @@ -7280,7 +7280,7 @@ func (m *ContainerStatusResponse) MarshalTo(dAtA []byte) (int, error) { i += n43 } if len(m.Info) > 0 { - for k, _ := range m.Info { + for k := range m.Info { dAtA[i] = 0x12 i++ v := m.Info[k] @@ -7912,7 +7912,7 @@ func (m *ImageStatusResponse) MarshalTo(dAtA []byte) (int, error) { i += n51 } if len(m.Info) > 0 { - for k, _ := range m.Info { + for k := range m.Info { dAtA[i] = 0x12 i++ v := m.Info[k] @@ -8331,7 +8331,7 @@ func (m *StatusResponse) MarshalTo(dAtA []byte) (int, error) { i += n58 } if len(m.Info) > 0 { - for k, _ := range m.Info { + for k := range m.Info { dAtA[i] = 0x12 i++ v := m.Info[k] @@ -8606,7 +8606,7 @@ func (m *ContainerStatsFilter) MarshalTo(dAtA []byte) (int, error) { i += copy(dAtA[i:], m.PodSandboxId) } if len(m.LabelSelector) > 0 { - for k, _ := range m.LabelSelector { + for k := range m.LabelSelector { dAtA[i] = 0x1a i++ v := m.LabelSelector[k] @@ -8687,7 +8687,7 @@ func (m *ContainerAttributes) MarshalTo(dAtA []byte) (int, error) { i += n64 } if len(m.Labels) > 0 { - for k, _ := range m.Labels { + for k := range m.Labels { dAtA[i] = 0x1a i++ v := m.Labels[k] @@ -8704,7 +8704,7 @@ func (m *ContainerAttributes) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Annotations) > 0 { - for k, _ := range m.Annotations { + for k := range m.Annotations { dAtA[i] = 0x22 i++ v := m.Annotations[k] @@ -10741,7 +10741,7 @@ func (this *LinuxPodSandboxConfig) String() string { return "nil" } keysForSysctls := make([]string, 0, len(this.Sysctls)) - for k, _ := range this.Sysctls { + for k := range this.Sysctls { keysForSysctls = append(keysForSysctls, k) } sortkeys.Strings(keysForSysctls) @@ -10776,7 +10776,7 @@ func (this *PodSandboxConfig) String() string { return "nil" } keysForLabels := make([]string, 0, len(this.Labels)) - for k, _ := range this.Labels { + for k := range this.Labels { keysForLabels = append(keysForLabels, k) } sortkeys.Strings(keysForLabels) @@ -10786,7 +10786,7 @@ func (this *PodSandboxConfig) String() string { } mapStringForLabels += "}" keysForAnnotations := make([]string, 0, len(this.Annotations)) - for k, _ := range this.Annotations { + for k := range this.Annotations { keysForAnnotations = append(keysForAnnotations, k) } sortkeys.Strings(keysForAnnotations) @@ -10912,7 +10912,7 @@ func (this *PodSandboxStatus) String() string { return "nil" } keysForLabels := make([]string, 0, len(this.Labels)) - for k, _ := range this.Labels { + for k := range this.Labels { keysForLabels = append(keysForLabels, k) } sortkeys.Strings(keysForLabels) @@ -10922,7 +10922,7 @@ func (this *PodSandboxStatus) String() string { } mapStringForLabels += "}" keysForAnnotations := make([]string, 0, len(this.Annotations)) - for k, _ := range this.Annotations { + for k := range this.Annotations { keysForAnnotations = append(keysForAnnotations, k) } sortkeys.Strings(keysForAnnotations) @@ -10949,7 +10949,7 @@ func (this *PodSandboxStatusResponse) String() string { return "nil" } keysForInfo := make([]string, 0, len(this.Info)) - for k, _ := range this.Info { + for k := range this.Info { keysForInfo = append(keysForInfo, k) } sortkeys.Strings(keysForInfo) @@ -10980,7 +10980,7 @@ func (this *PodSandboxFilter) String() string { return "nil" } keysForLabelSelector := make([]string, 0, len(this.LabelSelector)) - for k, _ := range this.LabelSelector { + for k := range this.LabelSelector { keysForLabelSelector = append(keysForLabelSelector, k) } sortkeys.Strings(keysForLabelSelector) @@ -11012,7 +11012,7 @@ func (this *PodSandbox) String() string { return "nil" } keysForLabels := make([]string, 0, len(this.Labels)) - for k, _ := range this.Labels { + for k := range this.Labels { keysForLabels = append(keysForLabels, k) } sortkeys.Strings(keysForLabels) @@ -11022,7 +11022,7 @@ func (this *PodSandbox) String() string { } mapStringForLabels += "}" keysForAnnotations := make([]string, 0, len(this.Annotations)) - for k, _ := range this.Annotations { + for k := range this.Annotations { keysForAnnotations = append(keysForAnnotations, k) } sortkeys.Strings(keysForAnnotations) @@ -11196,7 +11196,7 @@ func (this *ContainerConfig) String() string { return "nil" } keysForLabels := make([]string, 0, len(this.Labels)) - for k, _ := range this.Labels { + for k := range this.Labels { keysForLabels = append(keysForLabels, k) } sortkeys.Strings(keysForLabels) @@ -11206,7 +11206,7 @@ func (this *ContainerConfig) String() string { } mapStringForLabels += "}" keysForAnnotations := make([]string, 0, len(this.Annotations)) - for k, _ := range this.Annotations { + for k := range this.Annotations { keysForAnnotations = append(keysForAnnotations, k) } sortkeys.Strings(keysForAnnotations) @@ -11331,7 +11331,7 @@ func (this *ContainerFilter) String() string { return "nil" } keysForLabelSelector := make([]string, 0, len(this.LabelSelector)) - for k, _ := range this.LabelSelector { + for k := range this.LabelSelector { keysForLabelSelector = append(keysForLabelSelector, k) } sortkeys.Strings(keysForLabelSelector) @@ -11364,7 +11364,7 @@ func (this *Container) String() string { return "nil" } keysForLabels := make([]string, 0, len(this.Labels)) - for k, _ := range this.Labels { + for k := range this.Labels { keysForLabels = append(keysForLabels, k) } sortkeys.Strings(keysForLabels) @@ -11374,7 +11374,7 @@ func (this *Container) String() string { } mapStringForLabels += "}" keysForAnnotations := make([]string, 0, len(this.Annotations)) - for k, _ := range this.Annotations { + for k := range this.Annotations { keysForAnnotations = append(keysForAnnotations, k) } sortkeys.Strings(keysForAnnotations) @@ -11423,7 +11423,7 @@ func (this *ContainerStatus) String() string { return "nil" } keysForLabels := make([]string, 0, len(this.Labels)) - for k, _ := range this.Labels { + for k := range this.Labels { keysForLabels = append(keysForLabels, k) } sortkeys.Strings(keysForLabels) @@ -11433,7 +11433,7 @@ func (this *ContainerStatus) String() string { } mapStringForLabels += "}" keysForAnnotations := make([]string, 0, len(this.Annotations)) - for k, _ := range this.Annotations { + for k := range this.Annotations { keysForAnnotations = append(keysForAnnotations, k) } sortkeys.Strings(keysForAnnotations) @@ -11467,7 +11467,7 @@ func (this *ContainerStatusResponse) String() string { return "nil" } keysForInfo := make([]string, 0, len(this.Info)) - for k, _ := range this.Info { + for k := range this.Info { keysForInfo = append(keysForInfo, k) } sortkeys.Strings(keysForInfo) @@ -11658,7 +11658,7 @@ func (this *ImageStatusResponse) String() string { return "nil" } keysForInfo := make([]string, 0, len(this.Info)) - for k, _ := range this.Info { + for k := range this.Info { keysForInfo = append(keysForInfo, k) } sortkeys.Strings(keysForInfo) @@ -11807,7 +11807,7 @@ func (this *StatusResponse) String() string { return "nil" } keysForInfo := make([]string, 0, len(this.Info)) - for k, _ := range this.Info { + for k := range this.Info { keysForInfo = append(keysForInfo, k) } sortkeys.Strings(keysForInfo) @@ -11910,7 +11910,7 @@ func (this *ContainerStatsFilter) String() string { return "nil" } keysForLabelSelector := make([]string, 0, len(this.LabelSelector)) - for k, _ := range this.LabelSelector { + for k := range this.LabelSelector { keysForLabelSelector = append(keysForLabelSelector, k) } sortkeys.Strings(keysForLabelSelector) @@ -11942,7 +11942,7 @@ func (this *ContainerAttributes) String() string { return "nil" } keysForLabels := make([]string, 0, len(this.Labels)) - for k, _ := range this.Labels { + for k := range this.Labels { keysForLabels = append(keysForLabels, k) } sortkeys.Strings(keysForLabels) @@ -11952,7 +11952,7 @@ func (this *ContainerAttributes) String() string { } mapStringForLabels += "}" keysForAnnotations := make([]string, 0, len(this.Annotations)) - for k, _ := range this.Annotations { + for k := range this.Annotations { keysForAnnotations = append(keysForAnnotations, k) } sortkeys.Strings(keysForAnnotations) diff --git a/extras/build_on_circle.sh b/extras/build_on_circle.sh index 046dd88a81..d0772a20a8 100755 --- a/extras/build_on_circle.sh +++ b/extras/build_on_circle.sh @@ -2,4 +2,4 @@ set -e -./in_parallel.sh "make RM=" "$(find . -maxdepth 2 -name "*.go" -printf "%h\n" | sort -u | sed -n 's/\.\/\(.*\)/\1\/\1/p')" +./in_parallel.sh "make RM=" "$(find . -maxdepth 2 -name "*.go" -printf "%h\\n" | sort -u | sed -n 's/\.\/\(.*\)/\1\/\1/p')" diff --git a/extras/dialer/dialer b/extras/dialer/dialer index 67dacf46ad..86abc7e5f7 100755 --- a/extras/dialer/dialer +++ b/extras/dialer/dialer @@ -23,7 +23,7 @@ while true; do rand=$(((RANDOM % max_dialer) + 1)) container=${dialer[$rand]} docker rm -f "$container" >/dev/null & - unset dialer[$rand] + unset "dialer[$rand]" dialer=("${dialer[@]}") fi diff --git a/extras/example/vendor/github.com/richo/GOSHOUT/README.MD b/extras/example/vendor/github.com/richo/GOSHOUT/README.MD deleted file mode 100644 index 6563c7b6f1..0000000000 --- a/extras/example/vendor/github.com/richo/GOSHOUT/README.MD +++ /dev/null @@ -1 +0,0 @@ -GOLANG LIBRARY TO PROD [SHOUTCLOUD](SHOUTCLOUD.IO) diff --git a/extras/example/vendor/github.com/richo/GOSHOUT/SHOUT.go b/extras/example/vendor/github.com/richo/GOSHOUT/SHOUT.go deleted file mode 100644 index 779e707bd5..0000000000 --- a/extras/example/vendor/github.com/richo/GOSHOUT/SHOUT.go +++ /dev/null @@ -1,46 +0,0 @@ -package SHOUTCLOUD - -import ( - "bytes" - "encoding/json" - "errors" - "io/ioutil" - "net/http" -) - -type SHOUTREQUEST struct { - INPUT string -} - -type SHOUTRESPONSE struct { - INPUT string - OUTPUT string -} - -func UPCASE(THING_TO_YELL string) (string, error) { - REQUEST := &SHOUTREQUEST{THING_TO_YELL} - ENCODED, ERR := json.Marshal(REQUEST) - if ERR != nil { - return "", errors.New("COULDN'T MARSHALL THE REQUEST") - } - READER := bytes.NewReader(ENCODED) - - // NO TLS, SO MUCH SADNESS. - RESP, ERR := http.Post("http://API.SHOUTCLOUD.IO/V1/SHOUT", - "application/json", READER) - if ERR != nil { - return "", errors.New("REQUEST FAILED CAN'T UPCASE ERROR MESSAGE HALP") - } - - BODYBYTES, ERR := ioutil.ReadAll(RESP.Body) - if ERR != nil { - return "", errors.New("COULDN'T READ BODY HALP") - } - - var BODY SHOUTRESPONSE - if json.Unmarshal(BODYBYTES, &BODY) != nil { - return "", errors.New("COULDN'T UNPACK RESPONSE") - } - - return BODY.OUTPUT, nil -} diff --git a/extras/example/vendor/manifest b/extras/example/vendor/manifest deleted file mode 100644 index 144ec4d025..0000000000 --- a/extras/example/vendor/manifest +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": 0, - "dependencies": [ - { - "importpath": "github.com/richo/GOSHOUT", - "repository": "https://github.com/richo/GOSHOUT", - "revision": "da80b9993cbabeba5d04ee1c31688313dd730ad8", - "branch": "master" - } - ] -} \ No newline at end of file diff --git a/extras/generate_latest_map b/extras/generate_latest_map index d41d07e23e..d08e474b3e 100755 --- a/extras/generate_latest_map +++ b/extras/generate_latest_map @@ -211,7 +211,7 @@ function generate_latest_map() { func (m ${latest_map_type}) String() string { buf := bytes.NewBufferString("{") for _, val := range m { - fmt.Fprintf(buf, "%s: %s,\n", val.key, val.String()) + fmt.Fprintf(buf, "%s: %s,\\n", val.key, val.String()) } fmt.Fprintf(buf, "}") return buf.String() diff --git a/go.mod b/go.mod index dc46970f87..970d7ba12e 100644 --- a/go.mod +++ b/go.mod @@ -58,7 +58,7 @@ require ( github.com/peterbourgon/runsvinit v2.0.0+incompatible github.com/pkg/errors v0.8.1 github.com/prometheus/client_golang v1.5.0 - github.com/richo/GOSHOUT v0.0.0-20190205170632-a1a6db7f26e9 + github.com/richo/GOSHOUT v0.0.0-20160308183402-8e98c504bfae github.com/russross/blackfriday v0.0.0-20151020174500-a18a46c9b943 // indirect github.com/shurcooL/sanitized_anchor_name v0.0.0-20150822220530-244f5ac324cb // indirect github.com/sirupsen/logrus v1.4.2 diff --git a/go.sum b/go.sum index 907b01426f..08c07d679d 100644 --- a/go.sum +++ b/go.sum @@ -266,6 +266,8 @@ github.com/prometheus/procfs v0.0.3 h1:CTwfnzjQ+8dS6MhHHu4YswVAD99sL2wjPqP+VkURm github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/richo/GOSHOUT v0.0.0-20160308183402-8e98c504bfae h1:/NoALPFmRKJ/attvODMptyCS0DUsPeiXYC5LfqV0ecM= +github.com/richo/GOSHOUT v0.0.0-20160308183402-8e98c504bfae/go.mod h1:MSTsYcO3SGF1j/eewqZORAzbp3BUbisi2094EDP3+To= github.com/richo/GOSHOUT v0.0.0-20190205170632-a1a6db7f26e9 h1:2bCoptIvAKQ1O70dbwQHob8Pop8zIXJHlnVLRtf9pG8= github.com/richo/GOSHOUT v0.0.0-20190205170632-a1a6db7f26e9/go.mod h1:MSTsYcO3SGF1j/eewqZORAzbp3BUbisi2094EDP3+To= github.com/russross/blackfriday v0.0.0-20151020174500-a18a46c9b943 h1:Bn2ofKCNwK+UtM3PAsMzGGaxgViklwyVrl1cyzsHHGc= diff --git a/integration/410_container_control_test.sh b/integration/410_container_control_test.sh index abe74c541c..af6696e5dd 100755 --- a/integration/410_container_control_test.sh +++ b/integration/410_container_control_test.sh @@ -20,7 +20,7 @@ PROBEID=$(docker_on "$HOST1" logs weavescope 2>&1 | grep "probe starting" | sed # container's PATH settings are respected, which isn't the case for # login shells. PIPEID=$(curl -s -f -X POST "http://$HOST1:4040/api/control/$PROBEID/$CID;/docker_exec_container" | jq -r '.pipe') -assert "(sleep 1 && echo 'echo \$PATH' && sleep 1) | wscat -b 'ws://$HOST1:4040/api/pipe/$PIPEID' | col -pb" "/ # 6necho \$PATH\n/home:/usr/bin\n/ # 6n" +assert "(sleep 1 && echo 'echo \$PATH' && sleep 1) | wscat -b 'ws://$HOST1:4040/api/pipe/$PIPEID' | col -pb" "/ # 6necho \$PATH\\n/home:/usr/bin\\n/ # 6n" assert_raises "curl -f -X POST 'http://$HOST1:4040/api/control/$PROBEID/$CID;/docker_stop_container'" diff --git a/integration/420_host_control_test.sh b/integration/420_host_control_test.sh index fe461b091f..19fc448ac0 100755 --- a/integration/420_host_control_test.sh +++ b/integration/420_host_control_test.sh @@ -15,6 +15,6 @@ HOSTID=$($SSH "$HOST1" hostname) # Execute 'echo foo' in the host tty and check its output PIPEID=$(curl -s -f -X POST "http://$HOST1:4040/api/control/$PROBEID/$HOSTID;/host_exec" | jq -r '.pipe') -assert "(sleep 1 && echo \"PS1=''; echo foo\" && sleep 1) | wscat -b 'ws://$HOST1:4040/api/pipe/$PIPEID' | col -pb | tail -n 1" "foo\n" +assert "(sleep 1 && echo \"PS1=''; echo foo\" && sleep 1) | wscat -b 'ws://$HOST1:4040/api/pipe/$PIPEID' | col -pb | tail -n 1" "foo\\n" scope_end_suite diff --git a/probe/appclient/app_client_internal_test.go b/probe/appclient/app_client_internal_test.go index 4eded3adf0..5c5ee71778 100644 --- a/probe/appclient/app_client_internal_test.go +++ b/probe/appclient/app_client_internal_test.go @@ -32,8 +32,8 @@ func dummyServer(t *testing.T, expectedToken, expectedID string, expectedVersion t.Errorf("want %q, have %q", expectedVersion, have) } - if have := r.Header.Get("user-agent"); "Scope_Probe/"+expectedVersion!=have { - t.Errorf("want %q, have %q","Scope_Probe/"+expectedVersion,have) + if have := r.Header.Get("user-agent"); "Scope_Probe/"+expectedVersion != have { + t.Errorf("want %q, have %q", "Scope_Probe/"+expectedVersion, have) } var have report.Report diff --git a/probe/appclient/probe_config.go b/probe/appclient/probe_config.go index 7a170f7635..90dea7a73f 100644 --- a/probe/appclient/probe_config.go +++ b/probe/appclient/probe_config.go @@ -46,8 +46,7 @@ func (pc ProbeConfig) authorizeHeaders(headers http.Header) { } headers.Set(xfer.ScopeProbeIDHeader, pc.ProbeID) headers.Set(xfer.ScopeProbeVersionHeader, pc.ProbeVersion) - headers.Set("user-agent","Scope_Probe/"+pc.ProbeVersion ) - + headers.Set("user-agent", "Scope_Probe/"+pc.ProbeVersion) } diff --git a/probe/docker/container.go b/probe/docker/container.go index da27ac6d44..76d9f22d97 100644 --- a/probe/docker/container.go +++ b/probe/docker/container.go @@ -399,7 +399,6 @@ func (c *container) controls() []string { default: return []string{StartContainer, RemoveContainer} } - return nil } func (c *container) GetNode() report.Node { diff --git a/probe/docker/registry.go b/probe/docker/registry.go index d2b19a0780..dba7389edf 100644 --- a/probe/docker/registry.go +++ b/probe/docker/registry.go @@ -121,13 +121,13 @@ func NewRegistry(options RegistryOptions) (Registry, error) { images: map[string]docker_client.APIImages{}, pipeIDToexecID: map[string]string{}, - client: client, - pipes: options.Pipes, - interval: options.Interval, - collectStats: options.CollectStats, - hostID: options.HostID, - handlerRegistry: options.HandlerRegistry, - quit: make(chan chan struct{}), + client: client, + pipes: options.Pipes, + interval: options.Interval, + collectStats: options.CollectStats, + hostID: options.HostID, + handlerRegistry: options.HandlerRegistry, + quit: make(chan chan struct{}), noCommandLineArguments: options.NoCommandLineArguments, noEnvironmentVariables: options.NoEnvironmentVariables, } diff --git a/probe/endpoint/ebpf.go b/probe/endpoint/ebpf.go index 847c5d8a02..06fa8e18c4 100644 --- a/probe/endpoint/ebpf.go +++ b/probe/endpoint/ebpf.go @@ -373,6 +373,7 @@ func (t *EbpfTracker) isDead() bool { return t.dead } +// Stop the tracker and wait for it to signal it has stopped func (t *EbpfTracker) Stop() { t.stop() if t.stopping != nil { diff --git a/probe/kubernetes/service.go b/probe/kubernetes/service.go index 2763b7d204..4ff360cac3 100644 --- a/probe/kubernetes/service.go +++ b/probe/kubernetes/service.go @@ -49,8 +49,8 @@ func servicePortString(p apiv1.ServicePort) string { func (s *service) GetNode(probeID string) report.Node { latest := map[string]string{ - IP: s.Spec.ClusterIP, - Type: string(s.Spec.Type), + IP: s.Spec.ClusterIP, + Type: string(s.Spec.Type), report.ControlProbeID: probeID, } if s.Spec.LoadBalancerIP != "" { diff --git a/scope b/scope index 5611e1f5dc..e318ec9555 100755 --- a/scope +++ b/scope @@ -18,7 +18,7 @@ SCOPE_IMAGE="$SCOPE_IMAGE_NAME:$IMAGE_VERSION" # with care. SCOPE_CONTAINER_NAME="${SCOPE_CONTAINER_NAME:-weavescope}" SCOPE_APP_CONTAINER_NAME="${SCOPE_APP_CONTAINER_NAME:-weavescope-app}" -IP_REGEXP="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" +IP_REGEXP="[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}" IP_ADDR_CMD="find /sys/class/net -type l | xargs -n1 basename | grep -vE 'docker|veth|lo' | \ xargs -n1 ip addr show | grep inet | awk '{ print \$2 }' | grep -oE '$IP_REGEXP'" LISTENING_IP_ADDR_CMD="for I in \$( $IP_ADDR_CMD ); do if curl -m 1 -s \${I}:4040 > /dev/null ; then echo \${I}; fi; done" @@ -112,11 +112,11 @@ check_docker_version() { } check_probe_only() { - echo "${ARGS}" | grep -q -E "\-\-no\-app|\-\-service\-token|\-\-probe\-only" + echo "${ARGS}" | grep -q -E -e "--no-app|--service-token|--probe-only" } check_listen_address_arg() { - echo "${ARGS}" | grep -q -E "\-\-app\.http\.address" + echo "${ARGS}" | grep -q -E -e "--app\\.http\\.address" } check_docker_for_mac() { diff --git a/test/fixture/report_fixture.go b/test/fixture/report_fixture.go index 8a5d2ba565..b366b9441d 100644 --- a/test/fixture/report_fixture.go +++ b/test/fixture/report_fixture.go @@ -241,13 +241,13 @@ var ( ServerContainerNodeID: report.MakeNodeWith( ServerContainerNodeID, map[string]string{ - docker.ContainerID: ServerContainerID, - docker.ContainerName: ServerContainerName, - docker.ContainerHostname: ServerContainerHostname, - docker.ContainerState: report.StateRunning, - docker.ContainerStateHuman: report.StateRunning, - docker.ImageID: ServerContainerImageID, - report.HostNodeID: ServerHostNodeID, + docker.ContainerID: ServerContainerID, + docker.ContainerName: ServerContainerName, + docker.ContainerHostname: ServerContainerHostname, + docker.ContainerState: report.StateRunning, + docker.ContainerStateHuman: report.StateRunning, + docker.ImageID: ServerContainerImageID, + report.HostNodeID: ServerHostNodeID, docker.LabelPrefix + detailed.AmazonECSContainerNameLabel: "server", docker.LabelPrefix + "foo1": "bar1", docker.LabelPrefix + "foo2": "bar2", diff --git a/tools/.circleci/config.yml b/tools/.circleci/config.yml index 2e1a470054..27546e1299 100644 --- a/tools/.circleci/config.yml +++ b/tools/.circleci/config.yml @@ -10,11 +10,11 @@ jobs: steps: - checkout - run: cd build; make - - run: docker run --rm -v "$PWD:$PWD" -w "$PWD" --entrypoint sh weaveworks/build-golang -c ./lint . - - run: docker run --rm -v "$PWD:$PWD" -w "$PWD" --entrypoint sh weaveworks/build-golang -c ./shell-lint . - - run: docker run --rm -v "$PWD/cover:/go/src/cover" -w "/go/src/cover" --entrypoint sh weaveworks/build-golang -c make - - run: docker run --rm -v "$PWD/socks:/go/src/socks" -w "/go/src/socks" --entrypoint sh weaveworks/build-golang -c "make proxy" - - run: docker run --rm -v "$PWD/runner:/go/src/runner" -w "/go/src/runner" --entrypoint sh weaveworks/build-golang -c make + - run: docker run --rm -v "$PWD:$PWD" -w "$PWD" --entrypoint sh weaveworks/build-golang -c "./shell-lint ." + - run: docker run --rm -v "$PWD:/go/src" -w "/go/src/cover" --entrypoint sh weaveworks/build-golang -c make + - run: docker run --rm -v "$PWD:/go/src" -w "/go/src/socks" --entrypoint sh weaveworks/build-golang -c "make proxy" + - run: docker run --rm -v "$PWD:/go/src" -w "/go/src/runner" --entrypoint sh weaveworks/build-golang -c make + - run: docker run --rm -v "$PWD:/go/src" -w "/go/src" --entrypoint sh weaveworks/build-golang -c "./lint ./build ./config_management ./cover ./dependencies ./integration ./provisioning ./runner ./scheduler ./socks" - deploy: command: | diff --git a/tools/build/golang/Dockerfile b/tools/build/golang/Dockerfile index df97b2c833..f56c156d7c 100644 --- a/tools/build/golang/Dockerfile +++ b/tools/build/golang/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.13.1-stretch +FROM golang:1.14.4-stretch RUN apt-get update && \ apt-get install -y \ curl \ @@ -8,13 +8,16 @@ RUN apt-get update && \ libprotobuf-dev \ make \ protobuf-compiler \ - python-pip \ + python3 \ + python3-pip \ python-requests \ python-yaml \ + libssl-dev \ + python-openssl \ shellcheck \ unzip && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -RUN pip install attrs pyhcl yapf==0.16.2 flake8==3.3.0 +RUN pip3 install attrs==19.2.0 pyhcl yapf==0.16.2 flake8==3.3.0 RUN curl -fsSLo shfmt https://github.com/mvdan/sh/releases/download/v1.3.0/shfmt_v1.3.0_linux_amd64 && \ echo "b1925c2c405458811f0c227266402cf1868b4de529f114722c2e3a5af4ac7bb2 shfmt" | sha256sum -c && \ chmod +x shfmt && \ @@ -34,7 +37,7 @@ RUN go get -tags netgo \ github.com/golang/protobuf/protoc-gen-go \ github.com/kisielk/errcheck \ github.com/mjibson/esc \ - github.com/prometheus/prometheus/cmd/promtool && \ + && \ rm -rf /go/pkg /go/src RUN mkdir protoc && \ cd protoc && \ diff --git a/tools/dependencies/cross_versions.py b/tools/dependencies/cross_versions.py index dd920f0ef4..a278928429 100755 --- a/tools/dependencies/cross_versions.py +++ b/tools/dependencies/cross_versions.py @@ -80,8 +80,9 @@ def cross_versions(config): def main(argv): try: config = _validate_input(argv) - print(linesep.join('\t'.join(triple) - for triple in cross_versions(config))) + print( + linesep.join('\t'.join(triple) + for triple in cross_versions(config))) except Exception as e: print(str(e)) exit(_ERROR_RUNTIME) diff --git a/tools/lint b/tools/lint index 72621acbb6..3f2d72e9c4 100755 --- a/tools/lint +++ b/tools/lint @@ -219,12 +219,16 @@ matches_any() { return 1 } -filter_out() { +read_patterns() { local patterns_file="$1" if [ -n "$patterns_file" ] && [ -r "$patterns_file" ]; then - local patterns - patterns=$(sed '/^#.*$/d ; /^\s*$/d' "$patterns_file") # Remove blank lines and comments before we start iterating. - [ -n "$DEBUG" ] && echo >&2 "> Filters:" && echo >&2 "$patterns" + sed '/^#.*$/d ; /^\s*$/d' "$patterns_file" # Remove blank lines and comments. + fi +} + +filter_out() { + local patterns="$1" + if [ -n "$patterns" ]; then local filtered_out=() while read -r filename; do matches_any "$filename" "$patterns" && filtered_out+=("$filename") || echo "$filename" @@ -238,11 +242,13 @@ filter_out() { lint_directory() { local dirname="$1" local lint_result=0 + matches_any "$dirname" "$PATTERNS" && return 0 + [ -n "$DEBUG" ] && echo >&2 "> Linting directory: $dirname" # This test is just checking if there are any Go files in the directory if compgen -G "$dirname/*.go" >/dev/null; then lint_go "${dirname}" || lint_result=1 fi - find . -maxdepth 1 "$dirname" | filter_out "$LINT_IGNORE_FILE" | lint_files + find "$dirname" -maxdepth 1 | filter_out "$PATTERNS" | lint_files || lint_result=1 return $lint_result } @@ -255,11 +261,12 @@ lint_directories() { } list_directories() { - if [ $# -gt 0 ]; then - find "$@" \( -name vendor -o -name .git -o -name .cache -o -name .pkg \) -prune -o -type d - fi + find "$@" \( -name vendor -o -name .git -o -name .cache -o -name .pkg \) -prune -o -type d } +PATTERNS=$(read_patterns "$LINT_IGNORE_FILE") +[ -n "$DEBUG" ] && echo >&2 "> Filters:" && echo >&2 "$PATTERNS" + if [ $# = 1 ] && [ -f "$1" ]; then lint "$1" else diff --git a/tools/provisioning/gcp/main.tf b/tools/provisioning/gcp/main.tf index af5a22ebcf..1f9b8bacb6 100755 --- a/tools/provisioning/gcp/main.tf +++ b/tools/provisioning/gcp/main.tf @@ -18,8 +18,10 @@ resource "google_compute_instance" "tf_test_vm" { zone = "${var.gcp_zone}" count = "${var.num_hosts}" - disk { - image = "${var.gcp_image}" + boot_disk { + initialize_params { + image = "${var.gcp_image}" + } } tags = [ diff --git a/tools/provisioning/gcp/outputs.tf b/tools/provisioning/gcp/outputs.tf index 210398ba58..e091979378 100755 --- a/tools/provisioning/gcp/outputs.tf +++ b/tools/provisioning/gcp/outputs.tf @@ -3,11 +3,11 @@ output "username" { } output "public_ips" { - value = ["${google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.assigned_nat_ip}"] + value = ["${google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.nat_ip}"] } output "private_ips" { - value = ["${google_compute_instance.tf_test_vm.*.network_interface.0.address}"] + value = ["${google_compute_instance.tf_test_vm.*.network_interface.0.network_ip}"] } output "hostnames" { @@ -24,7 +24,7 @@ output "hostnames" { output "private_etc_hosts" { value = "${join("\n", "${formatlist("%v %v.%v.%v", - google_compute_instance.tf_test_vm.*.network_interface.0.address, + google_compute_instance.tf_test_vm.*.network_interface.0.network_ip, google_compute_instance.tf_test_vm.*.name, google_compute_instance.tf_test_vm.*.zone, var.app @@ -36,7 +36,7 @@ output "private_etc_hosts" { output "public_etc_hosts" { value = "${join("\n", "${formatlist("%v %v.%v.%v", - google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.assigned_nat_ip, + google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.nat_ip, google_compute_instance.tf_test_vm.*.name, google_compute_instance.tf_test_vm.*.zone, var.app @@ -47,8 +47,8 @@ output "public_etc_hosts" { output "ansible_inventory" { value = "${format("[all]\n%s", join("\n", "${formatlist("%v private_ip=%v", - google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.assigned_nat_ip, - google_compute_instance.tf_test_vm.*.network_interface.0.address + google_compute_instance.tf_test_vm.*.network_interface.0.access_config.0.nat_ip, + google_compute_instance.tf_test_vm.*.network_interface.0.network_ip )}" ))}" } diff --git a/tools/scheduler/README.md b/tools/scheduler/README.md index d9c4aa41eb..5c406911c9 100644 --- a/tools/scheduler/README.md +++ b/tools/scheduler/README.md @@ -23,41 +23,33 @@ $ pip install -r requirements.txt -t lib - Run: ```console - $ appcfg.py --version $(date '+%Y%m%dt%H%M%S') update . - XX:XX PM Application: positive-cocoa-90213; version: 1 - XX:XX PM Host: appengine.google.com - XX:XX PM Starting update of app: positive-cocoa-90213, version: 1 - XX:XX PM Getting current resource limits. - Your browser has been opened to visit: + $ gcloud app deploy --version $(date '+%Y%m%dt%H%M%S') --project positive-cocoa-90213 + Services to deploy: - https://accounts.google.com/o/oauth2/auth?scope=... + descriptor: [/Users/simon/weave/build-tools/scheduler/app.yaml] + source: [/Users/simon/weave/build-tools/scheduler] + target project: [positive-cocoa-90213] + target service: [default] + target version: [20200512t154238] + target url: [https://positive-cocoa-90213.appspot.com] - If your browser is on a different machine then exit and re-run this - application with the command-line parameter - --noauth_local_webserver + Do you want to continue (Y/n)? - Authentication successful. - XX:XX PM Scanning files on local disk. - XX:XX PM Scanned 500 files. - XX:XX PM Scanned 1000 files. - XX:XX PM Cloning 1220 application files. - XX:XX PM Uploading 28 files and blobs. - XX:XX PM Uploaded 28 files and blobs. - XX:XX PM Compilation starting. - XX:XX PM Compilation completed. - XX:XX PM Starting deployment. - XX:XX PM Checking if deployment succeeded. - XX:XX PM Will check again in 1 seconds. - XX:XX PM Checking if deployment succeeded. - XX:XX PM Will check again in 2 seconds. - XX:XX PM Checking if deployment succeeded. - XX:XX PM Will check again in 4 seconds. - XX:XX PM Checking if deployment succeeded. - XX:XX PM Deployment successful. - XX:XX PM Checking if updated app version is serving. - XX:XX PM Completed update of app: positive-cocoa-90213, version: 1 - XX:XX PM Uploading cron entries. + Beginning deployment of service [default]... + ╔════════════════════════════════════════════════════════════╗ + ╠═ Uploading 433 files to Google Cloud Storage ═╣ + ╚════════════════════════════════════════════════════════════╝ + File upload done. + Updating service [default]...done. + Setting traffic split for service [default]...done. + Deployed service [default] to [https://positive-cocoa-90213.appspot.com] + + You can stream logs from the command line by running: + $ gcloud app logs tail -s default + + To view your application in the web browser run: + $ gcloud app browse --project=positive-cocoa-90213 ``` - Go to [console.cloud.google.com](https://console.cloud.google.com) > Weave Integration Tests (`positive-cocoa-90213`) > AppEngine > Versions and ensure traffic is being directed to the newly deployed version. diff --git a/tools/scheduler/app.yaml b/tools/scheduler/app.yaml index 21f5f05273..e21848c809 100644 --- a/tools/scheduler/app.yaml +++ b/tools/scheduler/app.yaml @@ -1,5 +1,3 @@ -application: positive-cocoa-90213 -version: 1 runtime: python27 api_version: 1 threadsafe: true diff --git a/tools/scheduler/main.py b/tools/scheduler/main.py index 733de80779..4dd1e34245 100644 --- a/tools/scheduler/main.py +++ b/tools/scheduler/main.py @@ -82,14 +82,14 @@ def avg(test): test_times_dict = dict(test_times) test_times.sort(key=operator.itemgetter(1)) - shards = {i: [] for i in xrange(shard_count)} + shards = {i: [] for i in range(shard_count)} while test_times: test_name, time = test_times.pop() # find shortest shard and put it in that s, _ = min( ((i, sum(test_times_dict[t] for t in shards[i])) - for i in xrange(shard_count)), + for i in range(shard_count)), key=operator.itemgetter(1)) shards[s].append(test_name) @@ -123,9 +123,6 @@ def _matches_any_regex(name, regexes): return matches -# See also: https://circleci.com/account/api -CIRCLE_CI_API_TOKEN = 'cffb83afd920cfa109cbd3e9eecb7511a2d18bb9' - # N.B.: When adding a project below, please ensure: # - its CircleCI project is either public, or is followed by the user attached # to the above API token @@ -137,8 +134,7 @@ def _matches_any_regex(name, regexes): ('weaveworks/weave', 'positive-cocoa-90213', 'us-central1-a', True, None), ('weaveworks/scope', 'scope-integration-tests', 'us-central1-a', False, None), - ('weaveworks/wks', 'wks-tests', 'us-central1-a', True, - CIRCLE_CI_API_TOKEN), + ('weaveworks/wksctl', 'wks-tests', 'us-central1-a', True, None), ] diff --git a/tools/scheduler/requirements.txt b/tools/scheduler/requirements.txt index 17e9d67141..0bebea87b1 100644 --- a/tools/scheduler/requirements.txt +++ b/tools/scheduler/requirements.txt @@ -1,2 +1,3 @@ flask==1.0.0 google-api-python-client==1.6.7 +werkzeug<1.0 diff --git a/vendor/github.com/richo/GOSHOUT/SHOUT.go b/vendor/github.com/richo/GOSHOUT/SHOUT.go index 2eea007755..779e707bd5 100644 --- a/vendor/github.com/richo/GOSHOUT/SHOUT.go +++ b/vendor/github.com/richo/GOSHOUT/SHOUT.go @@ -25,19 +25,13 @@ func UPCASE(THING_TO_YELL string) (string, error) { } READER := bytes.NewReader(ENCODED) - CLIENT := &http.Client{ - Timeout:time.Second * 20, - } - // NO TLS, SO MUCH SADNESS. - RESP, ERR := CLIENT.Post("http://API.SHOUTCLOUD.IO/V1/SHOUT", + RESP, ERR := http.Post("http://API.SHOUTCLOUD.IO/V1/SHOUT", "application/json", READER) if ERR != nil { return "", errors.New("REQUEST FAILED CAN'T UPCASE ERROR MESSAGE HALP") } - defer RESP.Body.Close() - BODYBYTES, ERR := ioutil.ReadAll(RESP.Body) if ERR != nil { return "", errors.New("COULDN'T READ BODY HALP") diff --git a/vendor/modules.txt b/vendor/modules.txt index 92e7779c89..c8c23171de 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -269,7 +269,7 @@ github.com/prometheus/common/model github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs github.com/prometheus/procfs/internal/util -# github.com/richo/GOSHOUT v0.0.0-20190205170632-a1a6db7f26e9 +# github.com/richo/GOSHOUT v0.0.0-20160308183402-8e98c504bfae github.com/richo/GOSHOUT # github.com/russross/blackfriday v0.0.0-20151020174500-a18a46c9b943 github.com/russross/blackfriday