February 10, 2025
Welcome to 2025! With this release of opslevel-go we have made a series of breaking changes in opslevel-go around how we handle pushing "null" through to our API. Historically we've not been able to do this consistently on input type fields because JSON struct tags omitempty
works differently depending on the target field type, especially when you get pointers involved. Additionally some of our API mutations for update differentiate functionality between null
and ""
(empty) - which gets even more complicated by custom scalar types and such.
So for nearly every input type field we need 4 logical states the field can be in:
- not present in the json variables
- present but json
null
AKA "unset" during update mutations - present but empty state
- present but filled state
For example with a string
type this is not possible today with only *string
so we've introduced a new wrapper type Nullable[T]
that has special JSON marshalling that gives us the 2nd state above - present but json null
This is a pretty big sweeping change to opslevel-go and any usages of it are going to need a refactor when you build out the data for your input types. Where before you might have had:
desc := "Hello World"
input := opslevel.DomainInput{
Description: &desc
}
you will now need
input := opslevel.DomainInput{
Description: opslevel.RefOf("Hello World")
}
For types other then standard go types it may become a bit more complicated. Please check out the tests for the resource types you are having issues with to get a sense for what you need to do.
Codegen
Additionally if you've been following the project for a while you'll know what we've been trying to codegenerate the client library for sometime now. 2025 takes us 1 step closer to having more structures under code generation. Additionally we've moved the codegen out to a separate repository - https://github.com/OpsLevel/client-gen
Over the course of 2025 we will continue to keep pushing more and more of the client library to be generated and we may take on expanding that out to other languages - python, javascript, rust, etc
Feature
- 'metadata' field has been added to AlertSource struct
- 'description' field has been added to Category struct
- Struct 'Scorecard' has been updated to match all the fields possible in the API
- Add ability to CRUD 'ComponentType'
- Add aliases functions for CRUD components that use the old services CRUD functions
- Add support for the
provisionedBy
field on User type
Refactor
- BREAKING CHANGE: "Nullable" type now wraps some optional struct fields of API input objects. This "Nullable" type enables fields to be set to the JSON "null" value.
- convert enum consts into vars for easier pointer referencing
- enums converted from consts to vars, e.g. opslevel.RefOf(opslevel.AlertSourceTypeEnumDatadog) should now be &opslevel.AlertSourceTypeEnumDatadog
- BREAKING CHANGE: 'OpsLevelErrors' has been renamed to 'Error'
- BREAKING CHANGE: Struct 'GoogleCloudProject' fields
ID
andURL
are nowId
andUrl
respectively - Field 'ChecksCount' has been renamed to 'TotalChecks' on the struct 'Scorecard' to match the API definition
- Field 'ID' on struct 'Secret' has been renamed to 'Id' for consistency
- BREAKING CHANGE: struct 'OpsLevelWarnings' was renamed to 'Warning'
- BREAKING CHANGE: client.GetService now properly takes in an identifier and calls the appropreate queries for alias or id
- BREAKING CHANGE: the
notes
field on check input types doesn't supportnull
only""
and"filled"
values or not present.
Removed
- removed NullableString func, no longer used
Dependency
- Bump github.com/gosimple/slug from 1.14.0 to 1.15.0
- Bump github.com/go-playground/validator/v10 from 10.23.0 to 10.24.0
- Bump github.com/go-resty/resty/v2 from 2.16.2 to 2.16.5