Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new service #19

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/actions/build-downstream/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: build
description: Generates Google/Google-Beta Provider
inputs:
repo:
description: "provider repo"
required: true
token:
description: "github token"
required: true

runs:
using: "composite"
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Ruby
uses: ruby/setup-ruby@036ef458ddccddb148a2b9fb67e95a22fdbf728b # v1.160.0
with:
ruby-version: '3.1'

- name: Cache Bundler gems
uses: actions/cache@v3
with:
path: mmv1/vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('mmv1/**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-

- name: Install Ruby dependencies
shell: bash
run: |
bundle config path mmv1/vendor/bundle
bundle install
working-directory: mmv1

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '^1.20'

# Cache Go modules
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- run: go install golang.org/x/tools/cmd/goimports@latest
shell: bash
- name: Build ${{ inputs.repo }}
shell: bash
env:
BASE_BRANCH: ${{ github.event.pull_request.base.ref || github.ref_name }}
GITHUB_TOKEN: ${{ inputs.token }}
run: |
set -e
set -x
# Set GOPATH to a directory the runner user has access to
export GOPATH=~/go

function clone_repo() {
export OUTPUT_PATH=$GOPATH/src/github.com/$UPSTREAM_OWNER/$GH_REPO
GITHUB_PATH=https://x-access-token:[email protected]/$UPSTREAM_OWNER/$GH_REPO
mkdir -p "$(dirname $OUTPUT_PATH)"
git clone $GITHUB_PATH $OUTPUT_PATH --branch $BASE_BRANCH
}

GH_REPO="${{ inputs.repo }}"
if [ "$GH_REPO" == "docs-examples" ] && [ "$BASE_BRANCH" == "main" ]; then
BASE_BRANCH="master"
fi

GITHUB_PATH=https://x-access-token:[email protected]/$UPSTREAM_OWNER/$GH_REPO

if [[ "$GH_REPO" == terraform-provider-google* ]]; then
UPSTREAM_OWNER=hashicorp
clone_repo
if [ "$GH_REPO" == "terraform-provider-google" ]; then
export VERSION=ga
else
export VERSION=beta
fi
make clean-provider
make provider
elif [ "$GH_REPO" == "terraform-google-conversion" ]; then
UPSTREAM_OWNER=GoogleCloudPlatform
clone_repo
make clean-tgc
make tgc
elif [ "$GH_REPO" == "docs-examples" ]; then
UPSTREAM_OWNER=terraform-google-modules
clone_repo
make tf-oics
else
echo "case not supported"
exit 1
fi

(current_dir=$(pwd) && cd $OUTPUT_PATH && zip -r "$current_dir/output.zip" .)
79 changes: 26 additions & 53 deletions .github/workflows/teamcity-services-diff-check-weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,30 @@ on:
- cron: '0 4 * * 1-2'

jobs:
terraform-provider-google:
uses: ./.github/workflows/build-downstream.yml
with:
repo: 'terraform-provider-google'

terraform-provider-google-beta:
uses: ./.github/workflows/build-downstream.yml
with:
repo: 'terraform-provider-google-beta'

teamcity-services-diff-check:
needs: [terraform-provider-google, terraform-provider-google-beta]
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '^1.20'

- name: Download built artifacts - GA provider
uses: actions/download-artifact@v2
with:
name: artifact-terraform-provider-google
path: artifacts

- name: Unzip the artifacts and delete the zip
run: |
unzip -o artifacts/output.zip -d ./provider
rm artifacts/output.zip

- name: Download built artifacts - Beta provider
uses: actions/download-artifact@v2
with:
name: artifact-terraform-provider-google-beta
path: artifacts

- name: Unzip the artifacts and delete the zip
run: |
unzip -o artifacts/output.zip -d ./provider
rm artifacts/output.zip

- name: Check that new services have been added to the TeamCity configuration code
run: |
# Create lists of service packages in providers
ls provider/google/services > tools/teamcity-diff-check/services_ga.txt
ls provider/google-beta/services > tools/teamcity-diff-check/services_beta.txt

# Run tool to compare service packages in the providers vs those listed in TeamCity config files
cd tools/teamcity-diff-check
go run main.go -service_file=services_ga
go run main.go -service_file=services_beta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: TeamCity Google Provider Generate
uses: ./.github/actions/build-downstream
with:
repo: 'terraform-provider-google'
token: '$GITHUB_TOKEN'
- name: TeamCity Google Beta Provider Generate
uses: ./.github/actions/build-downstream
with:
repo: 'terraform-provider-google-beta'
token: '$GITHUB_TOKEN'
- name: Check that new services have been added to the TeamCity configuration code
run: |
# Create lists of service packages in providers
ls provider/google/services > tools/teamcity-diff-check/services_ga.txt
ls provider/google-beta/services > tools/teamcity-diff-check/services_beta.txt

# Run tool to compare service packages in the providers vs those listed in TeamCity config files
cd tools/teamcity-diff-check
go run main.go -service_file=services_ga
go run main.go -service_file=services_beta
69 changes: 19 additions & 50 deletions .github/workflows/teamcity-services-diff-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ on:
- 'mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt'
- 'mmv1/products/**'
jobs:
check-pr:
teamcity-services-diff-check:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-22.04
outputs:
services: ${{steps.services.outputs.services}}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -24,57 +24,26 @@ jobs:
newServices=$(($(git diff --name-only --diff-filter=A origin/main HEAD | grep -P "mmv1/products/.*/product.yaml" | wc -l)))
echo "services=$newServices" >> "${GITHUB_OUTPUT}"
if [ "$newServices" = "0" ];then
echo "No new service found."
echo "No new service found."
fi
terraform-provider-google:
if: ${{needs.check-pr.outputs.services != '0'}}
needs: check-pr
uses: ./.github/workflows/build-downstream.yml
with:
repo: 'terraform-provider-google'

terraform-provider-google-beta:
if: ${{needs.check-pr.outputs.services != '0'}}
needs: check-pr
uses: ./.github/workflows/build-downstream.yml
with:
repo: 'terraform-provider-google-beta'

teamcity-services-diff-check:
needs: [terraform-provider-google, terraform-provider-google-beta]
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v4
- name: TeamCity Google Provider Generate
id: generate
if: ${{steps.services.outputs.services != '0'}}
uses: ./.github/actions/build-downstream
with:
go-version: '^1.20'

- name: Download built artifacts - GA provider
uses: actions/download-artifact@v2
repo: 'terraform-provider-google'
token: '$GITHUB_TOKEN'
- name: TeamCity Google Beta Provider Generate
if: steps.generate.outcome == 'success'
uses: ./.github/actions/build-downstream
with:
name: artifact-terraform-provider-google
path: artifacts

- name: Unzip the artifacts and delete the zip
run: |
unzip -o artifacts/output.zip -d ./provider
rm artifacts/output.zip

- name: Download built artifacts - Beta provider
uses: actions/download-artifact@v2
with:
name: artifact-terraform-provider-google-beta
path: artifacts

- name: Unzip the artifacts and delete the zip
run: |
unzip -o artifacts/output.zip -d ./provider
rm artifacts/output.zip

repo: 'terraform-provider-google-beta'
token: '$GITHUB_TOKEN'
- name: Checkout Repository
if: steps.generate.outcome == 'success'
uses: actions/checkout@v4
- name: Check that new services have been added to the TeamCity configuration code
if: steps.generate.outcome == 'success'
run: |
# Create lists of service packages in providers
ls provider/google/services > tools/teamcity-diff-check/services_ga.txt
Expand Down
80 changes: 80 additions & 0 deletions mmv1/products/midquery/AgentPool.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright 2023 Google Inc.
# 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
#
# http://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.

--- !ruby/object:Api::Resource
name: 'AgentPool'
description: 'Represents an On-Premises Agent pool.'
base_url: 'projects/{{project}}/agentPools'
self_link: 'projects/{{project}}/agentPools/{{name}}'
create_url: 'projects/{{project}}/agentPools?agentPoolId={{name}}'
update_verb: :PATCH
update_mask: true
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation': 'https://cloud.google.com/storage-transfer/docs/on-prem-agent-pools'
api: 'https://cloud.google.com/storage-transfer/docs/reference/rest/v1/projects.agentPools'
examples:
- !ruby/object:Provider::Terraform::Examples
name: 'agent_pool_basic'
primary_resource_id:
'example'
# Skip generating this test as the example is covered in resource_storage_transfer_agent_pool_test.go
skip_test: true
vars:
agent-pool-name: 'agent-pool-example'
test_env_vars:
project_id: :PROJECT_NAME
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 30
custom_code: !ruby/object:Provider::Terraform::CustomCode
constants: templates/terraform/constants/agent_pool.go.erb
post_create: templates/terraform/post_create/agent_pool.go.erb
pre_update: templates/terraform/pre_update/agent_pool.go.erb
post_import: templates/terraform/post_import/agent_pool.go.erb
properties:
- !ruby/object:Api::Type::String
name: 'name'
description: |
The ID of the agent pool to create.
The agentPoolId must meet the following requirements:
* Length of 128 characters or less.
* Not start with the string goog.
* Start with a lowercase ASCII character, followed by:
* Zero or more: lowercase Latin alphabet characters, numerals, hyphens (-), periods (.), underscores (_), or tildes (~).
* One or more numerals or lowercase ASCII characters.
As expressed by the regular expression: ^(?!goog)[a-z]([a-z0-9-._~]*[a-z0-9])?$.
immutable: true
required: true
url_param_only: true
- !ruby/object:Api::Type::String
name: 'displayName'
description: 'Specifies the client-specified AgentPool description.'
- !ruby/object:Api::Type::Enum
name: 'state'
description: 'Specifies the state of the AgentPool.'
output: true
values:
- :CREATING
- :CREATED
- :DELETING
- !ruby/object:Api::Type::NestedObject
name: 'bandwidthLimit'
description: |
Specifies the bandwidth limit details. If this field is unspecified, the default value is set as 'No Limit'.
properties:
- !ruby/object:Api::Type::String
name: 'limitMbps'
description:
'Bandwidth rate in megabytes per second, distributed across all the
agents in the pool.'
required: true
22 changes: 22 additions & 0 deletions mmv1/products/midquery/product.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2022 Google Inc.
# 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
#
# http://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.

--- !ruby/object:Api::Product
name: MidQuery
display_name: Mid Query
versions:
- !ruby/object:Api::Product::Version
name: beta
base_url: https://workstations.googleapis.com/v1beta/
scopes:
- https://www.googleapis.com/auth/cloud-platform
Loading