Skip to content

V2 Migration

Piszmog edited this page Jun 9, 2021 · 9 revisions

Why a V2?

When I initially developed the library, there was some trickery done to get things to work (e.g. URL buidling), and I was ok with how I built it, but I felt I could do better.

So I decided to create a V2 where I fix some issues that were bugging me, make things easier to use, and remove the inefficient code.

Major Changes from V1 to V2

Config Client

Major changes were mostly centralized around the building of the ConfigClient (now Client).

No longer are there separate functions that need to be called to build a Client. Instead there is a single New function that can be provided a number of options to build the client.

Removal of Util Functions

V1 exposed a number of functions that built or retrieved unrelated data. These have been removed to slim down the APIs and make things easier to maintain.

Additional Resource Functions

V1 allowed only files of type JSON or YAML to be retrieved from the Config Server. Now XML files can be retrieved. Also, for any files that do not fit into these formats (e.g. Text or Properties), there are new functions - GetFileRaw and GetFromFromBranchRaw.

Migration Guide

Building a Client

  • ConfigClient is now Client
  • Functions NewLocalClientFromEnv, NewLocalClient, NewCloudClient, and NewOAuth2Client are removed
    • Use the universal New function and pass options (e.g. LocalEnv, Local, DefaultCFService, and OAuth2)
    • See examples for V2 usages

Retrieve Configurations

  • GetConfiguration no longer takes a slice of strings for the profiles, but is a variadic argument

Util Functions Removed

The following functions have been removed,

  • GetLocalCredentials
  • NewOAuth2HTTPClient
  • NewOAuth2Config
  • GetCloudCredentials

Error Renamed

  • PropertySourceDoesNotExistErr has been renamed to ErrPropertySourceDoesNotExist
  • NotFoundError has been renamed to ErrResourceNotFound