qontract-reconcile 0.10.1rc744__py3-none-any.whl → 0.10.1rc746__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qontract-reconcile
3
- Version: 0.10.1rc744
3
+ Version: 0.10.1rc746
4
4
  Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
5
5
  Home-page: https://github.com/app-sre/qontract-reconcile
6
6
  Author: Red Hat App-SRE Team
@@ -112,10 +112,10 @@ reconcile/terraform_aws_route53.py,sha256=R8eZHlvP368nvtmLd_cMSK3RGxD7jso9qE7NP9
112
112
  reconcile/terraform_cloudflare_dns.py,sha256=auU4bzeLwd4S8D8oqpqJbrCUoEdELXrgi7vHOedjYFk,13332
113
113
  reconcile/terraform_cloudflare_resources.py,sha256=EbQQaoDnZ7brvRCpbFtwlD7KLk2hDVNcjhrJGaAywEk,15023
114
114
  reconcile/terraform_cloudflare_users.py,sha256=1EbTHwJgiPkJpMP-Ag340QNgGK3mXn3dcC3DpLakudM,13987
115
- reconcile/terraform_repo.py,sha256=c0GZFuY3rCm6VHjHqYbsgOHrEkRWKF_1LrMThsn2XDw,16127
115
+ reconcile/terraform_repo.py,sha256=tQkMUEDEB6QfuWYwiW7H-NnX4SHxYK7mLZYZffKj-hE,16301
116
116
  reconcile/terraform_resources.py,sha256=BN8XuJwjOt1ztruEAHydkd0YiBlb3fHZ7n0snZtRhck,19356
117
117
  reconcile/terraform_tgw_attachments.py,sha256=k9Lf0ST65gmI6aUV6HnvxSGcKL7MGx_lN22OXuRGH9Y,16224
118
- reconcile/terraform_users.py,sha256=L921n4bD6-XbJeiiMKUI3quRacIkHlFEyvpi5Dcli_8,10374
118
+ reconcile/terraform_users.py,sha256=9rgbM572LfmOSnV3uCP20G_Cw6T7due94g8rhhiz904,10225
119
119
  reconcile/terraform_vpc_peerings.py,sha256=rnDH1u93OyzrBM8Hib0HwSnlxZtx4ScRQaZAcn3mx-k,25402
120
120
  reconcile/vault_replication.py,sha256=79GZ_kCimPoQcxkdhkWTQxPOAa46E0mNhf05s_Mk5so,17385
121
121
  reconcile/vpc_peerings_validator.py,sha256=Kv22HJVlTW9l9GB2eXwjPWqdDbr_VuvQBNPttox6s5o,7177
@@ -300,6 +300,7 @@ reconcile/gql_definitions/membershipsources/roles.py,sha256=d3nv3GLsj_eKgwB1glsi
300
300
  reconcile/gql_definitions/ocm_labels/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
301
301
  reconcile/gql_definitions/ocm_labels/clusters.py,sha256=MIVR5c8JxEOjsdGNpB737QyHGkjmHCycY6MAYNclPck,2916
302
302
  reconcile/gql_definitions/ocm_labels/organizations.py,sha256=mmYB5C5Fp_nPzwBDKdKG4qWiLre2VkZ26U_2O-jRKC4,2001
303
+ reconcile/gql_definitions/ocm_oidc_idp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
303
304
  reconcile/gql_definitions/ocm_subscription_labels/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
304
305
  reconcile/gql_definitions/openshift_cluster_bots/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
305
306
  reconcile/gql_definitions/openshift_cluster_bots/clusters.py,sha256=68meUg2Wgh91gplbPHAIlRWjnGg2RDrwtWd93QK6qRE,3672
@@ -345,7 +346,7 @@ reconcile/gql_definitions/terraform_cloudflare_users/terraform_cloudflare_roles.
345
346
  reconcile/gql_definitions/terraform_init/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
346
347
  reconcile/gql_definitions/terraform_init/aws_accounts.py,sha256=OJ0hDbRachRaDkL-OGT6-byr9cKdBiQDnNCpwUe3oJ8,2674
347
348
  reconcile/gql_definitions/terraform_repo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
348
- reconcile/gql_definitions/terraform_repo/terraform_repo.py,sha256=pefTRhb0ZcWm_j6dYz6m6qNqZFteqgrQ25SgUqRAVaI,3173
349
+ reconcile/gql_definitions/terraform_repo/terraform_repo.py,sha256=_rdq3efy5Q3QFpI-vcs3-wacsXo_1fu1kVix_E83h5Q,3599
349
350
  reconcile/gql_definitions/terraform_resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
