This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: All migrations as files * Update SDK Co-authored-by: Kemal Hadimli <[email protected]>
- Loading branch information
Showing
11 changed files
with
3,164 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: test_migration | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: [main] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
should_run: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
should_run: ${{ steps.cache-migrations.cache-hit != 'true' }} | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Cache Migrations | ||
id: cache-migrations | ||
uses: actions/cache@v2 | ||
with: | ||
path: resources/provider/migrations | ||
key: ${{ runner.os }}-${{ hashFiles('resources/provider/migrations') }} | ||
|
||
test_migration: | ||
needs: should_run | ||
if: github.repository == 'cloudquery/cq-provider-k8s' && needs.should_run.outputs.should_run == 'true' | ||
strategy: | ||
matrix: | ||
dbversion: [ "postgres:latest" ] | ||
go: [ "1.17" ] | ||
platform: [ ubuntu-latest ] # can not run in macOS and windowsOS | ||
runs-on: ${{ matrix.platform }} | ||
services: | ||
postgres: | ||
image: ${{ matrix.dbversion }} | ||
env: | ||
POSTGRES_PASSWORD: pass | ||
POSTGRES_USER: postgres | ||
POSTGRES_DB: postgres | ||
ports: | ||
- 5432:5432 | ||
# Set health checks to wait until postgres has started | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.17 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get dependencies | ||
run: | | ||
go get -v -t -d ./... | ||
- name: Test migrations for Postgres | ||
run: | | ||
go test -v ./resources/provider/provider_test.go | ||
env: | ||
CQ_MIGRATION_TEST_DSN: postgres://postgres:pass@localhost:5432/postgres?sslmode=disable | ||
|
||
- name: Test migrations for Timescale | ||
run: | | ||
go test -v ./resources/provider/provider_test.go | ||
env: | ||
CQ_MIGRATION_TEST_DSN: tsdb://postgres:pass@localhost:5432/postgres?sslmode=disable | ||
|
||
- name: Slack Notification | ||
uses: rtCamp/action-slack-notify@v2 | ||
if: ${{ failure() }} | ||
env: | ||
SLACK_CHANNEL: oss-tests | ||
SLACK_COLOR: ${{ job.status }} | ||
SLACK_MESSAGE: 'K8S - migration test failed' | ||
SLACK_TITLE: K8S - migration test failed | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} |
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
104 changes: 104 additions & 0 deletions
104
resources/provider/migrations/postgres/1_v0.4.0.down.sql
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,104 @@ | ||
-- Autogenerated by migration tool on 2022-01-19 11:52:48 | ||
|
||
-- Resource: apps.daemon_sets | ||
DROP TABLE IF EXISTS k8s_apps_daemon_set_selector_match_expressions; | ||
DROP TABLE IF EXISTS k8s_apps_daemon_set_status_conditions; | ||
DROP TABLE IF EXISTS k8s_apps_daemon_sets; | ||
|
||
-- Resource: apps.deployments | ||
DROP TABLE IF EXISTS k8s_apps_deployment_selector_match_expressions; | ||
DROP TABLE IF EXISTS k8s_apps_deployment_status_conditions; | ||
DROP TABLE IF EXISTS k8s_apps_deployments; | ||
|
||
-- Resource: apps.replica_sets | ||
DROP TABLE IF EXISTS k8s_apps_replica_set_selector_match_expressions; | ||
DROP TABLE IF EXISTS k8s_apps_replica_set_status_conditions; | ||
DROP TABLE IF EXISTS k8s_apps_replica_sets; | ||
|
||
-- Resource: apps.stateful_sets | ||
DROP TABLE IF EXISTS k8s_apps_stateful_set_selector_match_expressions; | ||
DROP TABLE IF EXISTS k8s_apps_stateful_set_status_conditions; | ||
DROP TABLE IF EXISTS k8s_apps_stateful_sets; | ||
|
||
-- Resource: batch.cron_jobs | ||
DROP TABLE IF EXISTS k8s_batch_cron_jobs; | ||
|
||
-- Resource: batch.jobs | ||
DROP TABLE IF EXISTS k8s_batch_job_selector_match_expressions; | ||
DROP TABLE IF EXISTS k8s_batch_job_status_conditions; | ||
DROP TABLE IF EXISTS k8s_batch_jobs; | ||
|
||
-- Resource: core.endpoints | ||
DROP TABLE IF EXISTS k8s_core_endpoint_subset_addresses; | ||
DROP TABLE IF EXISTS k8s_core_endpoint_subset_not_ready_addresses; | ||
DROP TABLE IF EXISTS k8s_core_endpoint_subset_ports; | ||
DROP TABLE IF EXISTS k8s_core_endpoint_subsets; | ||
DROP TABLE IF EXISTS k8s_core_endpoints; | ||
|
||
-- Resource: core.limit_ranges | ||
DROP TABLE IF EXISTS k8s_core_limit_range_limits; | ||
DROP TABLE IF EXISTS k8s_core_limit_ranges; | ||
|
||
-- Resource: core.namespaces | ||
DROP TABLE IF EXISTS k8s_meta_owner_references; | ||
DROP TABLE IF EXISTS k8s_core_namespaces; | ||
|
||
-- Resource: core.nodes | ||
DROP TABLE IF EXISTS k8s_core_node_images; | ||
DROP TABLE IF EXISTS k8s_core_node_volumes_attached; | ||
DROP TABLE IF EXISTS k8s_core_nodes; | ||
|
||
-- Resource: core.pods | ||
DROP TABLE IF EXISTS k8s_core_pod_init_container_ports; | ||
DROP TABLE IF EXISTS k8s_core_pod_init_container_envs; | ||
DROP TABLE IF EXISTS k8s_core_pod_init_container_volume_mounts; | ||
DROP TABLE IF EXISTS k8s_core_pod_init_container_volume_devices; | ||
DROP TABLE IF EXISTS k8s_core_pod_init_containers; | ||
DROP TABLE IF EXISTS k8s_core_pod_container_ports; | ||
DROP TABLE IF EXISTS k8s_core_pod_container_envs; | ||
DROP TABLE IF EXISTS k8s_core_pod_container_volume_mounts; | ||
DROP TABLE IF EXISTS k8s_core_pod_container_volume_devices; | ||
DROP TABLE IF EXISTS k8s_core_pod_containers; | ||
DROP TABLE IF EXISTS k8s_core_pod_ephemeral_container_ports; | ||
DROP TABLE IF EXISTS k8s_core_pod_ephemeral_container_envs; | ||
DROP TABLE IF EXISTS k8s_core_pod_ephemeral_container_volume_mounts; | ||
DROP TABLE IF EXISTS k8s_core_pod_ephemeral_container_volume_devices; | ||
DROP TABLE IF EXISTS k8s_core_pod_ephemeral_containers; | ||
DROP TABLE IF EXISTS k8s_core_pod_volumes; | ||
DROP TABLE IF EXISTS k8s_core_pod_init_container_statuses; | ||
DROP TABLE IF EXISTS k8s_core_pod_container_statuses; | ||
DROP TABLE IF EXISTS k8s_core_pod_ephemeral_container_statuses; | ||
DROP TABLE IF EXISTS k8s_core_pods; | ||
|
||
-- Resource: core.resource_quotas | ||
DROP TABLE IF EXISTS k8s_core_resource_quota_scope_selector_match_expressions; | ||
DROP TABLE IF EXISTS k8s_core_resource_quotas; | ||
|
||
-- Resource: core.service_accounts | ||
DROP TABLE IF EXISTS k8s_core_service_account_secrets; | ||
DROP TABLE IF EXISTS k8s_core_service_accounts; | ||
|
||
-- Resource: core.services | ||
DROP TABLE IF EXISTS k8s_core_service_ports; | ||
DROP TABLE IF EXISTS k8s_core_service_load_balancer_ingress_ports; | ||
DROP TABLE IF EXISTS k8s_core_service_load_balancer_ingresses; | ||
DROP TABLE IF EXISTS k8s_core_service_conditions; | ||
DROP TABLE IF EXISTS k8s_core_services; | ||
|
||
-- Resource: networking.network_policies | ||
DROP TABLE IF EXISTS k8s_networking_network_policy_pod_selector_match_expressions; | ||
DROP TABLE IF EXISTS k8s_networking_network_policy_ingress_ports; | ||
DROP TABLE IF EXISTS k8s_networking_network_policy_ingress_from; | ||
DROP TABLE IF EXISTS k8s_networking_network_policy_ingress; | ||
DROP TABLE IF EXISTS k8s_networking_network_policy_egress_ports; | ||
DROP TABLE IF EXISTS k8s_networking_network_policy_egress_to; | ||
DROP TABLE IF EXISTS k8s_networking_network_policy_egress; | ||
DROP TABLE IF EXISTS k8s_networking_network_policies; | ||
|
||
-- Resource: rbac.role_bindings | ||
DROP TABLE IF EXISTS k8s_rbac_role_binding_subjects; | ||
DROP TABLE IF EXISTS k8s_rbac_role_bindings; | ||
|
||
-- Resource: rbac.roles | ||
DROP TABLE IF EXISTS k8s_rbac_role_rules; | ||
DROP TABLE IF EXISTS k8s_rbac_roles; |
Oops, something went wrong.