refactor: custom labels
This commit is contained in:
parent
d3c9894479
commit
f3b04c1ef9
@ -874,20 +874,7 @@ private function generate_compose_file()
|
|||||||
$environment_variables = $this->generate_environment_variables($ports);
|
$environment_variables = $this->generate_environment_variables($ports);
|
||||||
|
|
||||||
if (data_get($this->application, 'custom_labels')) {
|
if (data_get($this->application, 'custom_labels')) {
|
||||||
if (base64_encode(base64_decode(data_get($this->application, 'custom_labels'), true)) === data_get($this->application, 'custom_labels')) {
|
$this->application->parseContainerLabels();
|
||||||
ray('custom_labels is base64 encoded');
|
|
||||||
} else {
|
|
||||||
ray('custom_labels is not base64 encoded');
|
|
||||||
$this->application->custom_labels = str($this->application->custom_labels)->replace(',', "\n");
|
|
||||||
$this->application->custom_labels = base64_encode(data_get($this->application, 'custom_labels'));
|
|
||||||
$this->application->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mb_detect_encoding(base64_decode($this->application->custom_labels), 'ASCII', true) === false) {
|
|
||||||
ray('custom_labels contains non-ascii characters');
|
|
||||||
$this->application->custom_labels = base64_encode(str(implode(",", generateLabelsApplication($this->application, $this->preview)))->replace(',', "\n"));
|
|
||||||
$this->application->save();
|
|
||||||
}
|
|
||||||
$labels = collect(preg_split("/\r\n|\n|\r/", base64_decode($this->application->custom_labels)));
|
$labels = collect(preg_split("/\r\n|\n|\r/", base64_decode($this->application->custom_labels)));
|
||||||
$labels = $labels->filter(function ($value, $key) {
|
$labels = $labels->filter(function ($value, $key) {
|
||||||
return !Str::startsWith($value, 'coolify.');
|
return !Str::startsWith($value, 'coolify.');
|
||||||
|
@ -109,24 +109,7 @@ public function mount()
|
|||||||
$this->application->isConfigurationChanged(true);
|
$this->application->isConfigurationChanged(true);
|
||||||
}
|
}
|
||||||
$this->isConfigurationChanged = $this->application->isConfigurationChanged();
|
$this->isConfigurationChanged = $this->application->isConfigurationChanged();
|
||||||
|
$this->customLabels = $this->application->parseContainerLabels();
|
||||||
if (data_get($this->application, 'custom_labels')) {
|
|
||||||
if (base64_encode(base64_decode(data_get($this->application, 'custom_labels'), true)) === data_get($this->application, 'custom_labels')) {
|
|
||||||
ray('custom_labels is base64 encoded');
|
|
||||||
} else {
|
|
||||||
ray('custom_labels is not base64 encoded');
|
|
||||||
$this->application->custom_labels = str($this->application->custom_labels)->replace(',', "\n");
|
|
||||||
$this->application->custom_labels = base64_encode(data_get($this->application, 'custom_labels'));
|
|
||||||
$this->application->save();
|
|
||||||
}
|
|
||||||
$this->customLabels = base64_decode(data_get($this->application, 'custom_labels'));
|
|
||||||
// // Fix for non-ascii characters
|
|
||||||
if (mb_detect_encoding($this->customLabels, 'ASCII', true) === false) {
|
|
||||||
ray('custom_labels contains non-ascii characters');
|
|
||||||
$this->resetDefaultLabels(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->initialDockerComposeLocation = $this->application->docker_compose_location;
|
$this->initialDockerComposeLocation = $this->application->docker_compose_location;
|
||||||
$this->checkLabelUpdates();
|
$this->checkLabelUpdates();
|
||||||
}
|
}
|
||||||
|
@ -1024,4 +1024,24 @@ function loadComposeFile($isInit = false)
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function parseContainerLabels(?ApplicationPreview $preview = null)
|
||||||
|
{
|
||||||
|
$customLabels = data_get($this, 'custom_labels');
|
||||||
|
if (!$customLabels) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (base64_encode(base64_decode($customLabels, true)) !== $customLabels) {
|
||||||
|
ray('custom_labels is not base64 encoded');
|
||||||
|
$this->custom_labels = str($customLabels)->replace(',', "\n");
|
||||||
|
$this->custom_labels = base64_encode($customLabels);
|
||||||
|
}
|
||||||
|
$customLabels = base64_decode($this->custom_labels);
|
||||||
|
if (mb_detect_encoding($customLabels, 'ASCII', true) === false) {
|
||||||
|
ray('custom_labels contains non-ascii characters');
|
||||||
|
$customLabels = str(implode(",", generateLabelsApplication($this, $preview)))->replace(',', "\n");
|
||||||
|
}
|
||||||
|
$this->custom_labels = base64_encode($customLabels);
|
||||||
|
$this->save();
|
||||||
|
return $customLabels;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
// The release version of your application
|
// The release version of your application
|
||||||
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
|
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
|
||||||
'release' => '4.0.0-beta.161',
|
'release' => '4.0.0-beta.162',
|
||||||
// When left empty or `null` the Laravel environment will be used
|
// When left empty or `null` the Laravel environment will be used
|
||||||
'environment' => config('app.env'),
|
'environment' => config('app.env'),
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return '4.0.0-beta.161';
|
return '4.0.0-beta.162';
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"version": "3.12.36"
|
"version": "3.12.36"
|
||||||
},
|
},
|
||||||
"v4": {
|
"v4": {
|
||||||
"version": "4.0.0-beta.161"
|
"version": "4.0.0-beta.162"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user