Skip to content

Commit

Permalink
fmt with Go 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
chlowell committed Aug 9, 2022
1 parent c57ca65 commit e516894
Show file tree
Hide file tree
Showing 48 changed files with 441 additions and 431 deletions.
8 changes: 5 additions & 3 deletions sdk/azidentity/default_azure_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ type DefaultAzureCredentialOptions struct {
// DefaultAzureCredential is a default credential chain for applications that will deploy to Azure.
// It combines credentials suitable for deployment with credentials suitable for local development.
// It attempts to authenticate with each of these credential types, in the following order, stopping when one provides a token:
// EnvironmentCredential
// ManagedIdentityCredential
// AzureCLICredential
//
// EnvironmentCredential
// ManagedIdentityCredential
// AzureCLICredential
//
// Consult the documentation for these credential types for more information on how they authenticate.
// Once a credential has successfully authenticated, DefaultAzureCredential will use that credential for
// every subsequent authentication.
Expand Down
6 changes: 3 additions & 3 deletions sdk/azidentity/environment_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ type EnvironmentCredentialOptions struct {
// EnvironmentCredential authenticates a service principal with a secret or certificate, or a user with a password, depending
// on environment variable configuration. It reads configuration from these variables, in the following order:
//
// Service principal with client secret
// # Service principal with client secret
//
// AZURE_TENANT_ID: ID of the service principal's tenant. Also called its "directory" ID.
//
// AZURE_CLIENT_ID: the service principal's client ID
//
// AZURE_CLIENT_SECRET: one of the service principal's client secrets
//
// Service principal with certificate
// # Service principal with certificate
//
// AZURE_TENANT_ID: ID of the service principal's tenant. Also called its "directory" ID.
//
Expand All @@ -46,7 +46,7 @@ type EnvironmentCredentialOptions struct {
//
// AZURE_CLIENT_CERTIFICATE_PASSWORD: (optional) password for the certificate file.
//
// User with username and password
// # User with username and password
//
// AZURE_TENANT_ID: (optional) tenant to authenticate in. Defaults to "organizations".
//
Expand Down
42 changes: 19 additions & 23 deletions sdk/data/azcosmos/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
Package azcosmos implements the client to interact with the Azure Cosmos DB SQL API.
The azcosmos package is capable of:
- Creating, deleting, and reading databases in an account
- Creating, deleting, updating, and reading containers in a database
- Creating, deleting, replacing, upserting, and reading items in a container
- Creating, deleting, and reading databases in an account
- Creating, deleting, updating, and reading containers in a database
- Creating, deleting, replacing, upserting, and reading items in a container
Creating the Client
# Creating the Client
Types of Credentials
The clients support different forms of authentication. The azcosmos library supports
authorization via Azure Active Directory or an account key.
Using Azure Active Directory
To create a client, you can use any of the TokenCredential implementations provided by `azidentity`.
cred, err := azidentity.NewClientSecretCredential("tenantId", "clientId", "clientSecret")
handle(err)
client, err := azcosmos.NewClient("myAccountEndpointURL", cred, nil)
handle(err)
Using account keys
To create a client, you will need the account's endpoint URL and a key credential.
Expand All @@ -32,34 +32,30 @@ To create a client, you will need the account's endpoint URL and a key credentia
client, err := azcosmos.NewClientWithKey("myAccountEndpointURL", cred, nil)
handle(err)
Using connection string
To create a client, you will need the account's connection string.
client, err := azcosmos.NewClientFromConnectionString("myConnectionString", nil)
handle(err)
Key Concepts
# Key Concepts
The following are relevant concepts for the usage of the client:
- A client is a connection to an Azure Cosmos DB account.
- An account can have multiple databases, and the client allows you to create, read, and delete databases.
- A database can have multiple containers, and the client allows you to create, read, update, and delete containers, and to modify throughput provision.
- Information is stored as items inside containers and the client allows you to create, read, update, and delete items in containers.
- A client is a connection to an Azure Cosmos DB account.
- An account can have multiple databases, and the client allows you to create, read, and delete databases.
- A database can have multiple containers, and the client allows you to create, read, update, and delete containers, and to modify throughput provision.
- Information is stored as items inside containers and the client allows you to create, read, update, and delete items in containers.
More Examples
# More Examples
The following sections provide several code snippets covering some of the most common Table tasks, including:
- Creating a database
- Creating a container
- Creating, reading, and deleting items
- Querying items
- Using Transactional Batch
- Creating a database
- Creating a container
- Creating, reading, and deleting items
- Querying items
- Using Transactional Batch
Creating a database
# Creating a database
Create a database and obtain a `DatabaseClient` to perform operations on your newly created database.
Expand All @@ -73,8 +69,7 @@ Create a database and obtain a `DatabaseClient` to perform operations on your ne
database, err := azcosmos.NewDatabase("myDatabase")
handle(err)
Creating a container
# Creating a container
Create a container on an existing database and obtain a `ContainerClient` to perform operations on your newly created container.
Expand Down Expand Up @@ -145,6 +140,7 @@ Querying items
}
Querying items with parametrized queries
&opt := azcosmos.QueryOptions{
azcosmos.QueryParameters: []QueryParameter{
{"@value", "2"},
Expand Down
2 changes: 1 addition & 1 deletion sdk/data/azcosmos/shared_key_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (c *KeyCredential) buildCanonicalizedAuthHeaderFromRequest(req *policy.Requ
return value, nil
}

//where date is like time.RFC1123 but hard-codes GMT as the time zone
// where date is like time.RFC1123 but hard-codes GMT as the time zone
func (c *KeyCredential) buildCanonicalizedAuthHeader(method, resourceType, resourceAddress, xmsDate, tokenType, version string) string {
if method == "" || resourceType == "" {
return ""
Expand Down
4 changes: 2 additions & 2 deletions sdk/data/aztables/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ func newListEntitiesPage(resp generated.TableClientQueryEntitiesResponse) (ListE
//
// NewListEntitiesPager returns a Pager, which allows iteration through each page of results. Use nil for listOptions if you want to use the default options.
// For more information about writing query strings, check out:
// - API Documentation: https://docs.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities
// - README samples: https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/data/aztables/README.md#writing-filters
// - API Documentation: https://docs.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities
// - README samples: https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/data/aztables/README.md#writing-filters
func (t *Client) NewListEntitiesPager(listOptions *ListEntitiesOptions) *runtime.Pager[ListEntitiesResponse] {
if listOptions == nil {
listOptions = &ListEntitiesOptions{}
Expand Down
35 changes: 16 additions & 19 deletions sdk/data/aztables/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
// license that can be found in the LICENSE file.

/*
Package aztables can access an Azure Storage or CosmosDB account.
The aztables package is capable of:
- Creating, deleting, and listing tables in an account
- Creating, deleting, updating, and querying entities in a table account
- Creating Shared Access Signatures for authentication
- Creating, deleting, and listing tables in an account
- Creating, deleting, updating, and querying entities in a table account
- Creating Shared Access Signatures for authentication
Creating the Client
# Creating the Client
The Azure Data Tables library allows you to interact with two types of resources:
* the tables in your account
Expand All @@ -28,14 +27,13 @@ URL and a credential that allows you to access the account.
serviceClient, err := aztables.NewServiceClient("https://<my_account_name>.table.core.windows.net/", cred, nil)
handle(err)
Types of Credentials
# Types of Credentials
The clients support different forms of authentication. The aztables library supports
any of the `azcore.TokenCredential` interfaces, authorization via a Connection String,
or authorization with a Shared Access Signature token.
Using a Shared Key
# Using a Shared Key
To use an account shared key (aka account key or access key), provide the key as a string.
This can be found in your storage account in the Azure Portal under the "Access Keys" section.
Expand Down Expand Up @@ -74,8 +72,7 @@ ServiceClient.GetAccountSASToken or Client.GetTableSASToken() functions.
sasService, err := aztables.NewServiceClient(sasUrl, azcore.AnonymousCredential(), nil)
handle(err)
Key Concepts
# Key Concepts
Common uses of the Table service included:
* Storing TBs of structured data capable of serving web scale applications
Expand All @@ -93,13 +90,14 @@ through the use of a dedicated client object.
Two different clients are provided to interact with the various components of the Table Service:
1. **`ServiceClient`** -
* Get and set account setting
* Query, create, and delete tables within the account.
* Get a `Client` to access a specific table using the `NewClient` method.
- Get and set account setting
- Query, create, and delete tables within the account.
- Get a `Client` to access a specific table using the `NewClient` method.
2. **`Client`** -
* Interacts with a specific table (which need not exist yet).
* Create, delete, query, and upsert entities within the specified table.
* Create or delete the specified table itself.
- Interacts with a specific table (which need not exist yet).
- Create, delete, query, and upsert entities within the specified table.
- Create or delete the specified table itself.
Entities are similar to rows. An entity has a PartitionKey, a RowKey, and a set of properties.
A property is a name value pair, similar to a column. Every entity in a table does not need to
Expand All @@ -122,16 +120,15 @@ ensure proper round-trip serialization of all properties.
}
}
More Examples
# More Examples
The following sections provide several code snippets covering some of the most common Table tasks, including:
* Creating a table
* Creating entities
* Querying entities
Creating a Table
# Creating a Table
Create a table in your account and get a `Client` to perform operations on the newly created table:
Expand Down
4 changes: 2 additions & 2 deletions sdk/data/aztables/service_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ func fromGeneratedTableResponseProperties(g *generated.TableResponseProperties)
//
// NewListTablesPager returns a Pager, which allows iteration through each page of results. Specify nil for listOptions if you want to use the default options.
// For more information about writing query strings, check out:
// - API Documentation: https://docs.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities
// - README samples: https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/data/aztables/README.md#writing-filters
// - API Documentation: https://docs.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities
// - README samples: https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/data/aztables/README.md#writing-filters
func (t *ServiceClient) NewListTablesPager(listOptions *ListTablesOptions) *runtime.Pager[ListTablesResponse] {
if listOptions == nil {
listOptions = &ListTablesOptions{}
Expand Down
3 changes: 1 addition & 2 deletions sdk/messaging/azeventhubs/internal/go-amqp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ func randString(n int) string {

// linkKey uniquely identifies a link on a connection by name and direction.
//
// A link can be identified uniquely by the ordered tuple
// (source-container-id, target-container-id, name)
// A link can be identified uniquely by the ordered tuple (source-container-id, target-container-id, name).
// On a single connection the container ID pairs can be abbreviated
// to a boolean flag indicating the direction of the link.
type linkKey struct {
Expand Down
Loading

0 comments on commit e516894

Please sign in to comment.