-
-
Notifications
You must be signed in to change notification settings - Fork 299
WIP: Packaging v3 #2070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
WIP: Packaging v3 #2070
Conversation
da7ec5e
to
d659e58
Compare
…able to run app scripts snippets, in particular the future v3 app functions build/init etc
…p assets and files to keep during ynh_setup_source such that we can run it as non-root ... not super happy about it, it's a mess, we should probably find a simpler way to handle this under a common directory which becomes YNH_APP_BASEDIR..
…nd run the build() function from the app's scripts.sh instead of the install script (later we shall have a _pre_build_as_root, _post_build_as_root, the init phase, etc, gotta think about how to organize the code)
…ant as non-root because $app can't give a file to the www-data group ... we'll need to do this between build and init/migrate somehow
…a separate utils file
…m + if clause handling
|
||
super().__init__(*args, **kwargs) | ||
|
||
def reload(): |
Check notice
Code scanning / CodeQL
First parameter of a method is not named 'self' Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 12 hours ago
To fix the issue, we need to determine the intended behavior of the reload
method:
- If the method is meant to interact with the instance (e.g., access or modify instance attributes), the
self
parameter should be added as the first argument. - If the method is independent of the instance, it should be decorated with
@staticmethod
to clarify its intent.
Given the context, it is likely that reload
is intended to be an instance method, as it is defined within a class that represents configurations. Therefore, the best fix is to add the self
parameter to the method definition.
-
Copy modified line R55
@@ -54,3 +54,3 @@ | ||
|
||
def reload(): | ||
def reload(self): | ||
pass |
ast.Eq: op.eq, | ||
ast.NotEq: op.ne, | ||
} | ||
context["true"] = True |
Check failure
Code scanning / CodeQL
Modification of parameter with default Error
default value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 days ago
To fix the issue, replace the mutable default value ({}
) of the context
parameter in evaluate_simple_js_expression
with None
. Then, within the function, check if context
is None
and initialize it to an empty dictionary. This ensures that a new dictionary is created for each function call, avoiding unintended side effects caused by modifying a shared default value.
Steps to implement the fix:
- Change the default value of the
context
parameter inevaluate_simple_js_expression
from{}
toNone
. - Add a check within
evaluate_simple_js_expression
to initializecontext
to an empty dictionary if it isNone
.
-
Copy modified lines R169-R171
@@ -168,3 +168,5 @@ | ||
|
||
def evaluate_simple_js_expression(expr: str, context: dict[str, Any] = {}) -> bool: | ||
def evaluate_simple_js_expression(expr: str, context: dict[str, Any] = None) -> bool: | ||
if context is None: | ||
context = {} | ||
if not expr.strip(): |
ast.NotEq: op.ne, | ||
} | ||
context["true"] = True | ||
context["false"] = False |
Check failure
Code scanning / CodeQL
Modification of parameter with default Error
default value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 days ago
To fix the issue, we will replace the mutable default argument ({}
) with None
and initialize the dictionary within the function if context
is None
. This ensures that each call to the function gets a fresh dictionary, preventing unintended side effects from shared state.
Steps to fix:
- Update the
evaluate_simple_js_expression
function definition to setcontext=None
as the default value. - Add a check at the beginning of the function to initialize
context
as an empty dictionary if it isNone
.
-
Copy modified lines R169-R171
@@ -168,3 +168,5 @@ | ||
|
||
def evaluate_simple_js_expression(expr: str, context: dict[str, Any] = {}) -> bool: | ||
def evaluate_simple_js_expression(expr: str, context: dict[str, Any] = None) -> bool: | ||
if context is None: | ||
context = {} | ||
if not expr.strip(): |
} | ||
context["true"] = True | ||
context["false"] = False | ||
context["null"] = None |
Check failure
Code scanning / CodeQL
Modification of parameter with default Error
default value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 days ago
To fix the issue, we will replace the mutable default value ({}
) for the context
parameter with a placeholder value (None
). Inside the function, we will check if context
is None
and initialize it to an empty dictionary ({}
) if necessary. This ensures that a new dictionary is created for each function call, avoiding the unintended sharing of state between calls.
Steps to fix:
- Update the
evaluate_simple_js_expression
function definition to set the default value ofcontext
toNone
instead of{}
. - Add a check at the beginning of the function to initialize
context
to an empty dictionary if it isNone
.
-
Copy modified lines R169-R171
@@ -168,3 +168,5 @@ | ||
|
||
def evaluate_simple_js_expression(expr: str, context: dict[str, Any] = {}) -> bool: | ||
def evaluate_simple_js_expression(expr: str, context: dict[str, Any] = None) -> bool: | ||
if context is None: | ||
context = {} | ||
if not expr.strip(): |
src/service.py
Outdated
#if service not in services.keys(): | ||
# raise YunohostValidationError("service_unknown", service=service) |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 12 hours ago
To fix the issue, we need to either remove the commented-out code or reinstate it. Since the _run_service_command
function already contains logic for handling services, reinstating the code would require validating its functionality and ensuring it integrates correctly with the existing logic. If the code is unnecessary, it should be removed entirely.
The best approach here is to remove the commented-out code, as there is no indication that it is required or functional. This will clean up the code and eliminate any confusion for future developers.
-
Copy modified line R632
@@ -631,4 +631,3 @@ | ||
services = _get_services() | ||
# if service not in services.keys(): | ||
# raise YunohostValidationError("service_unknown", service=service) | ||
|
||
|
# Remove the lock if one was given | ||
if need_lock and PID != 0: | ||
_remove_lock(PID) | ||
|
||
if wait_until_pattern: | ||
try: | ||
out, err = watch_log_proc.communicate(timeout=timeout) |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 12 hours ago
To fix the issue, we need to remove the unused variable out
while ensuring that the communicate()
method is still called to preserve any side effects it may have. Since the variable err
is also unused, we can simplify the call to communicate()
by omitting the unpacking of its return values entirely. This will make the code cleaner and avoid confusion about unused variables.
The changes will be made in the function where the issue occurs, specifically on line 691. No additional imports, methods, or definitions are required.
-
Copy modified line R691
@@ -690,3 +690,3 @@ | ||
try: | ||
out, err = watch_log_proc.communicate(timeout=timeout) | ||
watch_log_proc.communicate(timeout=timeout) | ||
except subprocess.TimeoutExpired: |
# Remove the lock if one was given | ||
if need_lock and PID != 0: | ||
_remove_lock(PID) | ||
|
||
if wait_until_pattern: | ||
try: | ||
out, err = watch_log_proc.communicate(timeout=timeout) |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 12 hours ago
To fix the issue, we should remove the assignment to the unused variable err
while preserving the assignment to out
, as out
is used later in the code. This can be achieved by modifying the communicate
call to only capture the out
variable. The communicate
method returns a tuple, so we can directly assign the first element to out
and ignore the second element (which corresponds to err
). Alternatively, we can use a placeholder name like _
for the unused variable to explicitly indicate that it is not used.
-
Copy modified line R691
@@ -690,3 +690,3 @@ | ||
try: | ||
out, err = watch_log_proc.communicate(timeout=timeout) | ||
out, _ = watch_log_proc.communicate(timeout=timeout) | ||
except subprocess.TimeoutExpired: |
@@ -760,9 +846,9 @@ | |||
# such that /etc/yunohost/services.yml contains the minimal | |||
# changes with respect to the base conf | |||
|
|||
conf_base = yaml.safe_load(open(SERVICES_CONF_BASE)) or {} | |||
conf_base: dict[str, ServiceInfos] = yaml.safe_load(open(SERVICES_CONF_BASE)) or {} |
Check warning
Code scanning / CodeQL
File is not always closed Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 12 hours ago
To fix the issue, replace the open(SERVICES_CONF_BASE)
call with a with
statement. This ensures the file is closed automatically when the block is exited, even if an exception occurs. The yaml.safe_load
function can be used directly within the with
block to read the file's contents.
-
Copy modified lines R858-R859
@@ -857,3 +857,4 @@ | ||
|
||
conf_base: dict[str, ServiceInfos] = yaml.safe_load(open(SERVICES_CONF_BASE)) or {} | ||
with open(SERVICES_CONF_BASE, 'r') as file: | ||
conf_base: dict[str, ServiceInfos] = yaml.safe_load(file) or {} | ||
|
…, it's too clumsy and the new automerge mechanism + extras conf mechanism should cover most of the usecases
…pattern appears in log, similar to what's already done in app systemd helpers
As foretold by The Prophecy
(NB: no need to try to review this, it's not nearly done, this is just the beginning, there's still a good 3 ~ 6 months of work ...)
TODO / Brain dump
scripts.sh
(build
,initialize
,before_build_as_root
etc ...)$app
main
one and extra resources (similar to what's already done for ports ... though uuugh that feels weird for install_dir / data_dir for example...) with if clauses and pydantic for property typing, default values, restriction to what may/must be defined in the manifestsinstall_dir
after the build ($app
can'tchgrp
towww-data
)--keep
be handled declaratively in the manifest ? Or even have a categorization of folders / files to flag them as conf / data / cache / source / dependencies / ..., idk/etc/yunohost/apps/*/hooks
folders ?