Repository: Azure/azure-sdk-for-go (go)

Issue:
Rename cloud.AzurePublicCloud to cloud.AzurePublic
Per earlier discussion, remove the trailing "Cloud" which is redundant.

Pull request:
Rename AzurePublicCloud -> AzurePublic
Closes #17732.  https://github.com/Azure/autorest.go/pull/810 will make the corresponding codegen change.

Patch:
diff --git a/eng/tools/generator/cmd/v2/common/changlogProcessor.go b/eng/tools/generator/cmd/v2/common/changlogProcessor.go
index 89905a6d89..2a2402f596 100644
--- a/eng/tools/generator/cmd/v2/common/changlogProcessor.go
+++ b/eng/tools/generator/cmd/v2/common/changlogProcessor.go
@@ -15,11 +15,14 @@ import (
 
 	"github.com/Azure/azure-sdk-for-go/eng/tools/generator/repo"
 	"github.com/Azure/azure-sdk-for-go/eng/tools/internal/exports"
+	"github.com/go-git/go-git/v5"
+	"github.com/go-git/go-git/v5/config"
 	"github.com/go-git/go-git/v5/plumbing"
 )
 
 const (
 	sdk_tag_fetch_url = "https://api.github.com/repos/Azure/azure-sdk-for-go/git/refs/tags"
+	sdk_remote_url    = "https://github.com/Azure/azure-sdk-for-go.git"
 )
 
 func GetAllVersionTags(rpName, namespaceName string) ([]string, error) {
@@ -110,6 +113,23 @@ func GetExportsFromTag(sdkRepo repo.SDKRepository, packagePath, tag string) (*ex
 		return nil, err
 	}
 
+	// create remote with center sdk repo
+	remoteName := "release_remote"
+	_, err = sdkRepo.CreateRemote(&config.RemoteConfig{Name: remoteName, URLs: []string{sdk_remote_url}})
+	if err != nil {
+		if err != git.ErrRemoteExists {
+			return nil, err
+		}
+	}
+
+	// fetch tag from remote
+	err = sdkRepo.Fetch(&git.FetchOptions{RemoteName: remoteName, RefSpecs: []config.RefSpec{config.RefSpec(tag + ":" + tag)}})
+	if err != nil {
+		if err.Error() != "already up-to-date" {
+			return nil, err
+		}
+	}
+
 	// checkout to the specific tag
 	err = sdkRepo.CheckoutTag(strings.TrimPrefix(tag, "ref/tags/"))
 	if err != nil {
@@ -130,6 +150,12 @@ func GetExportsFromTag(sdkRepo repo.SDKRepository, packagePath, tag string) (*ex
 		return nil, err
 	}
 
+	// remove remote
+	err = sdkRepo.DeleteRemote(remoteName)
+	if err != nil {
+		return nil, err
+	}
+
 	// restore current change
 	err = sdkRepo.StashPop()
 	if err != nil {
diff --git a/eng/tools/generator/repo/workTree.go b/eng/tools/generator/repo/workTree.go
index 217617d61a..7f949b46a8 100644
--- a/eng/tools/generator/repo/workTree.go
+++ b/eng/tools/generator/repo/workTree.go
@@ -27,6 +27,10 @@ type WorkTree interface {
 	StashPop() error
 	Head() (*plumbing.Reference, error)
 	Tags() (storer.ReferenceIter, error)
+	Remotes() ([]*git.Remote, error)
+	DeleteRemote(name string) error
+	CreateRemote(c *config.RemoteConfig) (*git.Remote, error)
+	Fetch(o *git.FetchOptions) error
 }
 
 type CheckoutOptions git.CheckoutOptions
diff --git a/sdk/azcore/CHANGELOG.md b/sdk/azcore/CHANGELOG.md
index 0e87951b90..7c04a18624 100644
--- a/sdk/azcore/CHANGELOG.md
+++ b/sdk/azcore/CHANGELOG.md
@@ -6,6 +6,7 @@
 
 ### Breaking Changes
 * Renamed `cloud.Configuration.LoginEndpoint` to `.ActiveDirectoryAuthorityHost`
+* Renamed `cloud.AzurePublicCloud` to `cloud.AzurePublic`
 * Removed `AuxiliaryTenants` field from `arm/ClientOptions` and `arm/policy/BearerTokenOptions`
 * Removed `TokenRequestOptions.TenantID`
 * `Poller[T].PollUntilDone()` now takes an `options *PollUntilDoneOptions` param instead of `freq time.Duration`
diff --git a/sdk/azcore/arm/arm.go b/sdk/azcore/arm/arm.go
index 055353650c..3a0cb64429 100644
--- a/sdk/azcore/arm/arm.go
+++ b/sdk/azcore/arm/arm.go
@@ -17,7 +17,7 @@ func init() {
 		Audience: "https://management.core.usgovcloudapi.net",
 		Endpoint: "https://management.usgovcloudapi.net",
 	}
-	cloud.AzurePublicCloud.Services[cloud.ResourceManager] = cloud.ServiceConfiguration{
+	cloud.AzurePublic.Services[cloud.ResourceManager] = cloud.ServiceConfiguration{
 		Audience: "https://management.core.windows.net/",
 		Endpoint: "https://management.azure.com",
 	}
diff --git a/sdk/azcore/arm/runtime/pipeline.go b/sdk/azcore/arm/runtime/pipeline.go
index a68054705c..6b9a242cea 100644
--- a/sdk/azcore/arm/runtime/pipeline.go
+++ b/sdk/azcore/arm/runtime/pipeline.go
@@ -46,7 +46,7 @@ func NewPipeline(module, version string, cred azcore.TokenCredential, plOpts azr
 }
 
 func getConfiguration(o *azpolicy.ClientOptions) (cloud.ServiceConfiguration, error) {
-	c := cloud.AzurePublicCloud
+	c := cloud.AzurePublic
 	if !reflect.ValueOf(o.Cloud).IsZero() {
 		c = o.Cloud
 	}
diff --git a/sdk/azcore/cloud/cloud.go b/sdk/azcore/cloud/cloud.go
index 232792ca4c..9d077a3e12 100644
--- a/sdk/azcore/cloud/cloud.go
+++ b/sdk/azcore/cloud/cloud.go
@@ -15,8 +15,8 @@ var (
 	AzureGovernment = Configuration{
 		ActiveDirectoryAuthorityHost: "https://login.microsoftonline.us/", Services: map[ServiceName]ServiceConfiguration{},
 	}
-	// AzurePublicCloud contains configuration for Azure Public Cloud.
-	AzurePublicCloud = Configuration{
+	// AzurePublic contains configuration for Azure Public Cloud.
+	AzurePublic = Configuration{
 		ActiveDirectoryAuthorityHost: "https://login.microsoftonline.com/", Services: map[ServiceName]ServiceConfiguration{},
 	}
 )
diff --git a/sdk/azidentity/azidentity.go b/sdk/azidentity/azidentity.go
index 341601bdd9..7a3e4454eb 100644
--- a/sdk/azidentity/azidentity.go
+++ b/sdk/azidentity/azidentity.go
@@ -42,7 +42,7 @@ func setAuthorityHost(cc cloud.Configuration) (string, error) {
 		if len(cc.Services) > 0 {
 			return "", errors.New("missing ActiveDirectoryAuthorityHost for specified cloud")
 		}
-		host = cloud.AzurePublicCloud.ActiveDirectoryAuthorityHost
+		host = cloud.AzurePublic.ActiveDirectoryAuthorityHost
 		if envAuthorityHost := os.Getenv(azureAuthorityHost); envAuthorityHost != "" {
 			host = envAuthorityHost
 		}


Test patch:
diff --git a/sdk/azcore/arm/runtime/pipeline_test.go b/sdk/azcore/arm/runtime/pipeline_test.go
index 239bce745a..056a1c3a2d 100644
--- a/sdk/azcore/arm/runtime/pipeline_test.go
+++ b/sdk/azcore/arm/runtime/pipeline_test.go
@@ -167,7 +167,7 @@ func TestPipelineWithCustomPolicies(t *testing.T) {
 }
 
 func TestPipelineAudience(t *testing.T) {
-	for _, c := range []cloud.Configuration{cloud.AzureChina, cloud.AzureGovernment, cloud.AzurePublicCloud} {
+	for _, c := range []cloud.Configuration{cloud.AzureChina, cloud.AzureGovernment, cloud.AzurePublic} {
 		srv, close := mock.NewServer()
 		defer close()
 		srv.AppendResponse(mock.WithStatusCode(200))
diff --git a/sdk/azidentity/azidentity_test.go b/sdk/azidentity/azidentity_test.go
index e936ba15ad..10c33ac5ab 100644
--- a/sdk/azidentity/azidentity_test.go
+++ b/sdk/azidentity/azidentity_test.go
@@ -156,7 +156,7 @@ func setEnvironmentVariables(t *testing.T, vars map[string]string) {
 }
 
 func Test_WellKnownHosts(t *testing.T) {
-	for _, cloud := range []cloud.Configuration{cloud.AzureChina, cloud.AzureGovernment, cloud.AzurePublicCloud} {
+	for _, cloud := range []cloud.Configuration{cloud.AzureChina, cloud.AzureGovernment, cloud.AzurePublic} {
 		host, err := setAuthorityHost(cloud)
 		if err != nil {
 			t.Fatal(err)
@@ -196,7 +196,7 @@ func Test_DefaultAuthorityHost(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	if authorityHost != cloud.AzurePublicCloud.ActiveDirectoryAuthorityHost {
+	if authorityHost != cloud.AzurePublic.ActiveDirectoryAuthorityHost {
 		t.Fatal("unexpected default host: " + authorityHost)
 	}
 }