Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
make the IDPOrgSync field a pointer to ensure backwards compatibility
  • Loading branch information
hugodutka committed Jan 29, 2025
commit 07057b173c99ee9cb799a190b43330b03db373d6
6 changes: 4 additions & 2 deletions coderd/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (r *remoteReporter) deployment() error {
MachineID: sysInfo.UniqueID,
StartedAt: r.startedAt,
ShutdownAt: r.shutdownAt,
IDPOrgSync: idpOrgSync,
IDPOrgSync: &idpOrgSync,
})
if err != nil {
return xerrors.Errorf("marshal deployment: %w", err)
Expand Down Expand Up @@ -1034,7 +1034,9 @@ type Deployment struct {
MachineID string `json:"machine_id"`
StartedAt time.Time `json:"started_at"`
ShutdownAt *time.Time `json:"shutdown_at"`
IDPOrgSync bool `json:"idp_org_sync"`
// While IDPOrgSync will always be set, it's nullable to make
// the struct backwards compatible with older coder versions.
IDPOrgSync *bool `json:"idp_org_sync"`
}

type APIKey struct {
Expand Down
6 changes: 3 additions & 3 deletions coderd/telemetry/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func TestTelemetry(t *testing.T) {

// 1. No org sync settings
deployment, _ := collectSnapshot(t, db, nil)
require.False(t, deployment.IDPOrgSync)
require.False(t, *deployment.IDPOrgSync)

// 2. Org sync settings set in server flags
deployment, _ = collectSnapshot(t, db, func(opts telemetry.Options) telemetry.Options {
Expand All @@ -289,7 +289,7 @@ func TestTelemetry(t *testing.T) {
}
return opts
})
require.True(t, deployment.IDPOrgSync)
require.True(t, *deployment.IDPOrgSync)

// 3. Org sync settings set in runtime config
org, err := db.GetDefaultOrganization(ctx)
Expand All @@ -304,7 +304,7 @@ func TestTelemetry(t *testing.T) {
})
require.NoError(t, err)
deployment, _ = collectSnapshot(t, db, nil)
require.True(t, deployment.IDPOrgSync)
require.True(t, *deployment.IDPOrgSync)
})
}

Expand Down
Loading