Skip to content

Commit

Permalink
Merge branch 'master' into feature/s390x-arch
Browse files Browse the repository at this point in the history
  • Loading branch information
buger committed Mar 31, 2023
2 parents 6e6b9d3 + fbfaa7a commit 249b68e
Show file tree
Hide file tree
Showing 113 changed files with 4,229 additions and 2,212 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/ci/ @TykTechnologies/devops
.github/workflows/release.yml @TykTechnologies/devops
.github/workflows/sync-automation.yml @TykTechnologies/devops
.github/workflows/pac.yml @TykTechnologies/devops
/repo-policy/ @TykTechnologies/devops
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# Generated by: gromit policy
# Generated on: Wed Dec 14 19:54:02 UTC 2022
# Generated on: Mon Mar 13 10:17:48 UTC 2023

version: 2
updates:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ jobs:
make lint
git add --all
git diff HEAD > git-state.log
echo "git-state=$(sed -ze 's/%/%25/g;s/\n/%0A/g' git-state.log)" >> $GITHUB_OUTPUT
git_state_count=$(wc -l < git-state.log)
if [[ $git_state_count -ne 0 ]]
then
echo "git-state<<EOF" >> $GITHUB_OUTPUT
cat git-state.log >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "make lint made git state dirty, please run make lint locally and update PR"
exit 1
fi
Expand All @@ -71,7 +75,6 @@ jobs:
with:
redis-version: ${{ matrix.redis-version }}


