Skip to content

Commit 1459970

Browse files
authored
Rename CloudBuildCreateBuildOperator to CloudBuildCreateOperator (#9314)
1 parent 2c18a3f commit 1459970

File tree

8 files changed

+21
-34
lines changed

8 files changed

+21
-34
lines changed

β€ŽUPDATING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ The following table shows changes in import paths.
919919
|airflow.contrib.operators.gcp_bigtable_operator.BigtableTableCreateOperator |airflow.providers.google.cloud.operators.bigtable.BigtableCreateTableOperator |
920920
|airflow.contrib.operators.gcp_bigtable_operator.BigtableTableDeleteOperator |airflow.providers.google.cloud.operators.bigtable.BigtableDeleteTableOperator |
921921
|airflow.contrib.operators.gcp_bigtable_operator.BigtableTableWaitForReplicationSensor |airflow.providers.google.cloud.sensors.bigtable.BigtableTableReplicationCompletedSensor |
922-
|airflow.contrib.operators.gcp_cloud_build_operator.CloudBuildCreateBuildOperator |airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateOperator |
922+
|airflow.contrib.operators.gcp_cloud_build_operator.CloudBuildCreateBuildOperator |airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateBuildOperator |
923923
|airflow.contrib.operators.gcp_compute_operator.GceBaseOperator |airflow.providers.google.cloud.operators.compute.GceBaseOperator |
924924
|airflow.contrib.operators.gcp_compute_operator.GceInstanceGroupManagerUpdateTemplateOperator |airflow.providers.google.cloud.operators.compute.GceInstanceGroupManagerUpdateTemplateOperator |
925925
|airflow.contrib.operators.gcp_compute_operator.GceInstanceStartOperator |airflow.providers.google.cloud.operators.compute.GceInstanceStartOperator |

β€Žairflow/contrib/operators/gcp_cloud_build_operator.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,10 @@
1919

2020
import warnings
2121

22-
from airflow.providers.google.cloud.operators.cloud_build import CloudBuildCreateOperator
22+
# pylint: disable=unused-import
23+
from airflow.providers.google.cloud.operators.cloud_build import CloudBuildCreateBuildOperator # noqa
2324

2425
warnings.warn(
2526
"This module is deprecated. Please use `airflow.providers.google.cloud.operators.cloud_build`.",
2627
DeprecationWarning, stacklevel=2
2728
)
28-
29-
30-
class CloudBuildCreateBuildOperator(CloudBuildCreateOperator):
31-
"""
32-
This class is deprecated.
33-
Please use `airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateOperator`.
34-
"""
35-
def __init__(self, *args, **kwargs):
36-
warnings.warn(
37-
"""This class is deprecated.
38-
Please use `airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateOperator`.""",
39-
DeprecationWarning, stacklevel=2
40-
)
41-
super().__init__(*args, **kwargs)

β€Žairflow/providers/google/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ All classes in Airflow 2.0 are in `airflow.providers.google` package.
287287
| [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) |
288288
| [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) |
289289
| [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) |
290-
| [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) |
290+
| [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) |
291291
| [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) |
292292
| [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) |
293293
| [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) |

β€Žairflow/providers/google/cloud/example_dags/example_cloud_build.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
from airflow import models
3737
from airflow.operators.bash import BashOperator
38-
from airflow.providers.google.cloud.operators.cloud_build import CloudBuildCreateOperator
38+
from airflow.providers.google.cloud.operators.cloud_build import CloudBuildCreateBuildOperator
3939
from airflow.utils import dates
4040

4141
GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project")
@@ -81,7 +81,7 @@
8181
tags=['example'],
8282
) as dag:
8383
# [START howto_operator_create_build_from_storage]
84-
create_build_from_storage = CloudBuildCreateOperator(
84+
create_build_from_storage = CloudBuildCreateBuildOperator(
8585
task_id="create_build_from_storage", project_id=GCP_PROJECT_ID, body=create_build_from_storage_body
8686
)
8787
# [END howto_operator_create_build_from_storage]
@@ -93,7 +93,7 @@
9393
)
9494
# [END howto_operator_create_build_from_storage_result]
9595

96-
create_build_from_repo = CloudBuildCreateOperator(
96+
create_build_from_repo = CloudBuildCreateBuildOperator(
9797
task_id="create_build_from_repo", project_id=GCP_PROJECT_ID, body=create_build_from_repo_body
9898
)
9999

@@ -103,7 +103,7 @@
103103
)
104104

