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
10 changes: 10 additions & 0 deletions docs.openc3.com/docs/getting-started/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,16 @@ The following target configuration keywords are silently ignored during parsing
- **`CMD_DECOM_RETAIN_TIME`** — Sets the retention time for command decommutation data in QuestDB. Accepts a time value with a unit suffix: `h` (hours), `d` (days), `w` (weeks), `M` (months), or `y` (years). Example: `CMD_DECOM_RETAIN_TIME 30d`
- **`TLM_DECOM_RETAIN_TIME`** — Sets the retention time for telemetry decommutation data in QuestDB. Same format as above. Example: `TLM_DECOM_RETAIN_TIME 1y`

### COSMOS API Changes

#### Python `Secrets.getClient()` renamed to `Secrets.get_client()`

COSMOS 7.0 renamed the Python `Secrets.getClient()` class method to `Secrets.get_client()` without keeping the old name. In COSMOS 7.0 through 7.4, any Python plugin, interface, or microservice that calls `Secrets.getClient()` fails with an `AttributeError`. Releases starting with 7.5 restore `Secrets.getClient()` as a deprecated alias that logs a `DeprecationWarning`, matching the existing `Bucket.getClient()` alias.

Update Python code to call `Secrets.get_client()`. Ruby code is unaffected: `Secrets.getClient` and `Bucket.getClient` still work, and starting with 7.5 Ruby also accepts `Secrets.get_client` and `Bucket.get_client` so the same names work in both languages.

If you've updated your plugin but still see errors about `getClient`, an older copy of your plugin code is probably still being loaded. Check the Admin Console Plugins tab for a previous version of the plugin that is still installed, and check the `shared` Python packages in the Admin Console Packages tab for an old copy of your plugin's Python package that COSMOS 6 installed.

### Troubleshooting

#### Init Container Failure
Expand Down
5 changes: 5 additions & 0 deletions openc3/lib/openc3/utilities/bucket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def self.getClient
klass.new
end

# snake_case alias to match the Python Bucket.get_client
def self.get_client # rubocop:disable Naming/AccessorMethodName
getClient()
end

def initialize
# Setup the client instance
end
Expand Down
5 changes: 5 additions & 0 deletions openc3/lib/openc3/utilities/secrets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ def self.getClient
klass.new
end

# snake_case alias to match the Python Secrets.get_client
def self.get_client # rubocop:disable Naming/AccessorMethodName
getClient()
end

def keys(secret_store: nil, scope:)
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
Expand Down
9 changes: 9 additions & 0 deletions openc3/python/openc3/utilities/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# if purchased from OpenC3, Inc.

import os
import warnings

from openc3.top_level import get_class_from_module
from openc3.utilities.string import filename_to_class_name
Expand Down Expand Up @@ -78,6 +79,14 @@
)
return klass()

@classmethod
def getClient(cls): # noqa: N802

Check warning on line 83 in openc3/python/openc3/utilities/secrets.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename method "getClient" to match the regular expression ^[a-z_][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=OpenC3_cosmos&issues=AaGIIZ6tsX4urdJfX8wS&open=AaGIIZ6tsX4urdJfX8wS&pullRequest=4184
"""Deprecated: Use get_client() instead. This camelCase method is provided for backwards compatibility."""
warnings.warn(
"Secrets.getClient() is deprecated, use Secrets.get_client() instead", DeprecationWarning, stacklevel=2
)
return cls.get_client()

def keys(self, secret_store=None, scope=None):
raise RuntimeError(f"{self.__class__.__name__} has not implemented method 'keys'")

Expand Down
10 changes: 10 additions & 0 deletions openc3/python/test/utilities/test_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,13 @@ def test_setup_does_not_read_file_secrets_outside_the_secret_file_dir(self):
for path in ["/etc/passwd", "/tmp/../etc/passwd"]:
with self.assertRaisesRegex(ValueError, "must be under"):
secrets.setup([["FILE", "KEY", path]])

def test_get_client_returns_the_configured_backend(self):
with patch.dict(os.environ, {"OPENC3_SECRET_BACKEND": "redis"}):
self.assertEqual(Secrets.get_client().__class__.__name__, "RedisSecrets")

def test_get_client_camel_case_is_a_deprecated_alias(self):
with patch.object(Secrets, "get_client", return_value="client") as get_client:
with self.assertWarnsRegex(DeprecationWarning, r"use Secrets\.get_client\(\)"):
self.assertEqual(Secrets.getClient(), "client")
get_client.assert_called_once()
8 changes: 8 additions & 0 deletions openc3/spec/utilities/bucket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,13 @@ module OpenC3
expect(client).to be_a LocalBucket
end
end

describe "get_client" do
it "is an alias for getClient" do
ENV['OPENC3_CLOUD'] = 'AWS'
Comment thread
jmthomas marked this conversation as resolved.
client = Bucket.get_client
expect(client).to be_a AwsBucket
end
end
end
end
8 changes: 8 additions & 0 deletions openc3/spec/utilities/secrets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ module OpenC3
end
end

describe "get_client" do
it "is an alias for getClient" do
client = double("client")
expect(Secrets).to receive(:getClient).and_return(client)
expect(Secrets.get_client).to be client
end
end

describe "setup" do
it "requires at least 3 items" do
expect { Secrets.new.setup([['ENV', 'KEY']]) }.to raise_error(ArgumentError, /at least 3 items/)
Expand Down
Loading