-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
chore: add registry auth to docker image apps #4187
Draft
OSINTRoach
wants to merge
15
commits into
coollabsio:next
Choose a base branch
from
OSINTRoach:docker-image-login
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b57a439
chore: add registry auth to docker image apps
15653e6
chore: added registry url with default plus fixed functionality
5a1431c
chore: remove encrypting token since it should be editable and visibl…
5187324
fix: revert change
3130b44
fix: revert some more for less confusion
60d6189
Merge remote-tracking branch 'upstream/next' into docker-image-login
02d29d9
chore: info tooltip
ebf2072
chore: encrypt with casts + masking and interpolation + fixes
9d08eed
chore: small improvement
3cd185a
chore: changed migrations, created registries, initial progress
42de7ec
chore: database, navigation images
1fd8737
fix: navbar link color
653d0f3
Merge remote-tracking branch 'upstream/next' into docker-image-login
65eb856
chore: looks and validation
8787a9b
Merge branch 'next' into docker-image-login
peaklabs-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Images\Images; | ||
|
||
use Livewire\Component; | ||
|
||
class Index extends Component | ||
{ | ||
public function render() | ||
{ | ||
return view('livewire.images.images.index'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Images\Registry; | ||
|
||
use App\Models\DockerRegistry; | ||
use Livewire\Component; | ||
|
||
class Create extends Component | ||
{ | ||
public string $name = ''; | ||
public string $type = 'docker_hub'; | ||
public ?string $url = null; | ||
public ?string $username = null; | ||
public ?string $token = null; | ||
|
||
protected $rules = [ | ||
'name' => 'required|string|max:255', | ||
'type' => 'required|string', | ||
'url' => 'nullable|string|max:255', | ||
'username' => 'nullable|string|max:255', | ||
'token' => 'nullable|string', | ||
]; | ||
|
||
public function getRegistryTypesProperty() | ||
{ | ||
return DockerRegistry::getTypes(); | ||
} | ||
|
||
public function submit() | ||
{ | ||
$this->validate(); | ||
|
||
DockerRegistry::create([ | ||
'name' => $this->name, | ||
'type' => $this->type, | ||
'url' => $this->type === 'custom' ? $this->url : 'docker.io', | ||
'username' => $this->username, | ||
'token' => $this->token, | ||
]); | ||
|
||
$this->dispatch('registry-added'); | ||
$this->dispatch('success', 'Registry added successfully.'); | ||
$this->dispatch('close-modal'); | ||
} | ||
|
||
public function render() | ||
{ | ||
return view('livewire.images.registry.create'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Images\Registry; | ||
|
||
use App\Models\DockerRegistry; | ||
use Livewire\Component; | ||
|
||
class Index extends Component | ||
{ | ||
protected $listeners = ['registry-added' => '$refresh']; | ||
|
||
public function render() | ||
{ | ||
return view('livewire.images.registry.index', [ | ||
'registries' => DockerRegistry::all() | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Images\Registry; | ||
|
||
use App\Models\DockerRegistry; | ||
use Livewire\Component; | ||
|
||
class Show extends Component | ||
{ | ||
public DockerRegistry $registry; | ||
public string $name = ''; | ||
public string $type = ''; | ||
public ?string $url = null; | ||
public ?string $username = null; | ||
public ?string $token = null; | ||
|
||
protected $rules = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also use the new validate attribute syntax |
||
'name' => 'required|string|max:255', | ||
'type' => 'required|string', | ||
'url' => 'nullable|string|max:255', | ||
'username' => 'nullable|string|max:255', | ||
'token' => 'nullable|string', | ||
]; | ||
|
||
public function mount(DockerRegistry $registry) | ||
{ | ||
$this->registry = $registry; | ||
$this->name = $registry->name; | ||
$this->type = $registry->type; | ||
$this->url = $registry->url; | ||
$this->username = $registry->username; | ||
$this->token = $registry->token; | ||
} | ||
|
||
public function getRegistryTypesProperty() | ||
{ | ||
return DockerRegistry::getTypes(); | ||
} | ||
|
||
public function updateRegistry() | ||
{ | ||
$this->validate(); | ||
|
||
$this->registry->update([ | ||
'name' => $this->name, | ||
'type' => $this->type, | ||
'url' => $this->type === 'custom' ? $this->url : 'docker.io', | ||
'username' => $this->username, | ||
'token' => $this->token, | ||
]); | ||
|
||
$this->dispatch('success', 'Registry updated successfully.'); | ||
} | ||
|
||
public function delete() | ||
{ | ||
// Update all applications using this registry | ||
$this->registry->applications() | ||
->update([ | ||
'docker_registry_id' => null, | ||
'docker_use_custom_registry' => false | ||
]); | ||
|
||
$this->registry->delete(); | ||
$this->dispatch('registry-added'); | ||
$this->dispatch('success', 'Registry deleted successfully.'); | ||
} | ||
|
||
public function render() | ||
{ | ||
return view('livewire.images.registry.show'); | ||
} | ||
|
||
public function getIsFormDirtyProperty(): bool | ||
{ | ||
return $this->name !== $this->registry->name | ||
|| $this->type !== $this->registry->type | ||
|| $this->url !== $this->registry->url | ||
|| $this->username !== $this->registry->username | ||
|| $this->token !== $this->registry->token; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the new validation attribute of Livewire as this syntax is deprecated. https://livewire.laravel.com/docs/validation#validate-attributes