|
| 1 | +# Migration guide |
| 2 | + |
| 3 | +## 1\. Update imports |
| 4 | + |
| 5 | +linodego v2 uses a Go major-version module path. |
| 6 | + |
| 7 | +Change all imports from: |
| 8 | + |
| 9 | +```go |
| 10 | +import "github.com/linode/linodego" |
| 11 | +``` |
| 12 | + |
| 13 | +to: |
| 14 | + |
| 15 | +```go |
| 16 | +import "github.com/linode/linodego/v2" |
| 17 | +``` |
| 18 | + |
| 19 | +If you use the helper Kubernetes package, also change: |
| 20 | + |
| 21 | +```go |
| 22 | +import "github.com/linode/linodego/k8s" |
| 23 | +``` |
| 24 | + |
| 25 | +to: |
| 26 | + |
| 27 | +```go |
| 28 | +import "github.com/linode/linodego/v2/k8s" |
| 29 | +``` |
| 30 | + |
| 31 | +Also update your module dependencies: |
| 32 | + |
| 33 | +```shell |
| 34 | +go get github.com/linode/linodego/v2 |
| 35 | +go get github.com/linode/linodego/v2/k8s # if you import the Kubernetes helper module |
| 36 | +go mod tidy |
| 37 | +``` |
| 38 | + |
| 39 | +## 2\. Handle NewClient errors |
| 40 | + |
| 41 | +NewClient changed from returning only a Client to returning (Client, error). |
| 42 | + |
| 43 | +### NewClient in linodego v1 |
| 44 | + |
| 45 | +```go |
| 46 | +linodeClient := linodego.NewClient(oauth2Client) |
| 47 | +``` |
| 48 | + |
| 49 | +### NewClient in linodego v2 |
| 50 | + |
| 51 | +```go |
| 52 | +linodeClient, err := linodego.NewClient(oauth2Client) |
| 53 | +if err != nil { |
| 54 | + return err |
| 55 | +} |
| 56 | +``` |
| 57 | + |
| 58 | +Every call site must now handle an initialization error. |
| 59 | + |
| 60 | +## 3\. Replace removed deprecated APIs, aliases, and compatibility types |
| 61 | + |
| 62 | +linodego v2 removes many deprecated fields, methods, aliases, and compatibility wrappers. |
| 63 | + |
| 64 | +Confirmed removals include: |
| 65 | + |
| 66 | +- MarkEventRead |
| 67 | +- ActionVolumeDelte |
| 68 | +- ActionCreateCardUpdated |
| 69 | +- AccountMaintenance.When |
| 70 | +- Domain.Group |
| 71 | +- LinodeKernel.XEN |
| 72 | +- MonitorAlertDefinition |
| 73 | +- CapabilityObjectStorageRegions |
| 74 | +- MutateInstance |
| 75 | +- LKEClusterDashboard |
| 76 | +- GetLKEClusterDashboard |
| 77 | +- ObjectStorageCluster |
| 78 | +- ListObjectStorageClusters |
| 79 | +- GetObjectStorageCluster |
| 80 | +- legacy paged response compatibility types |
| 81 | +- deprecated LKE cluster pool compatibility aliases and methods |
| 82 | + |
| 83 | +If your code still references any of these, it must be updated before moving to v2. |
| 84 | + |
| 85 | +Common replacements include: |
| 86 | + |
| 87 | +- MarkEventRead → MarkEventsSeen |
| 88 | +- ActionVolumeDelte → ActionVolumeDelete |
| 89 | +- ActionCreateCardUpdated → ActionCreditCardUpdated |
| 90 | +- MutateInstance → UpgradeInstance |
| 91 | +- LKEClusterPool\* → LKENodePool\* |
| 92 | + |
| 93 | +## 4\. Replace removed preview/temporary V2 compatibility APIs |
| 94 | + |
| 95 | +Some preview or temporary V2\-suffixed APIs and types were removed in linodego v2. |
| 96 | + |
| 97 | +**Migration rule:** in these areas, the old V2 forms were removed and the supported v2 surface now uses the original non-V2 names. In some cases this is effectively the same V2 behavior under the old name; in others, there are also related parameter, field-shape, or surrounding API changes. |
| 98 | +If you were already using the V2 form in v1, migrate to the corresponding supported non-V2 name in v2 and review any nearby type or behavior changes. |
| 99 | + |
| 100 | +Affected removed V2 preview/temporary compatibility APIs and types include: |
| 101 | + |
| 102 | +- GetInstanceTransferMonthlyV2 |
| 103 | +- MonthlyInstanceTransferStatsV2 |
| 104 | +- ObjectStorageBucketCertV2 |
| 105 | +- UploadObjectStorageBucketCertV2 |
| 106 | +- GetObjectStorageBucketCertV2 |
| 107 | +- ObjectStorageObjectACLConfigV2 |
| 108 | +- GetObjectStorageObjectACLConfigV2 |
| 109 | +- UpdateObjectStorageObjectACLConfigV2 |
| 110 | +- IPAddressUpdateOptionsV2 |
| 111 | +- UpdateIPAddressV2 |
| 112 | + |
| 113 | +## 5\. Update methods that now take options structs |
| 114 | + |
| 115 | +Many public methods that previously accepted individual primitive parameters for request bodies now take a single typed **options struct** instead. |
| 116 | + |
| 117 | +In practice, request-body attributes are now generally grouped into dedicated ...Options structs and passed as one argument. |
| 118 | + |
| 119 | +This affects a range of APIs, including: |
| 120 | + |
| 121 | +- instance actions |
| 122 | +- disk operations |
| 123 | +- IP operations |
| 124 | +- snapshot creation |
| 125 | +- and similar endpoints |
| 126 | + |
| 127 | +Migration approach: |
| 128 | + |
| 129 | +- find compile errors |
| 130 | +- identify the corresponding ...Options type |
| 131 | +- move the request-body values into that struct |
| 132 | +- pass the struct instead of separate primitive values |
| 133 | + |
| 134 | +This is mostly a mechanical migration. |
| 135 | + |
| 136 | +### Notable exception |
| 137 | + |
| 138 | +One breaking change goes in the opposite direction: |
| 139 | + |
| 140 | +- CloneInstanceDisk(ctx, linodeID, diskID, opts InstanceDiskCloneOptions) |
| 141 | +- became |
| 142 | +- CloneInstanceDisk(ctx, linodeID, diskID) |
| 143 | + |
| 144 | +So if you call CloneInstanceDisk, remove the now-deleted options argument. |
| 145 | + |
| 146 | +## 6\. Migrate firewall APIs |
| 147 | + |
| 148 | +The firewall API had substantial type cleanup. |
| 149 | + |
| 150 | +### Type renames and splits |
| 151 | + |
| 152 | +- FirewallRuleSet → FirewallRules |
| 153 | +- RuleSet → FirewallRuleSet |
| 154 | + |
| 155 | +FirewallRule was split differently depending on which API you are using. |
| 156 | + |
| 157 | +### If you use /firewalls APIs |
| 158 | + |
| 159 | +Replace: |
| 160 | + |
| 161 | +- FirewallRuleSet → FirewallRules |
| 162 | +- FirewallRule → FirewallRuleInbound / FirewallRuleOutbound |
| 163 | + |
| 164 | +Also update create/update payload types to: |
| 165 | + |
| 166 | +- FirewallRulesCreateOptions |
| 167 | +- FirewallRulesUpdateOptions |
| 168 | + |
| 169 | +### If you use /firewalls/rulesets APIs |
| 170 | + |
| 171 | +Replace: |
| 172 | + |
| 173 | +- RuleSet → FirewallRuleSet |
| 174 | +- FirewallRule → FirewallRuleSetRule |
| 175 | +- RuleSetCreateOptions → FirewallRuleSetCreateOptions |
| 176 | +- RuleSetUpdateOptions → FirewallRuleSetUpdateOptions |
| 177 | + |
| 178 | +Also note: |
| 179 | + |
| 180 | +- FirewallRuleSetRule no longer includes description |
| 181 | +- FirewallRuleSetRule no longer includes ruleset |
| 182 | + |
| 183 | +### Additional firewall migration note |
| 184 | + |
| 185 | +Also update any code that assumes: |
| 186 | + |
| 187 | +- FirewallDeviceEntity.Label is string instead of \*string |
| 188 | + |
| 189 | +## 7\. Migrate Object Storage APIs to region-based usage |
| 190 | + |
| 191 | +Object Storage APIs were standardized around **regions** instead of older cluster-oriented naming. |
| 192 | + |
| 193 | +Key changes: |
| 194 | + |
| 195 | +- stop using ObjectStorageBucket.Cluster |
| 196 | +- use region IDs in bucket/object/cert/ACL calls |
| 197 | +- replace ListObjectStorageBucketsInCluster with ListObjectStorageBucketsInRegion |
| 198 | +- remove usage of deleted ObjectStorageCluster APIs |
| 199 | +- GetObjectStorageBucketAccess now returns the newer access shape directly, so no separate V2 access type is needed |
| 200 | +- UpdateObjectStorageBucketAccess now uses PUT |
| 201 | +- ModifyObjectStorageBucketAccess was added as a separate POST |
| 202 | + |
| 203 | +Also note that preview/temporary V2 Object Storage compatibility APIs were removed; use the supported non-V2 names in v2. |
| 204 | + |
| 205 | +## 8\. Migrate IP update APIs |
| 206 | + |
| 207 | +Confirmed changes include: |
| 208 | + |
| 209 | +- IPAddressUpdateOptions is now the main IP update type |
| 210 | +- old split between original and V2 preview/temporary update option types removed |
| 211 | +- instance IP collection types changed from pointer element slices to value element slices in some responses |
| 212 | + |
| 213 | +If you were using preview/temporary IP update V2 APIs in v1, switch to the supported non-V2 names in v2. |
| 214 | + |
| 215 | +## 9\. Remove Resty-specific assumptions |
| 216 | + |
| 217 | +The client internals were migrated from Resty to net/http. |
| 218 | + |
| 219 | +Observable changes for advanced users: |
| 220 | + |
| 221 | +- Request now maps to http.Request |
| 222 | +- Response now maps to http.Response |
| 223 | +- Logger is now a local interface, not Resty’s logger |
| 224 | +- OnBeforeRequest / OnAfterResponse now use \*http.Request / \*http.Response |
| 225 | + |
| 226 | +If your code used Resty-specific fields or methods in callbacks, rewrite those hook implementations against net/http. |
| 227 | + |
| 228 | +## 10\. Update region capability usages if needed |
| 229 | + |
| 230 | +In regions.go, region capability constants changed from plain string constants to the custom RegionCapability type. |
| 231 | + |
| 232 | +In many places this will work transparently, but code that relies on untyped string constant behavior may need small adjustments where exact types matter. |
| 233 | + |
| 234 | +## 11\. Audit request/response type shape changes |
| 235 | + |
| 236 | +A broad pattern in v2 is cleanup of pointer-heavy request/response types. |
| 237 | + |
| 238 | +Common examples include: |
| 239 | + |
| 240 | +- \[\]\*T → \[\]T |
| 241 | +- \*\[\]string → \[\]string |
| 242 | +- some string fields becoming pointers where nullable semantics are needed |
| 243 | +- split create/update types for request payloads |
| 244 | + |
| 245 | +Review any code that depends on: |
| 246 | + |
| 247 | +- nil checks |
| 248 | +- pointer identity |
| 249 | +- distinguishing “unset” from “empty” |
| 250 | +- mutation of shared slices |
| 251 | + |
| 252 | +## 12\. Validate request payload behavior |
| 253 | + |
| 254 | +A large number of JSON tags changed from omitempty to omitzero. |
| 255 | + |
| 256 | +If your application depends on subtle update semantics such as “clear vs omit”, run integration tests against affected APIs before rollout. |
| 257 | + |
| 258 | +## 13\. Review retry, logging, and error handling integrations |
| 259 | + |
| 260 | +The retry, logging, and error handling layers changed along with the HTTP client rewrite. |
| 261 | + |
| 262 | +Confirmed changes include: |
| 263 | + |
| 264 | +- retry condition callback types now use \*http.Response |
| 265 | +- retry-after callback types now use \*http.Response |
| 266 | +- retry helper names are now exported/capitalized |
| 267 | +- logger behavior is no longer tied to Resty |
| 268 | +- error handling is now centered around http.Response instead of Resty responses |
| 269 | + |
| 270 | +If your code directly integrates with retry helpers, logging hooks, or response-backed errors, review those call sites carefully. |
| 271 | + |
| 272 | +## 14\. Suggested upgrade workflow |
| 273 | + |
| 274 | +1. Update imports to /v2 |
| 275 | +2. Run go get and go mod tidy |
| 276 | +3. Fix NewClient call sites |
| 277 | +4. Fix compile errors from removed deprecated APIs and aliases |
| 278 | +5. Fix usages of removed preview/temporary V2 compatibility APIs by switching to the supported non-V2 names |
| 279 | +6. Fix methods that now take typed options structs |
| 280 | +7. Fix firewall and object-storage type changes |
| 281 | +8. Fix request hook code that assumed Resty types |
| 282 | +9. Review any code depending on region capability constants as plain strings |
| 283 | +10. Run integration tests, especially around update payloads and object/firewall APIs |
0 commit comments