-
Notifications
You must be signed in to change notification settings - Fork 40
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
Implement global images #915
Merged
Merged
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
531accd
Implement global images
jmpesp c9900f8
different port for github actions
jmpesp 0098275
Merge remote-tracking branch 'upstream/main' into create_some_images
jmpesp 6aa953e
remove GlobalImageList from ResourceType
jmpesp 8341194
don't store fleet, it's a singleton
jmpesp 17042f4
remove global_image_fetch
jmpesp a52de65
GlobalImage not custom, but FleetChild
jmpesp bd825de
separate project and global image views
jmpesp 3b88391
return 503 instead of unimplemented
jmpesp 5acc551
warn to debug
jmpesp 5b35c58
change Into into From
jmpesp 6cb46a6
Merge remote-tracking branch 'upstream/main' into create_some_images
jmpesp ef02727
use only ActionError::action_failed
jmpesp 68879fa
remove non-useful comments
jmpesp e4007d4
remove project image comment reference to global image
jmpesp 0477683
create DiskSource enum for DiskCreate, make creation type safe
jmpesp 7d62b0b
fmt
jmpesp 639eba1
Merge remote-tracking branch 'upstream/main' into create_some_images
jmpesp 3b516c4
clippy
jmpesp 6b0a10f
tag = "type" is the best
jmpesp 4752359
more error context
jmpesp 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
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
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 |
---|---|---|
|
@@ -191,12 +191,69 @@ impl AuthorizedResource for Fleet { | |
} | ||
} | ||
|
||
#[derive(Clone, Copy, Debug)] | ||
pub struct GlobalImageList { | ||
fleet: Fleet, | ||
/// ConsoleSessionList is a synthetic resource used for modeling who has access | ||
/// to create sessions. | ||
#[derive(Clone, Copy, Debug, Eq, PartialEq)] | ||
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. It seems like something about the way this was merged caused this stuff to show up as part of your change. That's weird. |
||
pub struct ConsoleSessionList; | ||
|
||
pub const CONSOLE_SESSION_LIST: ConsoleSessionList = ConsoleSessionList {}; | ||
|
||
impl oso::PolarClass for ConsoleSessionList { | ||
fn get_polar_class_builder() -> oso::ClassBuilder<Self> { | ||
// Roles are not directly attached to ConsoleSessionList. | ||
oso::Class::builder() | ||
.with_equality_check() | ||
.add_method( | ||
"has_role", | ||
|_: &ConsoleSessionList, | ||
_actor: AuthenticatedActor, | ||
_role: String| false, | ||
) | ||
.add_attribute_getter("fleet", |_| FLEET) | ||
} | ||
} | ||
|
||
impl AuthorizedResource for ConsoleSessionList { | ||
fn load_roles<'a, 'b, 'c, 'd, 'e, 'f>( | ||
&'a self, | ||
opctx: &'b OpContext, | ||
datastore: &'c DataStore, | ||
authn: &'d authn::Context, | ||
roleset: &'e mut RoleSet, | ||
) -> futures::future::BoxFuture<'f, Result<(), Error>> | ||
where | ||
'a: 'f, | ||
'b: 'f, | ||
'c: 'f, | ||
'd: 'f, | ||
'e: 'f, | ||
{ | ||
load_roles_for_resource( | ||
opctx, | ||
datastore, | ||
authn, | ||
ResourceType::Fleet, | ||
*FLEET_ID, | ||
roleset, | ||
) | ||
.boxed() | ||
} | ||
|
||
fn on_unauthorized( | ||
&self, | ||
_: &Authz, | ||
error: Error, | ||
_: AnyActor, | ||
_: Action, | ||
) -> Error { | ||
error | ||
} | ||
} | ||
|
||
#[derive(Clone, Copy, Debug)] | ||
pub struct GlobalImageList; | ||
/// Singleton representing the [`GlobalImageList`] itself for authz purposes | ||
pub const GLOBAL_IMAGE_LIST: GlobalImageList = GlobalImageList { fleet: FLEET }; | ||
pub const GLOBAL_IMAGE_LIST: GlobalImageList = GlobalImageList; | ||
|
||
impl Eq for GlobalImageList {} | ||
impl PartialEq for GlobalImageList { | ||
|
@@ -210,7 +267,7 @@ impl oso::PolarClass for GlobalImageList { | |
fn get_polar_class_builder() -> oso::ClassBuilder<Self> { | ||
oso::Class::builder() | ||
.with_equality_check() | ||
.add_attribute_getter("fleet", |x: &GlobalImageList| x.fleet) | ||
.add_attribute_getter("fleet", |_x: &GlobalImageList| FLEET) | ||
} | ||
} | ||
|
||
|
@@ -399,5 +456,5 @@ authz_resource! { | |
parent = "Fleet", | ||
primary_key = Uuid, | ||
roles_allowed = false, | ||
polar_snippet = Custom, | ||
polar_snippet = FleetChild, | ||
} |
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.
I see you removed the "optional" comments here but the fields are still optional. Is that the intent or are they supposed to be
NOT NULL
?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.
They are supposed to be optional