-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added secret variables support for DDM. (#24969)
#24548 Adding secret variables support for DDM profiles. # Checklist for submitter - [x] Added/updated tests - [x] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Manual QA for all new/changed functionality
- Loading branch information
Showing
6 changed files
with
282 additions
and
44 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
server/datastore/mysql/migrations/tables/20241220114903_ChangeDDMJSONColumnToText.go
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,25 @@ | ||
package tables | ||
|
||
import ( | ||
"database/sql" | ||
"fmt" | ||
) | ||
|
||
func init() { | ||
MigrationClient.AddMigration(Up_20241220114903, Down_20241220114903) | ||
} | ||
|
||
func Up_20241220114903(tx *sql.Tx) error { | ||
_, err := tx.Exec(` | ||
ALTER TABLE mdm_apple_declarations | ||
CHANGE raw_json raw_json MEDIUMTEXT COLLATE utf8mb4_unicode_ci NOT NULL -- 16MB max size`) | ||
if err != nil { | ||
return fmt.Errorf("failed to change mdm_apple_declarations.raw_json column; is there a very large DDM profile?: %w", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func Down_20241220114903(tx *sql.Tx) error { | ||
return nil | ||
} |
36 changes: 36 additions & 0 deletions
36
server/datastore/mysql/migrations/tables/20241220114903_ChangeDDMJSONColumnToText_test.go
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,36 @@ | ||
package tables | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/jmoiron/sqlx" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestUp_20241220114903(t *testing.T) { | ||
db := applyUpToPrev(t) | ||
|
||
myJSON := `{"foo": "bar"}` | ||
execNoErr(t, db, | ||
fmt.Sprintf(`INSERT INTO mdm_apple_declarations (declaration_uuid, identifier, name, raw_json, checksum, team_id) VALUES ('A', 'A', 'nameA', '%s', '', 0)`, | ||
myJSON)) | ||
|
||
// Apply current migration. | ||
applyNext(t, db) | ||
|
||
var res []struct { | ||
DeclarationUUID string `db:"declaration_uuid"` | ||
RawJSON string `db:"raw_json"` | ||
} | ||
err := sqlx.SelectContext(context.Background(), db, &res, `SELECT declaration_uuid, raw_json FROM mdm_apple_declarations`) | ||
require.NoError(t, err) | ||
require.Len(t, res, 1) | ||
require.Equal(t, myJSON, res[0].RawJSON) | ||
require.Equal(t, "A", res[0].DeclarationUUID) | ||
|
||
execNoErr(t, db, | ||
`INSERT INTO mdm_apple_declarations (declaration_uuid, identifier, name, raw_json, checksum, team_id) VALUES ('B', 'B', 'nameB', '$FLEET_SECRET_BOZO', '', 0)`) | ||
|
||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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