-
Notifications
You must be signed in to change notification settings - Fork 465
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
Add policies for "No team" #21972
Add policies for "No team" #21972
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #21972 +/- ##
==========================================
+ Coverage 64.85% 65.40% +0.54%
==========================================
Files 1493 1493
Lines 116579 116332 -247
Branches 3537 3487 -50
==========================================
+ Hits 75611 76085 +474
+ Misses 33924 33152 -772
- Partials 7044 7095 +51
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Looks good. Left a few comments/questions.
@@ -366,12 +411,14 @@ func parseAgentOptions(top map[string]json.RawMessage, result *GitOps, baseDir s | |||
func parseControls(top map[string]json.RawMessage, result *GitOps, baseDir string, multiError *multierror.Error) *multierror.Error { | |||
controlsRaw, ok := top["controls"] | |||
if !ok { | |||
return multierror.Append(multiError, errors.New("'controls' is required")) |
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.
Why don't we need this error here?
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.
Because controls
can be defined on global file or in no-team.yml
, so we allow omitting it. (In cmd/fleetctl
we check that it has to be defined in one of these at least.)
return err | ||
} | ||
if len(constraints) != 1 { | ||
return errors.New("policies foreign key to teams not found") |
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.
Why the error here? If there are no constraints, then we don't need to drop the FK, I think.
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.
We are assuming the fk is there on all deployments.
DROP INDEX policy_team_unique, | ||
MODIFY inherited_team_id INT UNSIGNED NULL, | ||
ADD COLUMN inherited_team_id_char char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci | ||
GENERATED ALWAYS AS (IF(inherited_team_id IS NULL, 'global', CONVERT(inherited_team_id, CHAR))), |
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.
Why VIRTUAL
and not GENERATED ALWAYS AS (...) STORED
?
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.
Given policies is usually a small table (in the order of ~1k entries?) it doesn't make a difference, right?
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.
Yes, just wondering if this was intentional. I recommend explicitly specifying VIRTUAL
in the future.
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.
Let's add it to the patterns.md (when time allows).
@@ -12,9 +12,9 @@ import ( | |||
|
|||
"golang.org/x/text/unicode/norm" | |||
|
|||
"github.com/doug-martin/goqu/v9" |
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.
🎉
server/datastore/mysql/migrations/tables/20240905140515_AddPoliciesToNoTeam.go
Outdated
Show resolved
Hide resolved
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.
LGTM
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.
LGTM
#21467
changes/
,orbit/changes/
oree/fleetd-chrome/changes
.See Changes files for more information.
SELECT *
is avoided, SQL injection is prevented (using placeholders for values in statements)COLLATE utf8mb4_unicode_ci
).