Rename CloudBuildCreateBuildOperator to CloudBuildCreateOperator (#9314)

This commit is contained in:
Kamil Breguła 2020-06-15 19:27:03 +02:00 коммит произвёл GitHub
Родитель 2c18a3f3b3
Коммит 1459970b3b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 21 добавлений и 34 удалений

Просмотреть файл

@ -919,7 +919,7 @@ The following table shows changes in import paths.
|airflow.contrib.operators.gcp_bigtable_operator.BigtableTableCreateOperator |airflow.providers.google.cloud.operators.bigtable.BigtableCreateTableOperator |
|airflow.contrib.operators.gcp_bigtable_operator.BigtableTableDeleteOperator |airflow.providers.google.cloud.operators.bigtable.BigtableDeleteTableOperator |
|airflow.contrib.operators.gcp_bigtable_operator.BigtableTableWaitForReplicationSensor |airflow.providers.google.cloud.sensors.bigtable.BigtableTableReplicationCompletedSensor |
|airflow.contrib.operators.gcp_cloud_build_operator.CloudBuildCreateBuildOperator |airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateOperator |
|airflow.contrib.operators.gcp_cloud_build_operator.CloudBuildCreateBuildOperator |airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateBuildOperator |
|airflow.contrib.operators.gcp_compute_operator.GceBaseOperator |airflow.providers.google.cloud.operators.compute.GceBaseOperator |
|airflow.contrib.operators.gcp_compute_operator.GceInstanceGroupManagerUpdateTemplateOperator |airflow.providers.google.cloud.operators.compute.GceInstanceGroupManagerUpdateTemplateOperator |
|airflow.contrib.operators.gcp_compute_operator.GceInstanceStartOperator |airflow.providers.google.cloud.operators.compute.GceInstanceStartOperator |

Просмотреть файл

@ -19,23 +19,10 @@
import warnings
from airflow.providers.google.cloud.operators.cloud_build import CloudBuildCreateOperator
# pylint: disable=unused-import
from airflow.providers.google.cloud.operators.cloud_build import CloudBuildCreateBuildOperator # noqa
warnings.warn(
"This module is deprecated. Please use `airflow.providers.google.cloud.operators.cloud_build`.",
DeprecationWarning, stacklevel=2
)
class CloudBuildCreateBuildOperator(CloudBuildCreateOperator):
"""
This class is deprecated.
Please use `airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateOperator`.
"""
def __init__(self, *args, **kwargs):
warnings.warn(
"""This class is deprecated.
Please use `airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateOperator`.""",
DeprecationWarning, stacklevel=2
)
super().__init__(*args, **kwargs)

Просмотреть файл

@ -287,7 +287,7 @@ All classes in Airflow 2.0 are in `airflow.providers.google` package.
| [cloud.operators.bigtable.BigtableDeleteTableOperator](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/operators/bigtable.py) | [contrib.operators.gcp_bigtable_operator.BigtableTableDeleteOperator](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/operators/gcp_bigtable_operator.py) |
| [cloud.operators.bigtable.BigtableUpdateClusterOperator](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/operators/bigtable.py) | [contrib.operators.gcp_bigtable_operator.BigtableClusterUpdateOperator](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/operators/gcp_bigtable_operator.py) |
| [cloud.operators.cassandra_to_gcs.CassandraToGCSOperator](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/operators/cassandra_to_gcs.py) | [contrib.operators.cassandra_to_gcs.CassandraToGoogleCloudStorageOperator](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/operators/cassandra_to_gcs.py) |
| [cloud.operators.cloud_build.CloudBuildCreateOperator](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/operators/cloud_build.py) | [contrib.operators.gcp_cloud_build_operator.CloudBuildCreateBuildOperator](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/operators/gcp_cloud_build_operator.py) |
| [cloud.operators.cloud_build.CloudBuildCreateBuildOperator](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/operators/cloud_build.py) | [contrib.operators.gcp_cloud_build_operator.CloudBuildCreateOperator](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/operators/gcp_cloud_build_operator.py) |
| [cloud.operators.cloud_sql.CloudSQLBaseOperator](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/operators/cloud_sql.py) | [contrib.operators.gcp_sql_operator.CloudSqlBaseOperator](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/operators/gcp_sql_operator.py) |
| [cloud.operators.cloud_sql.CloudSQLCreateInstanceDatabaseOperator](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/operators/cloud_sql.py) | [contrib.operators.gcp_sql_operator.CloudSqlInstanceDatabaseCreateOperator](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/operators/gcp_sql_operator.py) |
| [cloud.operators.cloud_sql.CloudSQLCreateInstanceOperator](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/operators/cloud_sql.py) | [contrib.operators.gcp_sql_operator.CloudSqlInstanceCreateOperator](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/operators/gcp_sql_operator.py) |

Просмотреть файл

@ -35,7 +35,7 @@ from future.backports.urllib.parse import urlparse
from airflow import models
from airflow.operators.bash import BashOperator
from airflow.providers.google.cloud.operators.cloud_build import CloudBuildCreateOperator
from airflow.providers.google.cloud.operators.cloud_build import CloudBuildCreateBuildOperator
from airflow.utils import dates
GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project")
@ -81,7 +81,7 @@ with models.DAG(
tags=['example'],
) as dag:
# [START howto_operator_create_build_from_storage]
create_build_from_storage = CloudBuildCreateOperator(
create_build_from_storage = CloudBuildCreateBuildOperator(
task_id="create_build_from_storage", project_id=GCP_PROJECT_ID, body=create_build_from_storage_body
)
# [END howto_operator_create_build_from_storage]
@ -93,7 +93,7 @@ with models.DAG(
)
# [END howto_operator_create_build_from_storage_result]
create_build_from_repo = CloudBuildCreateOperator(
create_build_from_repo = CloudBuildCreateBuildOperator(
task_id="create_build_from_repo", project_id=GCP_PROJECT_ID, body=create_build_from_repo_body
)
@ -103,7 +103,7 @@ with models.DAG(
)
# [START howto_operator_gcp_create_build_from_yaml_body]
create_build_from_file = CloudBuildCreateOperator(
create_build_from_file = CloudBuildCreateBuildOperator(
task_id="create_build_from_file", project_id=GCP_PROJECT_ID,
body=str(CURRENT_FOLDER.joinpath('example_cloud_build.yaml')),
params={'name': 'Airflow'}

Просмотреть файл

@ -159,13 +159,13 @@ class BuildProcessor:
return source_dict
class CloudBuildCreateOperator(BaseOperator):
class CloudBuildCreateBuildOperator(BaseOperator):
"""
Starts a build with the specified configuration.
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:CloudBuildCreateOperator`
:ref:`howto/operator:CloudBuildCreateBuildOperator`
:param body: The build config with instructions to perform with CloudBuild.
Can be a dictionary or path to a file type like YAML or JSON.

Просмотреть файл

@ -92,13 +92,13 @@ It is also possible to specify it using a YAML or JSON format.
Read `Build Configuration Overview <https://cloud.google.com/cloud-build/docs/build-config>`__ to understand all the fields you can include in a build config file.
.. _howto/operator:CloudBuildCreateOperator:
.. _howto/operator:CloudBuildCreateBuildOperator:
Trigger a build
^^^^^^^^^^^^^^^
Trigger a build is performed with the
:class:`~airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateOperator` operator.
:class:`~airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateBuildOperator` operator.
.. exampleinclude:: ../../../../airflow/providers/google/cloud/example_dags/example_cloud_build.py
:language: python
@ -107,7 +107,7 @@ Trigger a build is performed with the
:end-before: [END howto_operator_create_build_from_storage]
You can use :ref:`Jinja templating <jinja-templating>` with
:template-fields:`airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateOperator`
:template-fields:`airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateBuildOperator`
parameters which allows you to dynamically determine values. The result is saved to :ref:`XCom <concepts:xcom>`, which allows it
to be used by other operators.

Просмотреть файл

@ -27,7 +27,7 @@ from parameterized import parameterized
from airflow.exceptions import AirflowException
from airflow.models import DAG, TaskInstance
from airflow.providers.google.cloud.operators.cloud_build import BuildProcessor, CloudBuildCreateOperator
from airflow.providers.google.cloud.operators.cloud_build import BuildProcessor, CloudBuildCreateBuildOperator
TEST_CREATE_BODY = {
"source": {"storageSource": {"bucket": "cloud-build-examples", "object": "node-docker-example.tar.gz"}},
@ -114,11 +114,11 @@ class TestBuildProcessor(TestCase):
self.assertEqual(body, expected_body)
class TestGcpCloudBuildCreateOperator(TestCase):
class TestGcpCloudBuildCreateBuildOperator(TestCase):
@mock.patch("airflow.providers.google.cloud.operators.cloud_build.CloudBuildHook")
def test_minimal_green_path(self, mock_hook):
mock_hook.return_value.create_build.return_value = TEST_CREATE_BODY
operator = CloudBuildCreateOperator(
operator = CloudBuildCreateBuildOperator(
body=TEST_CREATE_BODY, project_id=TEST_PROJECT_ID, task_id="task-id"
)
result = operator.execute({})
@ -127,7 +127,7 @@ class TestGcpCloudBuildCreateOperator(TestCase):
@parameterized.expand([({},), (None,)])
def test_missing_input(self, body):
with self.assertRaisesRegex(AirflowException, "The required parameter 'body' is missing"):
CloudBuildCreateOperator(body=body, project_id=TEST_PROJECT_ID, task_id="task-id")
CloudBuildCreateBuildOperator(body=body, project_id=TEST_PROJECT_ID, task_id="task-id")
@mock.patch("airflow.providers.google.cloud.operators.cloud_build.CloudBuildHook")
def test_storage_source_replace(self, hook_mock):
@ -145,7 +145,7 @@ class TestGcpCloudBuildCreateOperator(TestCase):
"images": ["gcr.io/$PROJECT_ID/docker-image"],
}
operator = CloudBuildCreateOperator(
operator = CloudBuildCreateBuildOperator(
body=current_body, project_id=TEST_PROJECT_ID, task_id="task-id"
)
operator.execute({})
@ -181,7 +181,7 @@ class TestGcpCloudBuildCreateOperator(TestCase):
],
"images": ["gcr.io/$PROJECT_ID/docker-image"],
}
operator = CloudBuildCreateOperator(
operator = CloudBuildCreateBuildOperator(
body=current_body, project_id=TEST_PROJECT_ID, task_id="task-id"
)
@ -219,7 +219,7 @@ class TestGcpCloudBuildCreateOperator(TestCase):
""")
build.seek(0)
body_path = build.name
operator = CloudBuildCreateOperator(
operator = CloudBuildCreateBuildOperator(
body=body_path,
task_id="task-id", dag=dag,
params={'name': 'airflow'}

Просмотреть файл

@ -474,7 +474,7 @@ OPERATOR = [
"airflow.contrib.operators.gcp_bigtable_operator.BigtableTableDeleteOperator",
),
(
"airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateOperator",
"airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateBuildOperator",
"airflow.contrib.operators.gcp_cloud_build_operator.CloudBuildCreateBuildOperator",
),
(