Skip to content

Add GAM feature parity for Google Workspace admin commands#179

Open
salmonumbrella wants to merge 42 commits intosteipete:mainfrom
salmonumbrella:gam-feature-parity
Open

Add GAM feature parity for Google Workspace admin commands#179
salmonumbrella wants to merge 42 commits intosteipete:mainfrom
salmonumbrella:gam-feature-parity

Conversation

@salmonumbrella
Copy link
Contributor

Summary

Brings gog to feature parity with GAM (Google Admin Manager) for Google Workspace administration. This is a large PR because GAM covers ~40 distinct Google API surfaces — each one needs its own command file, API service factory, and test suite.

What's in here:

  • ~40 new command groups: alerts, aliases, analytics, batch, CAA, calendar, channel, chat, classroom, cloud identity, contacts (advanced), CSV processing, domains, drive (advanced), forms, labels, licenses, looker studio, meet, org units, printers, projects, reports, reseller, resources, roles, schemas, service accounts, sites, SSO, transfer, users (advanced), vault, youtube
  • --dry-run for batch and CSV commands
  • --todrive output to Google Sheets
  • Special character support for password generation
  • GOG_CUSTOMER_ID env var for multi-tenant admin (Admin SDK + Cloud Identity)
  • Code review fixes: Drive API query escaping, output channel consistency, deduplication

Why it's big: Each Google API surface is structurally independent — separate endpoints, separate auth scopes, separate request/response types. There's no way to meaningfully split this into smaller PRs without shipping a half-working admin tool.

Test plan

  • go build ./... passes
  • go vet ./... clean
  • go test ./... — all packages pass (158 files changed, ~45k lines)
  • Code review completed — 1 critical (Drive query injection), 5 important, 4 minor issues found and fixed

🤖 Generated with Claude Code

salmonumbrella and others added 30 commits February 2, 2026 20:09
The commit 5137fcb added --history-types flag but changed the default
behavior: when not specified, it now fetched ALL history types instead
of just messageAdded (the previous hardcoded behavior).

This fix ensures backward compatibility by defaulting to messageAdded
when --history-types is not provided.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When messageDeleted history type is requested, deleted messages cannot
be fetched from Gmail API (returns 404). Now collectHistoryMessageIDs
returns a struct with separate FetchIDs and DeletedIDs lists, and the
hook payload includes deletedMessageIds field for consumers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add canonical forms to history type alias map for robustness
- Add length assertion for FetchIDs in TestCollectHistoryMessageIDs
- Clarify documentation that default is messageAdded
- Add test for empty input edge case in parseHistoryTypes
- Extract duplicate state update logic into updateStateAfterHistory helper

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rename inner `err` to `updateErr` to avoid shadowing the outer
variable, satisfying golangci-lint's govet shadow checker.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rename inner `err` to `updateErr` in two additional store.Update()
calls to avoid shadowing outer variables, completing the fix from
commit 71714ae. Both locations now match the established pattern.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace custom contains() helper with Go's built-in strings.Contains()
- Add TestProcess_ReadFromStdin to test stdin input via "-" path
- All 47 tests pass successfully

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add special character constant with 20+ unique characters
- Guarantee at least one special character in generated passwords
- Meet typical organizational password policies requiring uppercase, lowercase, digit, and special character
- Ensures passwords pass NIST and common security standards
…ting

Add --dry-run flag to batch.go and csv.go that shows which commands would be
executed without actually running them. This is important for bulk operations
to safely preview before execution.

- batch.go: Added DryRun field to BatchCmd, implements preview with
  "[dry-run] line N: cmd arg1 arg2 ..." format
- csv.go: Added DryRun field to CSVCmd, implements preview with
  "[dry-run] row N: cmd arg1 arg2 ..." format
- csv_test.go: Added TestBatchCmdDryRun and TestCSVCmdDryRun tests to verify
  dry-run mode prevents command execution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace hardcoded cloudIdentityDefaultParent constant with a function that checks for the GOG_CUSTOMER_ID environment variable. If set, uses "customers/{value}" as the parent; otherwise falls back to "customers/my_customer". Update help text for --parent flags to document this new env var override.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Previously, Clear() and Update() calls hardcoded "Sheet1" range regardless of the
actual first sheet name in the spreadsheet. This could cause failures when the
first sheet had a different name.

Changes:
- When creating new spreadsheets, explicitly set the first sheet title to "Data"
- When updating existing spreadsheets, fetch the first sheet name from metadata
- Use the actual sheet name (stored in sheetName variable) in Clear() and Update() calls

