Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi environment support #47

Closed
wants to merge 1 commit into from
Closed

Multi environment support #47

wants to merge 1 commit into from

Conversation

anweiss
Copy link

@anweiss anweiss commented Feb 15, 2015

Adds support for declaring a custom service management endpoint. Referencing #40

@@ -36,8 +37,14 @@ func NewAnonymousClient() Client {

//NewClientFromPublishSettingsFile creates a new azure.Client and imports the publish
//settings from the specified file path.
func NewClientFromPublishSettingsFile(publishSettingsFilePath string) (Client, error) {
client := Client{}
func NewClientFromPublishSettingsFile(publishSettingsFilePath string, serviceManagementURL ...string) (Client, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ...string?

@ahmetb
Copy link
Contributor

ahmetb commented Feb 15, 2015

Please squash changes to 1 commit. I see some intermediate confusing commits that contributes no delta to the PR.

@anweiss
Copy link
Author

anweiss commented Feb 16, 2015

squashed commits, cleaned up base URL declaration. Not sure if this is right approach but learning process for me :)

self.client.WaitAsyncOperation(requestId)

return nil
return self.client.WaitAsyncOperation(requestId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are fixed already. Please rebase.

@anweiss
Copy link
Author

anweiss commented Feb 16, 2015

not sure how else to consolidate the number of functions here

}

client.baseURL = baseURL
err := client.importPublishSettings(subscriptionID, managementCertificatePath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can directly return this line

@anweiss
Copy link
Author

anweiss commented Feb 16, 2015

fixed the rebase issue (hunk kept getting staged for some reason)...modified return statements and updated constant to more friendly name. slowly getting the hang of these conventions :)

err := client.importPublishSettingsFile(publishSettingsFilePath)
if err != nil {
return client, err
}
return client, nil

return Client{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is particularly bad because if somebody sets client.XXX = YYY, you'll construct a new client :) Also have you noticed that these return Client{baseURL:baseURL},nil snippets are identical? Maybe a new method? 😉

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, yep, missed that one...will update that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not entirely bad. I'm also fine with previous version like you set baseURL at the end. but it's probably better to have a newClient(baseURL) method and maybe even return *Client to get rid of being have to declare var client Client...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So returning a pointer was what I was thinking initially based on other API SDKs I've perused, but didn't want to do too much re-factoring...I guess at this point it wouldn't hurt

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually recently decided to not to pass *Client to management libraries because then they can modify it. However if we return *Client here, then we expect people to initialize clients like virtualmachine.NewClient(*client) which is vague because they need to figure out deferencing it with *. It doesn't really sound idiomatic.

@jeffmendoza
Copy link

Can we leave the existing factories unchanged?

@anweiss
Copy link
Author

anweiss commented Feb 16, 2015

We could...although, I feel like the client factories start to become unwieldy as we add more of them to support different parameter sets

@ahmetb
Copy link
Contributor

ahmetb commented Feb 16, 2015

@anweiss +1. as we develop this the factory method will just keep getting bigger. it makes sense to at least have one very simple factory and one with multiple parameters or a Config object.

@jeffmendoza
Copy link

Sorry, I mean the function signatures, not the implementation.

@ahmetb
Copy link
Contributor

ahmetb commented Feb 16, 2015

@jeffmendoza yep I'm aware. But we already broke everything. I thought it would be fine. Any specific reasons to not to break this?

Maybe we can keep NewClient same and add NewClientFromConfig.

@anweiss
Copy link
Author

anweiss commented Feb 16, 2015

I'm not sure I like the way the publishsettings file/management certs are imported either...which impacts the design of these clients. Currently, the importPublishSettingsFile function simply takes the first subscription tag and assumes it to be the active. We may want to modify this function to accept both a publishsettings file path and subscription ID...that way we can eliminate the redundancy of the importPublishSettings function and simplify the client model by accepting a config object with: publishSettingsFilePath, subscriptionID, and managementURL.

@ahmetb
Copy link
Contributor

ahmetb commented Feb 16, 2015

@anweiss +1 and actually we shouldn't ask for publishSettingsFilePath, user should be responsible of loading that somewhere and just passing the cert object or []byte of the file to us. 😄 Many other client libraries we have also accept .publishSettings file in the constructur but mostly their common use case is NewClient(subscriptionId, subscriptionCert, certPassword)

@jeffmendoza
Copy link

Ah ok, makes sense. I think keeping the "first found" publishsettings file options would be good for some cases, but also specifying which sub to use would be a great addition.

Agree with taking in a byte array for these file.

@anweiss
Copy link
Author

anweiss commented Feb 18, 2015

SubscriptionKey looks to be the private key as part of a pair of PEM encoded data as passed to the X509KeyPair function. In this case, the public/private keys are the same.

@anweiss
Copy link
Author

anweiss commented Feb 18, 2015

Going to close and re-open this PR to clean things up

@anweiss anweiss closed this Feb 18, 2015
@anweiss anweiss deleted the multi-env branch February 18, 2015 18:28
@ahmetb
Copy link
Contributor

ahmetb commented Feb 18, 2015

@anweiss I hate when people do that unless absolutely necessary :-)

@anweiss
Copy link
Author

anweiss commented Feb 18, 2015

lol, I screwed up my rebase with the merged commits from the package refactor...so my commits in this PR kept including changes that were already merged in to master...hence the new branch

marstr pushed a commit to marstr/azure-sdk-for-go that referenced this pull request Apr 27, 2017
marstr pushed a commit that referenced this pull request Apr 28, 2017
mcardosos added a commit that referenced this pull request May 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants