Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,13 @@ def get_custom_ca_trust_certificates(self) -> Union[List[bytes], None]:
:return: List[str] or None
"""
custom_ca_certs_file_path = self.raw_param.get("custom_ca_trust_certificates")
if not custom_ca_certs_file_path:
if custom_ca_certs_file_path is None:
return None
# Reject empty string - user must provide a valid file path
if custom_ca_certs_file_path == "":
raise InvalidArgumentValueError(
"custom_ca_trust_certificates cannot be an empty string. Please provide a valid file path."
)
if not os.path.isfile(custom_ca_certs_file_path):
raise InvalidArgumentValueError(
"{} is not valid file, or not accessible.".format(
Expand Down Expand Up @@ -8710,11 +8715,13 @@ def update_custom_ca_trust_certificates(self, mc: ManagedCluster) -> ManagedClus
"""
self._ensure_mc(mc)

ca_certs = self.context.get_custom_ca_trust_certificates()
if ca_certs:
# Check if the parameter was explicitly provided
if self.context.raw_param.get("custom_ca_trust_certificates") is not None:
ca_certs = self.context.get_custom_ca_trust_certificates()
Comment on lines +8719 to +8720
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's a good idea to allow this option to accept an empty string as a value, and that would also remove the existing certificates. But there might be a chance user is doing so by mistake (compared to provided an emtpy file)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified this to block when empty string is passed

if mc.security_profile is None:
mc.security_profile = self.models.ManagedClusterSecurityProfile() # pylint: disable=no-member

# Set certificates (this allows setting to empty list to remove certificates)
mc.security_profile.custom_ca_trust_certificates = ca_certs
Comment thread
UtheMan marked this conversation as resolved.

return mc
Expand Down
Loading