350
351
  reconcile/gql_definitions/terraform_resources/database_access_manager.py,sha256=yv0_YC-LmhaKD_gyGG3le1w5BtypBjlsO894-Zgdg4U,4813
351
352
  reconcile/gql_definitions/terraform_resources/terraform_resources_namespaces.py,sha256=ElJTVH2cwNqJiLFl3Zi5zt9y7dN0yLmdtmwZC5X7ir0,42189
@@ -501,10 +502,10 @@ reconcile/test/test_terraform_aws_route53.py,sha256=xHggb8K1P76OyCfFcogbkmyKle-N
501
502
  reconcile/test/test_terraform_cloudflare_dns.py,sha256=aQTXX8Vr4h9aWvJZTnpZEhMGYoBpT2d45ZxU_ECIQ6o,3425
502
503
  reconcile/test/test_terraform_cloudflare_resources.py,sha256=NK_uktyWihkQ3gMN4bCaKerpi43CXAVYGIKTfcz05rY,13550
503
504
  reconcile/test/test_terraform_cloudflare_users.py,sha256=RAFtMMdqZha3jNnNNsqbNQQUDSqUzdoM63rCw7fs4Fo,27456
504
- reconcile/test/test_terraform_repo.py,sha256=soKFJfF8tWIimDs39RQl3Hnh-Od-bR4PfnEA2s1UprM,11552
505
+ reconcile/test/test_terraform_repo.py,sha256=HTr8HMtLgecBTxKYbRAQFSty7tGzeKsv_fxtOAbDlNA,12184
505
506
  reconcile/test/test_terraform_resources.py,sha256=EFCqPI5_G8hPRh1zmnU91o8wMeT2qK1CabDUa_X1rSk,15283
506
507
  reconcile/test/test_terraform_tgw_attachments.py,sha256=cAq6exc-K-jtLla1CZUZQzVnBkyDnIlL7jybnddhLKc,36861
507
- reconcile/test/test_terraform_users.py,sha256=Xn4y6EcxnNQb6XcPoOhz_Ikxmh9Nrsu88OM1scN9hzY,5434
508
+ reconcile/test/test_terraform_users.py,sha256=XOAfGvITCJPI1LTlISmHbA4ONMQMkxYUMTsny7pQCFw,4319
508
509
  reconcile/test/test_terraform_vpc_peerings.py,sha256=ubcsKh0TrUIwuI1-W3ETIgzsFvzAyeoFmEJFC-IK6JY,20538
509
510
  reconcile/test/test_terraform_vpc_peerings_build_desired_state.py,sha256=DAfpb12I0PlqnuVUHK2vh4LH4d1OylT3H2GE_3TGZZI,47852
510
511
  reconcile/test/test_three_way_diff_strategy.py,sha256=2fjEqE2w4pIzKq18PRcADTSe01aGwsZfMGloU8xfNaE,3346
@@ -777,8 +778,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
777
778
  tools/test/test_qontract_cli.py,sha256=w2l4BHB09k1d-BGJ1jBUNCqDv7zkqYrMHojQXg-21kQ,4155
778
779
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
779
780
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
780
- qontract_reconcile-0.10.1rc744.dist-info/METADATA,sha256=sIbstE_GcpNpldwcIVZDvFWxsYWgttSR6hyw9KGJai4,2382
781
- qontract_reconcile-0.10.1rc744.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
782
- qontract_reconcile-0.10.1rc744.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
783
- qontract_reconcile-0.10.1rc744.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
784
- qontract_reconcile-0.10.1rc744.dist-info/RECORD,,
781
+ qontract_reconcile-0.10.1rc746.dist-info/METADATA,sha256=wZTYzj2gWnkTP279SxzH3p9fBGaVQk9mId5meD83nUQ,2382
782
+ qontract_reconcile-0.10.1rc746.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
783
+ qontract_reconcile-0.10.1rc746.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
784
+ qontract_reconcile-0.10.1rc746.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
785
+ qontract_reconcile-0.10.1rc746.dist-info/RECORD,,
File without changes
@@ -52,6 +52,15 @@ query TerraformRepo {
52
52
  projectPath
53
53
  delete
54
54
  requireFips
55
+ tfVersion
56
+ variables {
57
+ inputs {
58
+ ...VaultSecret
59
+ }
60
+ outputs {
61
+ ...VaultSecret
62
+ }
63
+ }
55
64
  }
