Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
costinm committed Mar 27, 2022
1 parent 6fce9f7 commit 1c58fac
Show file tree
Hide file tree
Showing 39 changed files with 1,371 additions and 875 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ jobs:
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

# -
# name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1
# -
# name: Login to GitHub Container Registry
# uses: docker/login-action@v1
# with:
# registry: ghcr.io
# #registry: docker.pkg.github.com
# #username: ${{ github.actor }}
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}
# -

- name: push
uses: docker/build-push-action@v1
with:
Expand All @@ -18,16 +33,22 @@ jobs:
registry: docker.pkg.github.com
repository: costinm/ugate/ugate
tag_with_ref: true
# uses: docker/build-push-action@v2
# with:
# push: true
# context: .
# tags: |
# ghcr.io/costinm/cert-ssh/sshd:latest

build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Set up Go 1.16
- name: Set up Go 1.17
uses: actions/setup-go@v1
with:
go-version: 1.16
go-version: 1.17
id: go

- name: Check out code into the Go module directory
Expand Down
4 changes: 1 addition & 3 deletions .run/go-ugate.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<package value="github.com/costinm/ugate/cmd/ugate" />
<directory value="$PROJECT_DIR$/../ugate/cmd/ugate/" />
<filePath value="$PROJECT_DIR$/cmd/ugate/ugate.go" />
<method v="2">
<option name="RunConfigurationTask" enabled="true" run_configuration_name="update" run_configuration_type="MAKEFILE_TARGET_RUN_CONFIGURATION" />
</method>
<method v="2" />
</configuration>
</component>
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,5 @@ remote/_run: build
ssh ${HOST} "cd /x/ugate; HOME=/x/ugate /x/ugate/ugate"

update:
yq -j < cmd/ugate/testdata/ugate.yaml > cmd/ugate/testdata/ugate.json
# yq -j < cmd/ugate/testdata/ugate.yaml > cmd/ugate/testdata/ugate.json

40 changes: 0 additions & 40 deletions bin/ko-build.sh

This file was deleted.

7 changes: 7 additions & 0 deletions cmd/stackdriver/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/costinm/ugate/cmd/stackdriver

go 1.17

replace github.com/costinm/ugate/ext/stackdriver => ../../ext/stackdriver

require github.com/costinm/ugate/ext/stackdriver v0.0.0-00010101000000-000000000000
554 changes: 554 additions & 0 deletions cmd/stackdriver/go.sum

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions cmd/stackdriver/sdt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"context"
"encoding/json"
"flag"
"fmt"
"log"
"os"

"github.com/costinm/ugate/ext/stackdriver"
)

var (
p = flag.String("p", os.Getenv("PROJECT_ID"), "Project ID")

r = flag.String("r", "", "Resource type.")

ns = flag.String("n", os.Getenv("WORKLOAD_NAMESPACE"), "Namespace")
wname = flag.String("s", os.Getenv("WORKLOAD_NAME"), "Service name")
rev = flag.String("v", "", "Version/revision")
metric = flag.String("m", "istio.io/service/client/request_count", "Metric name")
extra = flag.String("x", "", "Extra query parameters")

includeZero = flag.Bool("zero", false, "Include metrics with zero value")
jsonF = flag.Bool("json", false, "json output")
)

func main() {
flag.Parse()
projectID := *p
if *p == "" {
projectID = "wlhe-cr"
//panic("Missing PROJECT_ID")
//return
}

sd, err := stackdriver.NewStackdriver(projectID)
if err != nil {
panic(err)
}

// Verify client side metrics (in pod) reflect the CloudrRun server properties
ts, err := sd.ListTimeSeries(context.Background(),
*ns, *r,
*metric, *extra)
//" AND metric.labels.source_canonical_service_name = \"fortio\"" +
// " AND metric.labels.response_code = \"200\"")
if err != nil {
log.Fatalf("Error %v", err)
}

for _, tsr := range ts {
v := tsr.Points[0].Value
if ! *includeZero && *v.DoubleValue == 0 {
continue
}
if *jsonF {
d, _ := json.Marshal(tsr)
fmt.Println(string(d))
} else {
fmt.Printf("%v %v\n", *v.DoubleValue, tsr.Metric.Labels)
}
}
}

27 changes: 25 additions & 2 deletions cmd/ugate/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/costinm/ugate/cmd/ugate

go 1.16
go 1.17

replace github.com/costinm/ugate => ../../

Expand All @@ -16,7 +16,30 @@ replace github.com/costinm/ugate/ext/ssh => ../../ext/ssh

require (
github.com/costinm/ugate v0.0.0-20210425213441-05024f5e8910
github.com/costinm/ugate/dns v0.0.0-20210425213441-05024f5e8910
github.com/costinm/ugate/ext/bootstrap v0.0.0-20210510001934-3cec7b4617c7
github.com/miekg/dns v1.1.41 // indirect
)

require (
github.com/cheekybits/genny v1.0.0 // indirect
github.com/costinm/ugate/dns v0.0.0-20210425213441-05024f5e8910 // indirect
github.com/costinm/ugate/ext/h2r v0.0.0-20210425213441-05024f5e8910 // indirect
github.com/costinm/ugate/ext/quic v0.0.0-20210425213441-05024f5e8910 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/lucas-clemente/quic-go v0.25.0 // indirect
github.com/marten-seemann/qpack v0.2.1 // indirect
github.com/marten-seemann/qtls-go1-16 v0.1.4 // indirect
github.com/marten-seemann/qtls-go1-17 v0.1.0 // indirect
github.com/marten-seemann/qtls-go1-18 v0.1.0-beta.1 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo v1.16.4 // indirect
golang.org/x/crypto v0.0.0-20210503195802-e9a32991a82e // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 // indirect
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/tools v0.1.1 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
)
Loading

0 comments on commit 1c58fac

Please sign in to comment.