105105
# [START howto_operator_gcp_create_build_from_yaml_body]
106-
create_build_from_file = CloudBuildCreateOperator(
106+
create_build_from_file = CloudBuildCreateBuildOperator(
107107
task_id="create_build_from_file", project_id=GCP_PROJECT_ID,
108108
body=str(CURRENT_FOLDER.joinpath('example_cloud_build.yaml')),
109109
params={'name': 'Airflow'}

β€Žairflow/providers/google/cloud/operators/cloud_build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ def _convert_storage_url_to_dict(storage_url: str) -> Dict[str, Any]:
159159
return source_dict
160160

161161

162-
class CloudBuildCreateOperator(BaseOperator):
162+
class CloudBuildCreateBuildOperator(BaseOperator):
163163
"""
164164
Starts a build with the specified configuration.
165165
166166
.. seealso::
167167
For more information on how to use this operator, take a look at the guide:
168-
:ref:`howto/operator:CloudBuildCreateOperator`
168+
:ref:`howto/operator:CloudBuildCreateBuildOperator`
169169
170170
:param body: The build config with instructions to perform with CloudBuild.
171171
Can be a dictionary or path to a file type like YAML or JSON.

β€Ždocs/howto/operator/gcp/cloud_build.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ It is also possible to specify it using a YAML or JSON format.
9292
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.
9393

9494

95-
.. _howto/operator:CloudBuildCreateOperator:
95+
.. _howto/operator:CloudBuildCreateBuildOperator:
9696

9797
Trigger a build
9898
^^^^^^^^^^^^^^^
9999

100100
Trigger a build is performed with the
101-
:class:`~airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateOperator` operator.
101+
:class:`~airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateBuildOperator` operator.
102102

103103
.. exampleinclude:: ../../../../airflow/providers/google/cloud/example_dags/example_cloud_build.py
104104
:language: python
@@ -107,7 +107,7 @@ Trigger a build is performed with the
107107
:end-before: [END howto_operator_create_build_from_storage]
108108

109109
You can use :ref:`Jinja templating <jinja-templating>` with
110-
:template-fields:`airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateOperator`
110+
:template-fields:`airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateBuildOperator`
111111
parameters which allows you to dynamically determine values. The result is saved to :ref:`XCom <concepts:xcom>`, which allows it
112112
to be used by other operators.
113113

β€Žtests/providers/google/cloud/operators/test_cloud_build.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
from airflow.exceptions import AirflowException
2929
from airflow.models import DAG, TaskInstance
30-
from airflow.providers.google.cloud.operators.cloud_build import BuildProcessor, CloudBuildCreateOperator
30+
from airflow.providers.google.cloud.operators.cloud_build import BuildProcessor, CloudBuildCreateBuildOperator
3131

3232
TEST_CREATE_BODY = {
3333
"source": {"storageSource": {"bucket": "cloud-build-examples", "object": "node-docker-example.tar.gz"}},
@@ -114,11 +114,11 @@ def test_do_nothing(self, source_key):
114114
self.assertEqual(body, expected_body)
115115

116116

117-
class TestGcpCloudBuildCreateOperator(TestCase):
117+
class TestGcpCloudBuildCreateBuildOperator(TestCase):
118118
@mock.patch("airflow.providers.google.cloud.operators.cloud_build.CloudBuildHook")
119119
def test_minimal_green_path(self, mock_hook):
120120
mock_hook.return_value.create_build.return_value = TEST_CREATE_BODY
121-
operator = CloudBuildCreateOperator(
121+
operator = CloudBuildCreateBuildOperator(
122122
body=TEST_CREATE_BODY, project_id=TEST_PROJECT_ID, task_id="task-id"
123123
)
124124
result = operator.execute({})
@@ -127,7 +127,7 @@ def test_minimal_green_path(self, mock_hook):
127127
@parameterized.expand([({},), (None,)])
128128
def test_missing_input(self, body):
129129
with self.assertRaisesRegex(AirflowException, "The required parameter 'body' is missing"):
130-
CloudBuildCreateOperator(body=body, project_id=TEST_PROJECT_ID, task_id="task-id")
130+
CloudBuildCreateBuildOperator(body=body, project_id=TEST_PROJECT_ID, task_id="task-id")
131131

132132
@mock.patch("airflow.providers.google.cloud.operators.cloud_build.CloudBuildHook")
133133
def test_storage_source_replace(self, hook_mock):
@@ -145,7 +145,7 @@ def test_storage_source_replace(self, hook_mock):
145145
"images": ["gcr.io/$PROJECT_ID/docker-image"],
146146
}
147147

148-
operator = CloudBuildCreateOperator(
148+
operator = CloudBuildCreateBuildOperator(
149149
body=current_body, project_id=TEST_PROJECT_ID, task_id="task-id"
150150
)
151151
operator.execute({})
@@ -181,7 +181,7 @@ def test_repo_source_replace(self, hook_mock):
181181
],
182182
"images": ["gcr.io/$PROJECT_ID/docker-image"],
183183
}
184-
operator = CloudBuildCreateOperator(
184+
operator = CloudBuildCreateBuildOperator(
185185
body=current_body, project_id=TEST_PROJECT_ID, task_id="task-id"
186186
)
187187

@@ -219,7 +219,7 @@ def test_load_templated_yaml(self):
219219
""")
220220
build.seek(0)
221221
body_path = build.name
222-
operator = CloudBuildCreateOperator(
222+
operator = CloudBuildCreateBuildOperator(
223223
body=body_path,
224224
task_id="task-id", dag=dag,
225225
params={'name': 'airflow'}

β€Žtests/test_core_to_contrib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@
474474
"airflow.contrib.operators.gcp_bigtable_operator.BigtableTableDeleteOperator",
475475
),
476476
(
477-
"airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateOperator",
477+
"airflow.providers.google.cloud.operators.cloud_build.CloudBuildCreateBuildOperator",
478478
"airflow.contrib.operators.gcp_cloud_build_operator.CloudBuildCreateBuildOperator",
479479
),
480480
(

0 commit comments

Comments
 (0)