- name: Cache
uses: actions/cache@v2
with:
Expand All @@ -83,10 +86,7 @@ jobs:
- name: Run Gateway Tests
id: ci-tests
run: |
./bin/ci-tests.sh 2>&1 | tee test.log
result_code=${PIPESTATUS[0]}
echo "log=$(sed -ze 's/%/%25/g;s/\n/%0A/g' test.log)" >> $GITHUB_OUTPUT
exit $result_code
./bin/ci-tests.sh 2>&1
- name: Notify status
if: ${{ failure() && github.event.pull_request.number }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/del-env.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# Generated by: gromit policy
# Generated on: Wed Dec 14 19:54:02 UTC 2022
# Generated on: Mon Mar 13 10:17:48 UTC 2023

name: Retiring dev env

Expand Down
50 changes: 46 additions & 4 deletions .github/workflows/pac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@ name: Policy as Code
on:
pull_request:
paths:
- ci/repo-policy/**
- repo-policy/**

env:
TERRAFORM_DIR: "./ci/repo-policy"
GITHUB_TOKEN: ${{ secrets.ITS_GH_TOKEN }}
TERRAFORM_DIR: "./repo-policy"

jobs:
terraform:
runs-on: ubuntu-latest
permissions:
id-token: write
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1

- uses: aws-actions/configure-aws-credentials@v1
with:
Expand All @@ -28,16 +30,56 @@ jobs:
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.3.0
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}

- name: Terraform Init
working-directory: ${{ env.TERRAFORM_DIR }}
id: init
run: terraform init -input=false

- name: Terraform Validate
id: validate
run: terraform validate -no-color

- name: Terraform Plan
working-directory: ${{ env.TERRAFORM_DIR }}
id: plan
run: |
echo "::group::Terraform Plan"
terraform validate && terraform plan
terraform plan -no-color -input=false
echo "::endgroup::"
continue-on-error: true

- name: Update Pull Request
uses: actions/github-script@v6
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${process.env.PLAN}
\`\`\`
</details>
*Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
- name: Terraform Plan Status
if: steps.plan.outcome == 'failure'
run: exit 1
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# Generated by: gromit policy
# Generated on: Wed Dec 14 19:54:02 UTC 2022
# Generated on: Mon Mar 13 10:17:48 UTC 2023


# Distribution channels covered by this workflow
Expand Down Expand Up @@ -56,6 +56,10 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: "Add Git safe.directory"
run: git config --global --add safe.directory $GITHUB_WORKSPACE

- uses: docker/setup-qemu-action@v2

- uses: docker/setup-buildx-action@v2
Expand All @@ -66,7 +70,6 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Login to Cloudsmith
if: startsWith(github.ref, 'refs/tags')
uses: docker/login-action@v2
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/sync-automation.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Generated by: gromit policy
# Generated on: Thu Dec 15 07:17:30 UTC 2022
# Generated on: Thu Mar 9 16:52:31 UTC 2023

name: Sync automation

Expand All @@ -16,6 +16,7 @@ on:
jobs:
sync:
runs-on: ubuntu-latest
container: tykio/gromit:v1.5

strategy:
fail-fast: false
Expand All @@ -33,6 +34,7 @@ jobs:
- name: sync ${{matrix.branch}} from master
id: sync-changes
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config --local user.email "policy@gromit"
git config --local user.name "Bender"
git fetch origin ${{ matrix.branch }}
Expand All @@ -53,6 +55,21 @@ jobs:
echo "::debug::Commit ${{ github.sha }} syncd for ${{matrix.branch}}"
exit 0
- name: Generate releng bundle using latest gromit templates for ${{matrix.branch}}
id: gromit-bundle-gen
run: |
# add gh cli to gromit container
apk add --no-cache github-cli
# get the tarball for the latest gromit master - it will have the latest version of
# the templates.
mkdir /tmp/gromit-src && gh api -H "Accept: application/vnd.github+json" /repos/TykTechnologies/gromit/tarball/master | tar --strip-components 1 -C /tmp/gromit-src -xzf -
gromit bundle gen --branch ${{ matrix.branch }} --bundle /tmp/gromit-src/policy/templates/releng --repo tyk .
git add -A && git commit -m "[CI]: Automated releng bundle sync by sync-automation"
git push origin ${{ steps.sync-changes.outputs.prbranch }}
exit 0
env:
GH_TOKEN: ${{ secrets.ORG_GH_TOKEN }}

- name: Create PR from the branch.
id: create-pr
uses: actions/github-script@v6
Expand Down Expand Up @@ -89,6 +106,6 @@ jobs:
run: |
gh pr merge $PULL --auto --squash --subject "[CI] Sync automation: Syncing commits from master" --body "Picking CI changes from the commit $COMMIT"
env:
GITHUB_TOKEN: ${{ secrets.ORG_GH_TOKEN }}
GH_TOKEN: ${{ secrets.ORG_GH_TOKEN }}
PULL: ${{ steps.create-pr.outputs.result }}
COMMIT: ${{ github.sha }}
23 changes: 23 additions & 0 deletions .github/workflows/update-config-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Keep the docs on tyk-docs in sync with this branch's docs

name: Update Config docs

on:
push:
branches:
- master
- release-**
paths:
- config/config.go

jobs:
sync:
name: tyk-config-docs
runs-on: ubuntu-latest
steps:
- uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.ORG_GH_TOKEN }}
repository: TykTechnologies/tyk-docs
event-type: tyk-config-docs
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}","repo":"gateway","branch":"${{github.ref_name}}"}'
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ linters:
- dupl
- nilerr
- misspell
- goimports

linters-settings:
goimports:
local-prefixes: github.com/TykTechnologies,github.com/TykTechnologies/tyk/internal

errcheck:
check-type-assertions: true
check-blank: true
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test:
# lint runs all local linters that must pass before pushing
.PHONY: lint lint-install lint-fast
lint: lint-install
goimports -local github.com/TykTechnologies -w .
goimports -local github.com/TykTechnologies,github.com/TykTechnologies/tyk/internal -w .
gofmt -w .
faillint -ignore-tests -paths "$(shell grep -v '^#' .faillint | xargs echo | sed 's/ /,/g')" ./...

Expand Down
56 changes: 56 additions & 0 deletions apidef/adapter/gqlengineadapter/adapter_proxy_only.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package gqlengineadapter

import (
"net/http"
"strings"

graphqlDataSource "github.com/TykTechnologies/graphql-go-tools/pkg/engine/datasource/graphql_datasource"
"github.com/TykTechnologies/graphql-go-tools/pkg/graphql"

"github.com/TykTechnologies/tyk/apidef"
)

type ProxyOnly struct {
ApiDefinition *apidef.APIDefinition
HttpClient *http.Client
StreamingClient *http.Client
Schema *graphql.Schema

subscriptionClientFactory graphqlDataSource.GraphQLSubscriptionClientFactory
}

func (p *ProxyOnly) EngineConfig() (*graphql.EngineV2Configuration, error) {
var err error
if p.Schema == nil {
p.Schema, err = parseSchema(p.ApiDefinition.GraphQL.Schema)
if err != nil {
return nil, err
}
}

staticHeaders := make(http.Header)

url := p.ApiDefinition.Proxy.TargetURL
if strings.HasPrefix(url, "tyk://") {
url = strings.ReplaceAll(url, "tyk://", "http://")
staticHeaders.Set(apidef.TykInternalApiHeader, "true")
}

upstreamConfig := graphql.ProxyUpstreamConfig{
URL: url,
StaticHeaders: staticHeaders,
SubscriptionType: graphqlSubscriptionType(p.ApiDefinition.GraphQL.Proxy.SubscriptionType),
}

v2Config, err := graphql.NewProxyEngineConfigFactory(
p.Schema,
upstreamConfig,
graphqlDataSource.NewBatchFactory(),
graphql.WithProxyHttpClient(p.HttpClient),
graphql.WithProxyStreamingClient(p.StreamingClient),
graphql.WithProxySubscriptionClientFactory(subscriptionClientFactoryOrDefault(p.subscriptionClientFactory)),
).EngineV2Configuration()

v2Config.EnableSingleFlight(true)
return &v2Config, err
}
Loading

0 comments on commit 249b68e

Please sign in to comment.