Skip to content

Commit

Permalink
Merge pull request #12 from phyzical/feature/add-labels-file-exists-c…
Browse files Browse the repository at this point in the history
…heck

add file check on config load page
  • Loading branch information
phyzical authored Nov 3, 2024
2 parents 2f54916 + 5857395 commit 415fcb7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docker.labelInjector.plg
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

<PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;" min="6.12.3">
<CHANGES>
###2024.11.03
- Fix issue with default labels not being loaded correctly when first time use

###2024.10.29
!!!! BREAKING CHANGE !!!!
- Changed the way the default labels are stored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class DefaultLabels
{
public const CONFIG_PATH = "/boot/config/docker.labelInjector/";
public const CONFIG_PATH = "/boot/config/docker.labelInjector";
public const LABELS_PATH = self::CONFIG_PATH . "/labels.json";
public const QUOTE_REPLACER = "\`";

Expand Down Expand Up @@ -33,7 +33,10 @@ static function formSubmit(): string|null
*/
static function getDefaultLabels(): array
{
$json = file_get_contents(self::LABELS_PATH);
$json = "";
if (file_exists(self::LABELS_PATH)) {
$json = file_get_contents(self::LABELS_PATH);
}
if (!$json || empty($json)) {
return [];
}
Expand Down

0 comments on commit 415fcb7

Please sign in to comment.