コード例 #1
0
ファイル: stack.go プロジェクト: koding/koding
// VerifyCredential verifies the given Azure credential.
func (s *Stack) VerifyCredential(c *stack.Credential) error {
	cred := c.Credential.(*Cred)

	if err := cred.Valid(); err != nil {
		return err
	}

	client, err := management.ClientFromPublishSettingsData([]byte(cred.PublishSettings), cred.SubscriptionID)
	if err != nil {
		return err
	}

	err = client.WaitForOperation("invalid", nil)
	if err != nil && !strings.Contains(err.Error(), "The operation request ID was not found") {
		return err
	}

	return nil
}
コード例 #2
0
ファイル: config.go プロジェクト: saulshanabrook/terraform
func (c *Config) NewClientFromSettingsData() (*Client, error) {
	mc, err := management.ClientFromPublishSettingsData(c.Settings, c.SubscriptionID)
	if err != nil {
		return nil, nil
	}

	return &Client{
		mgmtClient:           mc,
		affinityGroupClient:  affinitygroup.NewClient(mc),
		hostedServiceClient:  hostedservice.NewClient(mc),
		secGroupClient:       networksecuritygroup.NewClient(mc),
		osImageClient:        osimage.NewClient(mc),
		sqlClient:            sql.NewClient(mc),
		storageServiceClient: storageservice.NewClient(mc),
		vmClient:             virtualmachine.NewClient(mc),
		vmDiskClient:         virtualmachinedisk.NewClient(mc),
		vmImageClient:        virtualmachineimage.NewClient(mc),
		vnetClient:           virtualnetwork.NewClient(mc),
		mutex:                &sync.Mutex{},
	}, nil
}