56
65
  }
57
66
  """
@@ -82,6 +91,11 @@ class AWSAccountV1(ConfiguredBaseModel):
82
91
  terraform_state: Optional[TerraformStateAWSV1] = Field(..., alias="terraformState")
83
92
 
84
93
 
94
+ class TerraformRepoVariablesV1(ConfiguredBaseModel):
95
+ inputs: VaultSecret = Field(..., alias="inputs")
96
+ outputs: VaultSecret = Field(..., alias="outputs")
97
+
98
+
85
99
  class TerraformRepoV1(ConfiguredBaseModel):
86
100
  account: AWSAccountV1 = Field(..., alias="account")
87
101
  name: str = Field(..., alias="name")
@@ -90,6 +104,8 @@ class TerraformRepoV1(ConfiguredBaseModel):
90
104
  project_path: str = Field(..., alias="projectPath")
91
105
  delete: Optional[bool] = Field(..., alias="delete")
92
106
  require_fips: Optional[bool] = Field(..., alias="requireFips")
107
+ tf_version: str = Field(..., alias="tfVersion")
108
+ variables: Optional[TerraformRepoVariablesV1] = Field(..., alias="variables")
93
109
 
94
110
 
95
111
  class TerraformRepoQueryData(ConfiguredBaseModel):
@@ -12,8 +12,10 @@ from pydantic import (
12
12
  )
13
13
 
14
14
  from reconcile import queries
15
+ from reconcile.gql_definitions.fragments.vault_secret import VaultSecret
15
16
  from reconcile.gql_definitions.terraform_repo.terraform_repo import (
16
17
  TerraformRepoV1,
18
+ TerraformRepoVariablesV1,
17
19
  query,
18
20
  )
19
21
  from reconcile.utils import gql
@@ -35,22 +37,19 @@ from reconcile.utils.state import (
35
37
  )
36
38
 
37
39
 
38
- class RepoSecret(BaseModel):
39
- path: str
40
- version: Optional[int]
41
-
42
-
43
40
  class RepoOutput(BaseModel):
44
41
  repository: str
45
42
  name: str
46
43
  ref: str
47
44
  project_path: str
48
45
  delete: bool
49
- secret: RepoSecret
46
+ aws_creds: VaultSecret
47
+ variables: Optional[TerraformRepoVariablesV1]
50
48
  bucket: Optional[str]
51
49
  region: Optional[str]
52
50
  bucket_path: Optional[str]
53
51
  require_fips: bool
52
+ tf_version: str
54
53
 
55
54
 
56
55
  class OutputFile(BaseModel):
@@ -126,13 +125,16 @@ class TerraformRepoIntegration(
126
125
  recreate_state=True,
127
126
  )
128
127
 
129
- def print_output(self, diff: list[TerraformRepoV1], dry_run: bool) -> None:
128
+ def print_output(self, diff: list[TerraformRepoV1], dry_run: bool) -> OutputFile:
130
129
  """Parses and prints the output of a Terraform Repo diff for the executor
131
130
 
132
131
  :param diff: list of terraform repos to be acted on
133
132
  :type diff: list[TerraformRepoV1]
134
133
  :param dry_run: whether the executor should perform a tf apply
135
134
  :type dry_run: bool
135
+
136
+ :return: output of diff (used for testing)
137
+ :rtype: OutputFile
136
138
  """
137
139
  actions_list: list[RepoOutput] = []
138
140
 
@@ -144,10 +146,9 @@ class TerraformRepoIntegration(
144
146
  project_path=repo.project_path,
145
147
  delete=repo.delete or False,
146
148
  require_fips=repo.require_fips or False,
147
- secret=RepoSecret(
148
- path=repo.account.automation_token.path,
149
- version=repo.account.automation_token.version,
150
- ),
149
+ tf_version=repo.tf_version,
150
+ aws_creds=repo.account.automation_token,
151
+ variables=repo.variables,
151
152
  )
152
153
  # terraform-repo will store its statefiles in a specified directory if there is a
153
154
  # terraform-state yaml file associated with the AWS account and a configuration is
@@ -179,6 +180,8 @@ class TerraformRepoIntegration(
179
180
  else:
180
181
  print(yaml.safe_dump(data=output.dict(), explicit_start=True))
181
182
 
183
+ return output
184
+
182
185
  def get_repos(self, query_func: Callable) -> list[TerraformRepoV1]:
183
186
  """Gets a list of terraform repos defined in App Interface
184
187
 
