Note: This tool is related to the Azure-SDK-for-Go, but not truly part of it. As such, the SemVers associated with this repository do not extend to the packages associated with
Azure Profiles offer a means of virtualizing the API Versions of services that should be targeted by an application or SDK. This concept was introduced for Azure Stack, where the environment in which applications will be executed is less consistent than when targeting the public cloud. However, its usefulness as a means of easily snapping to versions of a service is broadly applicapable. Using profiles, it is easy to use a single version of models and operations throughout an application, or a means of locking to versions of services that have been tested and are guaranteed to work together.
Type aliases were introduced in Go 1.9, effectively allowing for multiple symbols to be mapped to a single type. The impact of this for our support of profiles is tremendous. It allows for seamless interoperability between packages using different profiles, but where those profiles still target the same API Version of a service. Without type aliases, we would have been forced to generate code in a way that required some ugly casts to be scattered throughout the consumer's code.
The simplest version of installation is very easy but not stable, just run the following command:
go get -u github.com/Azure/azure-sdk-for-go/tools/profileBuilder
If that causes you trouble, run the following commands:
# bash go get -d github.com/Azure/azure-sdk-for-go/tools/profileBuilder cd $GOPATH/src/github.com/Azure/azure-sdk-for-go/tools/profileBuilder go install
# PowerShell go get -d github.com/Azure/azure-sdk-for-go/tools/profileBuilder cd $env:GOPATH\src\github.com\Azure\azure-sdk-for-go\tools\profileBuilder go install
Once installed, running
profileBuilder should be straight-forward. Each sub-command is a different strategy for finding the packages to include in the profile. The most flexible and broadly applicable sub-command is
For the first example, we'll use the
list sub-command without any commands. It will read from
stdin, looking for line delimited Go package names.
$> profileBuilder list github.com/Azure/azure-sdk-for-go/services/logic/mgmt/2016-06-01/logic github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2017-02-01/redis
Because we didn't specify a name for this profile, a random one will be generated. Assuming that it chooses the name
YellowIceberg84, the files that would be produced would be in the structure:
$GOPATH /src | /github.com | | /Azure | | | /azure-sdk-for-go | | | | /profiles | | | | | /YellowIceberg84 | | | | | | /logic | | | | | | | /mgmt | | | | | | | | /logic | | | | | | | | | models.go | | | | | | /redis | | | | | | | /mgmt | | | | | | | | /redis | | | | | | | | | models.go
Each of the files named
models.go is composed of type definitions which will either duplicate or delegate all calls back to the original package's definition.
Clearly, typing each package name on demand, as profiles needs to be generated is error-prone and inconvenient. For that reason, using the piping operator to read the contents of a file into
stdin is a much better idea. Using the file:
<myProfileDefinition.txt> github.com/Azure/azure-sdk-for-go/services/logic/mgmt/2016-06-01/logic github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2017-02-01/redis
Will allow for the command:
$> cat myProfileDefinition.txt | profileBuilder list
This command then yields the same results as the first example.
latest command reflects on the packages in the
services directory of the Azure-SDK-for-Go, and picks the most up-to-date API Versions for inclusion in a profile. Optionally, it will include API Versions that are labeled as "preview".
When using the
list sub-command, instead of reading from stdin, read from the file specified .
The behavior of
profileBuilder can be confured by passing in command-line arguments as flags. If you have any doubt or question about how a command operates, pass
profileBuilder to get a brief description of the command you're using, and all of the arguments it accepts.
You can opt-to not have
profileBuilder use a randomly generated name for your profile by passing this argument.
The directory that profileBuilder should use to write the profile that is created.
latest command is iterating over the known Azure-SDK-for-Go packages, it needs to decide whether or not to disclude versions it deems "preview" versions. The
latest command relies of the suffix "-preview" at the end of the API Version name to make this determination.
If you're looking for more information about the intermediate status of
profileBuilder, this flag is for you. It may be most useful if you're not seeing the API Version you expected in your profile.
go generate command cat take the place of
make in some circumstances. The big benefit of using it is that it ships with
go, and is more portable than
make. To use it, one simply adds a comment into a Go source file that invokes an arbitrary command. When combined with the
profileBuilder, this can be a powerful combination.
There is no documentation for this package.