Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
JCLOUDS-1557 - Azure local server support
Co-authored-by: David Sloan <david.sloan@lenses.io>
- Loading branch information
1 parent
3a7e41f
commit 17fd80cd5a10ed2ab6886ad436f51b62ad0a826d
Showing
11 changed files
with
414 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jclouds.azure.storage.util.storageurl; | ||
|
||
import com.google.common.base.Preconditions; | ||
import com.google.common.base.Supplier; | ||
import org.jclouds.domain.Credentials; | ||
import org.jclouds.location.Provider; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
|
||
import static org.jclouds.azure.storage.util.storageurl.TrailingSlashUtil.ensureTrailingSlash; | ||
import java.net.URI; | ||
|
||
@Singleton | ||
public class AppendAccountToEndpoint implements StorageUrlSupplier { | ||
|
||
private final Supplier<URI> endpointSupplier; | ||
private final Supplier<Credentials> credentialsSupplier; | ||
|
||
@Inject | ||
public AppendAccountToEndpoint(@Provider Supplier<URI> endpointSupplier, @Provider Supplier<Credentials> credentialsSupplier) { | ||
this.endpointSupplier = endpointSupplier; | ||
this.credentialsSupplier = credentialsSupplier; | ||
} | ||
|
||
@Override | ||
public URI get() { | ||
|
||
URI endpoint = endpointSupplier.get(); | ||
|
||
Preconditions.checkNotNull(endpoint, "An endpoint must be configured in order to use AppendAccountToEndpoint module"); | ||
|
||
String endpointTrailingSlash = new StringBuilder(ensureTrailingSlash(endpoint)) | ||
.append(credentialsSupplier.get().identity) | ||
.append("/") | ||
.toString(); | ||
|
||
return URI.create(endpointTrailingSlash); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jclouds.azure.storage.util.storageurl; | ||
|
||
import com.google.common.base.Supplier; | ||
import org.jclouds.domain.Credentials; | ||
import org.jclouds.location.Provider; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
import java.net.URI; | ||
import static org.jclouds.azure.storage.util.storageurl.TrailingSlashUtil.ensureTrailingSlash; | ||
|
||
@Singleton | ||
public class StorageAccountInVhost implements StorageUrlSupplier { | ||
|
||
private final Supplier<URI> endpointSupplier; | ||
private final Supplier<Credentials> credentialsSupplier; | ||
|
||
@Inject | ||
public StorageAccountInVhost(@Provider Supplier<URI> endpointSupplier, @Provider Supplier<Credentials> credentialsSupplier) { | ||
this.endpointSupplier = endpointSupplier; | ||
this.credentialsSupplier = credentialsSupplier; | ||
} | ||
|
||
@Override | ||
public URI get() { | ||
|
||
URI endpoint = endpointSupplier.get(); | ||
|
||
String uri = endpoint == null ? buildUri() : ensureTrailingSlash(endpoint); | ||
|
||
return URI.create(uri); | ||
|
||
} | ||
|
||
private String buildUri() { | ||
return "https://" + credentialsSupplier.get().identity + ".blob.core.windows.net/"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jclouds.azure.storage.util.storageurl; | ||
|
||
import com.google.common.base.Supplier; | ||
import com.google.inject.ImplementedBy; | ||
|
||
import java.net.URI; | ||
|
||
@ImplementedBy(StorageAccountInVhost.class) | ||
public interface StorageUrlSupplier extends Supplier<URI> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jclouds.azure.storage.util.storageurl; | ||
|
||
import java.net.URI; | ||
|
||
public class TrailingSlashUtil { | ||
|
||
static String ensureTrailingSlash(URI endpointUri) { | ||
String endpoint = endpointUri.toString(); | ||
return endpoint.endsWith("/") ? endpoint : endpoint + "/"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jclouds.azureblob.config; | ||
|
||
import com.google.inject.AbstractModule; | ||
import org.jclouds.azure.storage.util.storageurl.AppendAccountToEndpoint; | ||
import org.jclouds.azure.storage.util.storageurl.StorageUrlSupplier; | ||
|
||
public class AppendAccountToEndpointModule extends AbstractModule { | ||
|
||
@Override | ||
protected void configure() { | ||
bind(StorageUrlSupplier.class).to(AppendAccountToEndpoint.class); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.