diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3487659101c8..f82f2b5ba91f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ repos: ).?$ - repo: https://github.com/csachs/pyproject-flake8 - rev: v0.0.1a2.post1 + rev: v6.0.0 hooks: - id: pyproject-flake8 args: ["--config", "pyproject.toml"] diff --git a/octavia-cli/integration_tests/configurations/connections/poke_to_pg/configuration.yaml b/octavia-cli/integration_tests/configurations/connections/poke_to_pg/configuration.yaml index 1e343e606fb6..6240fadd1047 100644 --- a/octavia-cli/integration_tests/configurations/connections/poke_to_pg/configuration.yaml +++ b/octavia-cli/integration_tests/configurations/connections/poke_to_pg/configuration.yaml @@ -7,6 +7,7 @@ destination_configuration_path: TO_UPDATE_FROM_TEST # EDIT THE CONFIGURATION BELOW! configuration: status: active # REQUIRED | string | Allowed values: active, inactive, deprecated + skip_reset: false # OPTIONAL | boolean | Flag to check if the connection should be reset after a connection update namespace_definition: source # OPTIONAL | string | Allowed values: source, destination, customformat namespace_format: "${SOURCE_NAMESPACE}" # OPTIONAL | string | Used when namespaceDefinition is 'customformat'. If blank then behaves like namespaceDefinition = 'destination'. If "${SOURCE_NAMESPACE}" then behaves like namespaceDefinition = 'source'. prefix: "" # REQUIRED | Prefix that will be prepended to the name of each stream when it is written to the destination diff --git a/octavia-cli/integration_tests/test_generate/expected_rendered_yaml/connection/expected_with_normalization.yaml b/octavia-cli/integration_tests/test_generate/expected_rendered_yaml/connection/expected_with_normalization.yaml index 2ec8abc12173..ceeddbc1c8de 100644 --- a/octavia-cli/integration_tests/test_generate/expected_rendered_yaml/connection/expected_with_normalization.yaml +++ b/octavia-cli/integration_tests/test_generate/expected_rendered_yaml/connection/expected_with_normalization.yaml @@ -7,6 +7,7 @@ destination_configuration_path: destination_configuration_path # EDIT THE CONFIGURATION BELOW! configuration: status: active # REQUIRED | string | Allowed values: active, inactive, deprecated + skip_reset: false # OPTIONAL | boolean | Flag to check if the connection should be reset after a connection update namespace_definition: source # OPTIONAL | string | Allowed values: source, destination, customformat namespace_format: "${SOURCE_NAMESPACE}" # OPTIONAL | string | Used when namespaceDefinition is 'customformat'. If blank then behaves like namespaceDefinition = 'destination'. If "${SOURCE_NAMESPACE}" then behaves like namespaceDefinition = 'source'. prefix: "" # REQUIRED | Prefix that will be prepended to the name of each stream when it is written to the destination diff --git a/octavia-cli/integration_tests/test_generate/expected_rendered_yaml/connection/expected_without_normalization.yaml b/octavia-cli/integration_tests/test_generate/expected_rendered_yaml/connection/expected_without_normalization.yaml index 6cfe86d70e46..ebe43dbccbef 100644 --- a/octavia-cli/integration_tests/test_generate/expected_rendered_yaml/connection/expected_without_normalization.yaml +++ b/octavia-cli/integration_tests/test_generate/expected_rendered_yaml/connection/expected_without_normalization.yaml @@ -7,6 +7,7 @@ destination_configuration_path: destination_configuration_path # EDIT THE CONFIGURATION BELOW! configuration: status: active # REQUIRED | string | Allowed values: active, inactive, deprecated + skip_reset: false # OPTIONAL | boolean | Flag to check if the connection should be reset after a connection update namespace_definition: source # OPTIONAL | string | Allowed values: source, destination, customformat namespace_format: "${SOURCE_NAMESPACE}" # OPTIONAL | string | Used when namespaceDefinition is 'customformat'. If blank then behaves like namespaceDefinition = 'destination'. If "${SOURCE_NAMESPACE}" then behaves like namespaceDefinition = 'source'. prefix: "" # REQUIRED | Prefix that will be prepended to the name of each stream when it is written to the destination diff --git a/octavia-cli/octavia_cli/apply/resources.py b/octavia-cli/octavia_cli/apply/resources.py index da60f0008b44..7425ac61d0f9 100644 --- a/octavia-cli/octavia_cli/apply/resources.py +++ b/octavia-cli/octavia_cli/apply/resources.py @@ -569,6 +569,10 @@ class Connection(BaseResource): resource_type = "connection" + local_root_level_keys_to_remove_during_create = ["skip_reset"] # Remove these keys when sending a create request + + local_root_level_keys_to_filter_out_for_comparison = ["skip_reset"] # Remote do not have these keys + remote_root_level_keys_to_filter_out_for_comparison = [ "name", "source", @@ -667,6 +671,8 @@ def create_payload(self) -> WebBackendConnectionCreate: self.configuration["operations"] = self._deserialize_operations( self.raw_configuration["configuration"]["operations"], OperationCreate ) + for k in self.local_root_level_keys_to_remove_during_create: + self.configuration.pop(k, None) return WebBackendConnectionCreate( name=self.resource_name, source_id=self.source_id, destination_id=self.destination_id, **self.configuration ) @@ -794,6 +800,14 @@ def _check_for_legacy_raw_configuration_keys(self, raw_configuration): "These keys changed to source_configuration_path and destination_configuration_path in version > 0.39.18, please update your connection configuration to give path to source and destination configuration files or regenerate the connection", ) + def _get_local_comparable_configuration(self) -> dict: + comparable = { + k: v + for k, v in self.raw_configuration["configuration"].items() + if k not in self.local_root_level_keys_to_filter_out_for_comparison + } + return comparable + def _get_remote_comparable_configuration(self) -> dict: comparable = { diff --git a/octavia-cli/octavia_cli/generate/templates/connection.yaml.j2 b/octavia-cli/octavia_cli/generate/templates/connection.yaml.j2 index 58b36cba53cd..510083944e91 100644 --- a/octavia-cli/octavia_cli/generate/templates/connection.yaml.j2 +++ b/octavia-cli/octavia_cli/generate/templates/connection.yaml.j2 @@ -7,6 +7,7 @@ destination_configuration_path: {{ destination_configuration_path }} # EDIT THE CONFIGURATION BELOW! configuration: status: active # REQUIRED | string | Allowed values: active, inactive, deprecated + skip_reset: false # OPTIONAL | boolean | Flag to check if the connection should be reset after a connection update namespace_definition: source # OPTIONAL | string | Allowed values: source, destination, customformat namespace_format: "${SOURCE_NAMESPACE}" # OPTIONAL | string | Used when namespaceDefinition is 'customformat'. If blank then behaves like namespaceDefinition = 'destination'. If "${SOURCE_NAMESPACE}" then behaves like namespaceDefinition = 'source'. prefix: "" # REQUIRED | Prefix that will be prepended to the name of each stream when it is written to the destination