Skip to content

feat: Upgrade to SDK v2 and add new resources/data sources - #21

Open
aamirk-splunk wants to merge 5 commits into
splunk:masterfrom
aamirk-splunk:feat/sdk-v2-upgrade-and-new-resources
Open

feat: Upgrade to SDK v2 and add new resources/data sources#21
aamirk-splunk wants to merge 5 commits into
splunk:masterfrom
aamirk-splunk:feat/sdk-v2-upgrade-and-new-resources

Conversation

@aamirk-splunk

Copy link
Copy Markdown

BREAKING CHANGES:

  • Upgraded from terraform-plugin-sdk v1.8.0 to v2.31.0
  • Upgraded Go version from 1.14 to 1.22

NEW RESOURCES:

  • victorops_user_contact_email: Manage user email contact methods
  • victorops_user_contact_phone: Manage user phone contact methods
  • victorops_scheduled_override: Manage scheduled overrides with assignments
  • victorops_maintenance_mode: Manage maintenance windows (start/end lifecycle)
  • victorops_alert_rule: Manage alert routing rules
  • victorops_user_paging_policy: Manage user paging policies (steps and rules)

NEW DATA SOURCES:

  • victorops_users: List users with optional email filter
  • victorops_routing_keys: List all routing keys
  • victorops_team_admins: List team administrators
  • victorops_rotations: List team rotations
  • victorops_team_oncall_schedule: Get team on-call schedule
  • victorops_user_devices: List user contact devices (read-only)

IMPROVEMENTS:

  • Added rate limiting (2 req/sec) to prevent API throttling
  • Added retry logic with exponential backoff for transient errors
  • Added ImportState support to existing resources
  • Added deprecation warning for is_admin field on user resource
  • Migrated all resources to use context.Context and diag.Diagnostics
  • Added comprehensive acceptance tests for all new features
  • Updated CI workflow for Go 1.22

KNOWN LIMITATIONS:

  • Alert rule routing_key not returned by API on GET (preserved from config)
  • Maintenance mode is ForceNew (API only supports start/end, no update)
  • User devices are read-only (API limitation)

BREAKING CHANGES:
- Upgraded from terraform-plugin-sdk v1.8.0 to v2.31.0
- Upgraded Go version from 1.14 to 1.22

NEW RESOURCES:
- victorops_user_contact_email: Manage user email contact methods
- victorops_user_contact_phone: Manage user phone contact methods
- victorops_scheduled_override: Manage scheduled overrides with assignments
- victorops_maintenance_mode: Manage maintenance windows (start/end lifecycle)
- victorops_alert_rule: Manage alert routing rules
- victorops_user_paging_policy: Manage user paging policies (steps and rules)

NEW DATA SOURCES:
- victorops_users: List users with optional email filter
- victorops_routing_keys: List all routing keys
- victorops_team_admins: List team administrators
- victorops_rotations: List team rotations
- victorops_team_oncall_schedule: Get team on-call schedule
- victorops_user_devices: List user contact devices (read-only)

IMPROVEMENTS:
- Added rate limiting (2 req/sec) to prevent API throttling
- Added retry logic with exponential backoff for transient errors
- Added ImportState support to existing resources
- Added deprecation warning for is_admin field on user resource
- Migrated all resources to use context.Context and diag.Diagnostics
- Added comprehensive acceptance tests for all new features
- Updated CI workflow for Go 1.22

KNOWN LIMITATIONS:
- Alert rule routing_key not returned by API on GET (preserved from config)
- Maintenance mode is ForceNew (API only supports start/end, no update)
- User devices are read-only (API limitation)
- Fix JSON tag: totalMembers -> totalMembersInRotation
- Add complete ShiftDetails with all fields (shiftMembers, shifttype, mask, etc.)
- Add ShiftMember, OnCallPeriod, RotationMask, MaskDays, MaskTimeRange, MaskTime models
- Update Terraform schema to expose all rotation fields
- Update read function to map all nested fields
- Fix MaintenanceModeTarget: use type+names instead of routingKey
- Fix OnCall Schedule: use User objects, ISO8601 strings, PolicySchedule
- Fix Paging Policy: use index field and Contact object
- Update team_oncall_schedule data source schema with nested policy/overrides
- Rotations already correct (no changes needed)

All 14 acceptance tests pass.
The go-victorops library has a bug where UpdateTeam uses team.Name for
the URL path instead of the team slug. This caused team name updates to
fail with 'No team found' errors.

Fix: Added api_team.go with a custom UpdateTeam function that correctly
uses the team slug in the URL path (/api-public/v1/team/{slug}).
Comment thread victorops/data_source_victorops_rotations.go
Comment thread victorops/api_alert_rule.go Outdated
LastUpdatedBy string `json:"lastUpdatedBy,omitempty"`
Notes string `json:"notes,omitempty"`
RouteKey string `json:"routeKey,omitempty"`
RoutingKey string `json:"routingKey,omitempty"`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is only route key, not routing key field

}

// GetAlertRule gets an alert rule by ID
func (c *APIClient) GetAlertRule(ruleID int) (*AlertRule, error) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have only list alert rule, not get alert rule

Comment thread victorops/api_data_sources.go Outdated
// TeamOncallSchedule represents a team's on-call schedule
type TeamOncallSchedule struct {
Team TeamInfo `json:"team,omitempty"`
Schedules []OncallSchedule `json:"schedules,omitempty"`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The object type for Schedules is wrong, it should be

type: object
    properties:
      team:
        $ref: '#/definitions/Team'
      schedules:
        type: array
        items:
          $ref: '#/definitions/PolicySchedule'

API spec clarification:
- Request (POST/PUT) uses 'routingKey' field
- Response (GET) uses 'routeKey' field

Removed RoutingKey from AlertRule struct since it's only for parsing
API responses which use routeKey.
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.

2 participants