@@ -1,4 +1,3 @@
1
- import logging
2
1
  import sys
3
2
  from textwrap import indent
4
3
  from typing import (
@@ -113,11 +112,12 @@ def setup(
113
112
  appsre_pgp_key: Optional[str] = None,
114
113
  account_name: Optional[str] = None,
115
114
  ) -> tuple[list[dict[str, Any]], dict[str, str], bool, AWSApi]:
116
- accounts = queries.get_aws_accounts(terraform_state=True)
117
- if account_name:
118
- accounts = [n for n in accounts if n["name"] == account_name]
119
- if not accounts:
120
- raise ValueError(f"aws account {account_name} is not found")
115
+ accounts = [
116
+ a
117
+ for a in queries.get_aws_accounts(terraform_state=True)
118
+ if integration_is_enabled(QONTRACT_INTEGRATION.replace("_", "-"), a)
119
+ and (not account_name or a["name"] == account_name)
120
+ ]
121
121
  roles = get_tf_roles()
122
122
  participating_aws_accounts = _filter_participating_aws_accounts(accounts, roles)
123
123
 
@@ -253,9 +253,7 @@ def run(
253
253
  )
254
254
 
255
255
  if not accounts:
256
- logging.warning(
257
- f"No participating AWS accounts found, consider disabling this integration, account name: {account_name}"
258
- )
256
+ # no enabled accounts found
259
257
  return
260
258
 
261
259
  if print_to_file:
@@ -1,7 +1,6 @@
1
1
  from unittest.mock import MagicMock
2
2
 
3
3
  import pytest
4
- import yaml
5
4
 
6
5
  from reconcile.gql_definitions.fragments.terraform_state import (
7
6
  AWSTerraformStateIntegrationsV1,
@@ -10,9 +9,12 @@ from reconcile.gql_definitions.fragments.vault_secret import VaultSecret
10
9
  from reconcile.gql_definitions.terraform_repo.terraform_repo import (
11
10
  AWSAccountV1,
12
11
  TerraformRepoV1,
12
+ TerraformRepoVariablesV1,
13
13
  TerraformStateAWSV1,
14
14
  )
15
15
  from reconcile.terraform_repo import (
16
+ OutputFile,
17
+ RepoOutput,
16
18
  TerraformRepoIntegration,
17
19
  TerraformRepoIntegrationParams,
18
20
  )
@@ -21,8 +23,10 @@ from reconcile.utils.state import State
21
23
 
22
24
  A_REPO = "https://git-example/tf-repo-example"
23
25
  A_REPO_SHA = "a390f5cb20322c90861d6d80e9b70c6a579be1d0"
26
+ A_REPO_VERSION = "1.4.5"
24
27
  B_REPO = "https://git-example/tf-repo-example2"
25
28
  B_REPO_SHA = "94edb90815e502b387c25358f5ec602e52d0bfbb"
29
+ B_REPO_VERSION = "1.5.7"
26
30
  AWS_UID = "000000000000"
27
31
  AUTOMATION_TOKEN_PATH = "aws-secrets/terraform/foo"
28
32
  STATE_REGION = "us-east-1"
@@ -31,7 +35,7 @@ STATE_PROVIDER = "s3"
31
35
 
32
36
 
33
37
  @pytest.fixture
34
- def existing_repo(aws_account) -> TerraformRepoV1:
38
+ def existing_repo(aws_account, tf_variables) -> TerraformRepoV1:
35
39
  return TerraformRepoV1(
36
40
  name="a_repo",
37
41
  repository=A_REPO,
@@ -40,27 +44,34 @@ def existing_repo(aws_account) -> TerraformRepoV1:
40
44
  projectPath="tf",
41
45
  delete=False,
42
46
  requireFips=True,
47
+ tfVersion=A_REPO_VERSION,
48
+ variables=tf_variables,
43
49
  )
44
50
 
45
51
 
46
52
  @pytest.fixture
47
- def existing_repo_output() -> str:
48
- return f"""
49
- dry_run: true
50
- repos:
51
- - repository: {A_REPO}
52
- name: a_repo
53
- ref: {A_REPO_SHA}
54
- project_path: tf
55
- delete: false
56
- secret:
57
- path: {AUTOMATION_TOKEN_PATH}
58
- version: 1
59
- bucket: {STATE_BUCKET}
60
- region: {STATE_REGION}
61
- bucket_path: tf-repo
62
- require_fips: true
63
- """
53
+ def existing_repo_output(tf_variables) -> OutputFile:
54
+ return OutputFile(
55
+ dry_run=True,
56
+ repos=[
57
+ RepoOutput(
58
+ repository=A_REPO,
59
+ name="a_repo",
60
+ ref=A_REPO_SHA,
61
+ project_path="tf",
62
+ delete=False,
63
+ aws_creds=VaultSecret(
64
+ path=AUTOMATION_TOKEN_PATH, version=1, field="all", format=None
65
+ ),
66
+ bucket=STATE_BUCKET,
67
+ region=STATE_REGION,
68
+ bucket_path="tf-repo",
69
+ require_fips=True,
70
+ tf_version=A_REPO_VERSION,
71
+ variables=tf_variables,
72
+ )
73
+ ],
74
+ )
64
75
 
65
76
 
66
77
  @pytest.fixture
@@ -73,27 +84,34 @@ def new_repo(aws_account_no_state) -> TerraformRepoV1:
73
84
  projectPath="tf",
74
85
  delete=False,
75
86
  requireFips=False,
87
+ tfVersion=B_REPO_VERSION,
88
+ variables=None,
76
89
  )
77
90
 
78
91
 
79
92
  @pytest.fixture
80
- def new_repo_output() -> str:
81
- return f"""
82
- dry_run: true
83
- repos:
84
- - repository: {B_REPO}
85
- name: b_repo
86
- ref: {B_REPO_SHA}
87
- project_path: tf
88
- delete: false
89
- secret:
90
- path: {AUTOMATION_TOKEN_PATH}
91
- version: 1
92
- bucket: null
93
- region: null
94
- bucket_path: null
95
- require_fips: false
96
- """
93
+ def new_repo_output() -> OutputFile:
94
+ return OutputFile(
95
+ dry_run=True,
96
+ repos=[
97
+ RepoOutput(
98
+ repository=B_REPO,
99
+ name="b_repo",
100
+ ref=B_REPO_SHA,
101
+ project_path="tf",
102
+ delete=False,
103
+ aws_creds=VaultSecret(
104
+ path=AUTOMATION_TOKEN_PATH, version=1, field="all", format=None
105
+ ),
106
+ bucket=None,
107
+ region=None,
108
+ bucket_path=None,
109
+ require_fips=False,
110
+ tf_version=B_REPO_VERSION,
111
+ variables=None,
112
+ )
113
+ ],
114
+ )
97
115
 
98
116
 
99
117
  @pytest.fixture()
@@ -101,6 +119,18 @@ def automation_token() -> VaultSecret:
101
119
  return VaultSecret(path=AUTOMATION_TOKEN_PATH, version=1, field="all", format=None)
102
120
 
103
121
 
122
+ @pytest.fixture()
123
+ def tf_variables() -> TerraformRepoVariablesV1:
124
+ return TerraformRepoVariablesV1(
125
+ inputs=VaultSecret(
126
+ path="terraform-repo/inputs/abc", field="all", version=2, format=None
127
+ ),
128
+ outputs=VaultSecret(
129
+ path="terraform-repo/outputs/abc", field="all", version=2, format=None
130
+ ),
131
+ )
132
+
133
+
104
134
  @pytest.fixture()
105
135
  def terraform_state(terraform_state_integrations) -> TerraformStateAWSV1:
106
136
  return TerraformStateAWSV1(
@@ -143,13 +173,6 @@ def int_params() -> TerraformRepoIntegrationParams:
143
173
  return TerraformRepoIntegrationParams(output_file=None, validate_git=False)
144
174
 
145
175
 
146
- @pytest.fixture
147
- def int_params_print_to_tmp(tmp_path) -> TerraformRepoIntegrationParams:
148
- return TerraformRepoIntegrationParams(
149
- output_file=f"{tmp_path}/tf-repo.yaml", validate_git=False
150
- )
151
-
152
-
153
176
  @pytest.fixture()
154
177
  def state_mock() -> MagicMock:
155
178
  return MagicMock(spec=State)
@@ -253,7 +276,7 @@ def test_delete_repo_without_flag(existing_repo, int_params):
253
276
  )
254
277
 
255
278
 
256
- def test_get_repo_state(s3_state_builder, int_params, existing_repo):
279
+ def test_get_repo_state(s3_state_builder, int_params, existing_repo, tf_variables):
257
280
  state = s3_state_builder({
258
281
  "ls": [
259
282
  "/a_repo",
@@ -266,6 +289,8 @@ def test_get_repo_state(s3_state_builder, int_params, existing_repo):
266
289
  "projectPath": "tf",
267
290
  "delete": False,
268
291
  "requireFips": True,
292
+ "tfVersion": A_REPO_VERSION,
293
+ "variables": tf_variables,
269
294
  "account": {
270
295
  "name": "foo",
271
296
  "uid": AWS_UID,
@@ -319,15 +344,13 @@ def test_update_repo_state(int_params, existing_repo, state_mock):
319
344
  # these two output tests are to ensure that there isn't a sudden change to outputs that throws
320
345
  # off tf-executor
321
346
  def test_output_correct_statefile(
322
- int_params_print_to_tmp, existing_repo, existing_repo_output, tmp_path, state_mock
347
+ int_params, existing_repo, existing_repo_output, state_mock
323
348
  ):
324
- integration = TerraformRepoIntegration(params=int_params_print_to_tmp)
349
+ integration = TerraformRepoIntegration(params=int_params)
325
350
 
326
351
  existing_state: list = []
327
352
  desired_state = [existing_repo]
328
353
 
329
- expected_output = yaml.safe_load(existing_repo_output)
330
-
331
354
  diff = integration.calculate_diff(
332
355
  existing_state=existing_state,
333
356
  desired_state=desired_state,
@@ -337,24 +360,19 @@ def test_output_correct_statefile(
337
360
  )
338
361
 
339
362
  assert diff
340
- integration.print_output(diff, True)
341
-
342
- with open(f"{tmp_path}/tf-repo.yaml", "r", encoding="locale") as output:
343
- yaml_rep = yaml.safe_load(output)
363
+ current_output = integration.print_output(diff, True)
344
364
 
345
- assert expected_output == yaml_rep
365
+ assert existing_repo_output == current_output
346
366
 
347
367
 
348
368
  def test_output_correct_no_statefile(
349
- int_params_print_to_tmp, new_repo, new_repo_output, tmp_path, state_mock
369
+ int_params, new_repo, new_repo_output, tmp_path, state_mock
350
370
  ):
351
- integration = TerraformRepoIntegration(params=int_params_print_to_tmp)
371
+ integration = TerraformRepoIntegration(params=int_params)
352
372
 
353
373
  existing_state: list = []
354
374
  desired_state = [new_repo]
355
375
 
356
- expected_output = yaml.safe_load(new_repo_output)
357
-
358
376
  diff = integration.calculate_diff(
359
377
  existing_state=existing_state,
360
378
  desired_state=desired_state,
@@ -364,12 +382,9 @@ def test_output_correct_no_statefile(
364
382
  )
365
383
 
366
384
  assert diff
367
- integration.print_output(diff, True)
368
-
369
- with open(f"{tmp_path}/tf-repo.yaml", "r", encoding="locale") as output:
370
- yaml_rep = yaml.safe_load(output)
385
+ current_output = integration.print_output(diff, True)
371
386
 
372
- assert expected_output == yaml_rep
387
+ assert new_repo_output == current_output
373
388
 
374
389
 
375
390
  def test_fail_on_multiple_repos_dry_run(int_params, existing_repo, new_repo):
@@ -150,29 +150,3 @@ def test_setup(
150
150
  settings=None,
151
151
  init_users=False,
152
152
  )
153
-
154
-
155
- def test_empty_run(
156
- mocker: MockerFixture,
157
- pgp_reencryption_settings: PgpReencryptionSettingsQueryData,
158
- test_aws_account: dict,
159
- gql_api_builder: Callable[..., GqlApi],
160
- ) -> None:
161
- mocked_gql_api = gql_api_builder({"roles": []})
162
- mocker.patch("reconcile.terraform_users.gql").get_api.return_value = mocked_gql_api
163
- mocker.patch(
164
- "reconcile.terraform_users.query"
165
- ).return_value = pgp_reencryption_settings
166
- mocker.patch("reconcile.terraform_users.sys")
167
- mocked_queries = mocker.patch("reconcile.terraform_users.queries")
168
- mocked_queries.get_aws_accounts.return_value = [test_aws_account]
169
- mocked_queries.get_app_interface_settings.return_value = None
170
- mocker.patch("reconcile.terraform_users.Terrascript", autospec=True)
171
- mocker.patch("reconcile.terraform_users.AWSApi", autospec=True)
172
- mocked_logging = mocker.patch("reconcile.terraform_users.logging")
173
-
174
- integ.run(False, send_mails=False)
175
-
176
- mocked_logging.warning.assert_called_once_with(
177
- "No participating AWS accounts found, consider disabling this integration, account name: None"
178
- )