This ensures the code works with spreadsheets that have any first sheet name,
not just "Sheet1".

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- cloudidentity.go: Add CEL expression example to --dynamic-query help
- csv.go: Add field substitution and regex pattern examples
- batch.go: Clarify batch file format in help text
Replace fmt.Fprintf(os.Stdout, ...) with u.Out().Printf(...) across all
command files for consistent output handling through the UI abstraction.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add vault tests: matters CRUD, exports, holds
- Add roles tests: get, update, delete, privileges
- Add admin groups tests: update, delete, settings, members sync
- Increases cmd package coverage from 63.1% to 65.5%

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 45 new tests for resources buildings, calendars, and features commands:
- Buildings: list, get, create, update, delete (with JSON/text output variants)
- Calendars: list, get, create, update, delete (with JSON/text output variants)
- Features: list, create, delete (with JSON/text output variants)
- Input validation tests for empty IDs and missing required fields
- Pagination and filtering tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for AlertsGetCmd, AlertsDeleteCmd, AlertsUndeleteCmd,
AlertsFeedbackCreateCmd, AlertsFeedbackListCmd, AlertsSettingsUpdateCmd,
AliasesCreateCmd, and AliasesDeleteCmd. Tests cover plain text output,
JSON output mode, validation errors, and confirmation requirements.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for DomainsGetCmd, DomainsCreateCmd, DomainsDeleteCmd,
DomainsAliasesListCmd, DomainsAliasesCreateCmd, and DomainsAliasesDeleteCmd.
Tests cover JSON and plain text output modes, error handling, missing
account validation, and confirmation requirements for destructive operations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for contacts delegates, domain, import, export, and dedup commands:
- ContactsDelegatesAddCmd: add delegate functionality with JSON output
- ContactsDelegatesRemoveCmd: remove delegate functionality with JSON output
- ContactsDelegatesListCmd: JSON output and empty results handling
- ContactsDomainCreateCmd: create contact with JSON output and validation
- ContactsDomainDeleteCmd: delete by resource name/email with JSON output
- ContactsDomainListCmd: JSON output and pagination
- ContactsImportCmd: CSV parsing, JSON output, and error handling
- ContactsExportCmd: CSV export to file/stdout with JSON output
- ContactsDedupCmd: duplicate detection and dry-run mode

Also includes unit tests for CSV helper functions:
- normalizeCSVHeader, parseCSVRow, csvPerson
- openCSVReader, openCSVWriter

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 36 new tests for printers and forms commands:

Printers (18 tests):
- PrintersListCmd: list, JSON output, empty results, pagination
- PrintersGetCmd: get, JSON output, empty ID validation
- PrintersCreateCmd: create, JSON output, missing name/URI validation
- PrintersUpdateCmd: update, empty ID and no-updates validation
- PrintersDeleteCmd: delete, empty ID validation, confirmation check
- Helper functions: printerResourceName, printerParent

Forms (18 tests):
- FormsListCmd: list, JSON output, empty results, pagination, user filter
- FormsGetCmd: get, JSON output, empty ID validation, no-title handling
- FormsCreateCmd: create, JSON output, missing/whitespace title validation
- FormsResponsesCmd: list responses, JSON output, empty results, empty form ID, pagination

All tests use mock HTTP servers to verify API interactions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add tests for CAA (Context-Aware Access) levels commands
- Add tests for Cloud Identity management commands
- Add tests for license management commands
- Add tests for schema management commands
- Add tests for data transfer commands
- Fix RootFlags.Yes -> RootFlags.Force in caa_test.go

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
salmonumbrella and others added 12 commits February 3, 2026 13:28
- Add comprehensive tests for config commands
- Fix TestTransferApplicationsCmd_JSON: use string type for ID since JSON
  output serializes int64 as string

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ports, reseller, serviceaccounts

Add extensive test coverage for previously uncovered commands:
- labels: list, get, create, delete with JSON/text output
- orgunits: create, delete, get, update, list
- projects: list, get with JSON/text output
- reports: activities, users, customer, drive, tokens
- reseller: customers list/get, subscriptions list/get
- serviceaccounts: list, create, delete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for calendar edit functions and event day parsing:
- applyCreateEventType with various event types and transparency settings
- parseEventTime and parseEventDate with valid and invalid inputs
- edge cases for all-day events and timezone handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add extensive test coverage for authentication and chat commands:
- Auth tests for login, status, logout, info, and switch flows
- Chat tests for spaces, messages, threads operations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add extensive test coverage for Google Classroom commands:
- Courses (list, get, create, update, join, leave, url)
- Coursework (list, get, create, assignees)
- Guardians and guardian invites
- Invitations (list, get, create, accept, delete)
- Announcements (list, get, create, delete)
- Materials (list, get, create, update, delete)
- Roster, students, teachers, profile

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add shared EscapeDriveQueryValue to googleapi package that escapes
backslashes and single quotes, preventing query injection when
user-provided values contain those characters. Applied at all five
interpolation sites and deduplicated existing local escape helpers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Inline Drive query escape wrappers to use shared EscapeDriveQueryValue directly
- Add comprehensive unit tests for EscapeDriveQueryValue
- Fix CloudIdentity groups get to use UI layer instead of direct os.Stdout
- Remove duplicate splitCSVFields, use splitCSV from split_helpers.go
- Make adminCustomerID configurable via GOG_CUSTOMER_ID env var
- Add t.Parallel() safety comment to testutil_test.go
- Move cloudchannel stub from testutil_test.go to channel_test.go
- Fix batch.go channel close pattern with goroutine
- Document readValueOrFile file detection heuristic

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Address 124 lint findings across err113, goconst, govet shadow,
gosec, unparam, wsl, staticcheck, thelper, nilnil, predeclared,
ineffassign, and errorlint categories.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant