-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preparation for Otterize Cloud - Merge branch 'develop'
- Loading branch information
Showing
37 changed files
with
1,273 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: golangci-lint | ||
on: | ||
push: | ||
tags: | ||
- v* | ||
branches: | ||
- main | ||
pull_request: | ||
permissions: | ||
contents: read | ||
# Optional: allow read access to pull request. Use with `only-new-issues` option. | ||
# pull-requests: read | ||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: '>=1.19.1' | ||
- uses: actions/checkout@v3 | ||
- name: Install dependencies | ||
run: sudo apt update && sudo apt install libpcap-dev # required for the linter to be able to lint github.com/google/gopacket | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version | ||
version: v1.50.1 | ||
|
||
# Optional: working directory, useful for monorepos | ||
working-directory: src | ||
|
||
# Optional: golangci-lint command line arguments. | ||
args: --timeout 5m | ||
|
||
# Optional: show only new issues if it's a pull request. The default value is `false`. | ||
# only-new-issues: true | ||
|
||
# Optional: if set to true then the all caching functionality will be complete disabled, | ||
# takes precedence over all other caching options. | ||
# skip-cache: true | ||
|
||
# Optional: if set to true then the action don't cache or restore ~/go/pkg. | ||
# skip-pkg-cache: true | ||
|
||
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build. | ||
# skip-build-cache: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "src/cloudgraphql"] | ||
path = src/cloudgraphql | ||
url = https://github.com/otterize/graphql |
Submodule cloudgraphql
added at
4d044b
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package cloudclient | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/Khan/genqlient/graphql" | ||
"github.com/sirupsen/logrus" | ||
"golang.org/x/oauth2" | ||
) | ||
|
||
type FactoryFunction func(ctx context.Context, apiAddress string, tokenSource oauth2.TokenSource) CloudClient | ||
|
||
type CloudClient interface { | ||
ReportDiscoveredIntents(intents []*DiscoveredIntentInput) bool | ||
ReportComponentStatus(component ComponentType) | ||
} | ||
|
||
type CloudClientImpl struct { | ||
ctx context.Context | ||
client graphql.Client | ||
} | ||
|
||
func NewClient(ctx context.Context, apiAddress string, tokenSource oauth2.TokenSource) CloudClient { | ||
url := fmt.Sprintf("%s/graphql/v1", apiAddress) | ||
client := graphql.NewClient(url, oauth2.NewClient(ctx, tokenSource)) | ||
|
||
return &CloudClientImpl{ | ||
client: client, | ||
ctx: ctx, | ||
} | ||
} | ||
|
||
func (c *CloudClientImpl) ReportDiscoveredIntents(intents []*DiscoveredIntentInput) bool { | ||
logrus.Info("Uploading intents to cloud, count: ", len(intents)) | ||
|
||
_, err := ReportDiscoveredIntents(c.ctx, c.client, intents) | ||
if err != nil { | ||
logrus.Error("Failed to upload intents to cloud ", err) | ||
return false | ||
} | ||
|
||
return true | ||
} | ||
|
||
func (c *CloudClientImpl) ReportComponentStatus(component ComponentType) { | ||
logrus.Info("Uploading component to cloud") | ||
|
||
_, err := ReportComponentStatus(c.ctx, c.client, component) | ||
if err != nil { | ||
logrus.Error("Failed to upload component to cloud ", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package cloudclient | ||
|
||
//go:generate go run github.com/Khan/genqlient ./genqlient.yaml | ||
//go:generate go run github.com/golang/mock/[email protected] -destination=./mocks/mocks.go -package=cloudclientmocks -source=./cloud_client.go CloudClient |
Oops, something went wrong.