-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add Azure Blob Provisioner extension (#1536)
* add dedicated cloud e2e test module * added test without container * add s3 provision and e2e test (wip) * backport/copy upstream AZ Blob Provisioner * add s3 destination credentials * fix lic header format * avoid NPE in the generator * DEPENDENCIES * re-enable FCC crawling in tests
- Loading branch information
1 parent
5cc887d
commit 3f66ebd
Showing
27 changed files
with
1,730 additions
and
29 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,2 @@ | ||
All modules in this directory are only temporary and they should be replaced with their upstream counterparts at the | ||
earliest opportunity. changes made here should be upstreamed ASAP, lest we run the risk of feature divergence! |
29 changes: 29 additions & 0 deletions
29
edc-extensions/backport/azblob-provisioner/build.gradle.kts
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,29 @@ | ||
/* | ||
* Copyright (c) 2020, 2021 Microsoft Corporation | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Microsoft Corporation - initial API and implementation | ||
* | ||
*/ | ||
|
||
plugins { | ||
`java-library` | ||
} | ||
|
||
dependencies { | ||
api(libs.edc.spi.core) | ||
api(libs.edc.azure.blob.core) | ||
|
||
implementation(libs.azure.storage.blob) | ||
// implementation(libs.failsafe.core) | ||
|
||
testImplementation(testFixtures(libs.edc.azure.test)) | ||
} | ||
|
||
|
77 changes: 77 additions & 0 deletions
77
...oner/src/main/java/org/eclipse/edc/connector/provision/azure/AzureProvisionExtension.java
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,77 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2020,2021 Microsoft Corporation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
|
||
package org.eclipse.edc.connector.provision.azure; | ||
|
||
import dev.failsafe.RetryPolicy; | ||
import org.eclipse.edc.azure.blob.AzureSasToken; | ||
import org.eclipse.edc.azure.blob.api.BlobStoreApi; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.provision.ProvisionManager; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.provision.Provisioner; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.provision.ResourceManifestGenerator; | ||
import org.eclipse.edc.connector.provision.azure.blob.ObjectContainerProvisionedResource; | ||
import org.eclipse.edc.connector.provision.azure.blob.ObjectStorageConsumerResourceDefinitionGenerator; | ||
import org.eclipse.edc.connector.provision.azure.blob.ObjectStorageProvisioner; | ||
import org.eclipse.edc.connector.provision.azure.blob.ObjectStorageResourceDefinition; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Inject; | ||
import org.eclipse.edc.spi.system.ServiceExtension; | ||
import org.eclipse.edc.spi.system.ServiceExtensionContext; | ||
import org.eclipse.edc.spi.types.TypeManager; | ||
|
||
/** | ||
* Provides data transfer {@link Provisioner}s backed by Azure services. | ||
*/ | ||
public class AzureProvisionExtension implements ServiceExtension { | ||
|
||
@Inject | ||
private BlobStoreApi blobStoreApi; | ||
|
||
@Inject | ||
private RetryPolicy<Object> retryPolicy; | ||
|
||
@Inject | ||
private ResourceManifestGenerator manifestGenerator; | ||
|
||
@Inject | ||
private TypeManager typeManager; | ||
|
||
@Override | ||
public String name() { | ||
return "Azure Provision"; | ||
} | ||
|
||
@Override | ||
public void initialize(ServiceExtensionContext context) { | ||
|
||
var monitor = context.getMonitor(); | ||
var provisionManager = context.getService(ProvisionManager.class); | ||
|
||
provisionManager.register(new ObjectStorageProvisioner(retryPolicy, monitor, blobStoreApi)); | ||
|
||
// register the generator | ||
manifestGenerator.registerGenerator(new ObjectStorageConsumerResourceDefinitionGenerator()); | ||
|
||
registerTypes(typeManager); | ||
} | ||
|
||
private void registerTypes(TypeManager typeManager) { | ||
typeManager.registerTypes(ObjectContainerProvisionedResource.class, ObjectStorageResourceDefinition.class, AzureSasToken.class); | ||
} | ||
|
||
} |
86 changes: 86 additions & 0 deletions
86
...va/org/eclipse/edc/connector/provision/azure/blob/ObjectContainerProvisionedResource.java
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,86 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2020,2021 Microsoft Corporation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
|
||
package org.eclipse.edc.connector.provision.azure.blob; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonTypeName; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; | ||
import org.eclipse.edc.azure.blob.AzureBlobStoreSchema; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.types.ProvisionedDataDestinationResource; | ||
|
||
import static org.eclipse.edc.azure.blob.AzureBlobStoreSchema.ACCOUNT_NAME; | ||
import static org.eclipse.edc.azure.blob.AzureBlobStoreSchema.CONTAINER_NAME; | ||
import static org.eclipse.edc.azure.blob.AzureBlobStoreSchema.FOLDER_NAME; | ||
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE; | ||
|
||
@JsonDeserialize(builder = ObjectContainerProvisionedResource.Builder.class) | ||
@JsonTypeName("dataspaceconnector:objectcontainerprovisionedresource") | ||
public class ObjectContainerProvisionedResource extends ProvisionedDataDestinationResource { | ||
|
||
private ObjectContainerProvisionedResource() { | ||
} | ||
|
||
public String getAccountName() { | ||
return getDataAddress().getStringProperty(ACCOUNT_NAME); | ||
} | ||
|
||
public String getContainerName() { | ||
return getDataAddress().getStringProperty(CONTAINER_NAME); | ||
} | ||
|
||
@JsonPOJOBuilder(withPrefix = "") | ||
public static class Builder extends ProvisionedDataDestinationResource.Builder<ObjectContainerProvisionedResource, Builder> { | ||
|
||
private Builder() { | ||
super(new ObjectContainerProvisionedResource()); | ||
dataAddressBuilder.type(AzureBlobStoreSchema.TYPE); | ||
} | ||
|
||
@JsonCreator | ||
public static Builder newInstance() { | ||
return new Builder(); | ||
} | ||
|
||
public Builder accountName(String accountName) { | ||
dataAddressBuilder.property(EDC_NAMESPACE + ACCOUNT_NAME, accountName); | ||
return this; | ||
} | ||
|
||
public Builder containerName(String containerName) { | ||
dataAddressBuilder.property(EDC_NAMESPACE + CONTAINER_NAME, containerName); | ||
return this; | ||
} | ||
|
||
@Override | ||
public Builder resourceName(String name) { | ||
dataAddressBuilder.keyName(name); | ||
super.resourceName(name); | ||
return this; | ||
} | ||
|
||
public Builder folderName(String folderName) { | ||
if (folderName != null) { | ||
dataAddressBuilder.property(EDC_NAMESPACE + FOLDER_NAME, folderName); | ||
} | ||
return this; | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
.../edc/connector/provision/azure/blob/ObjectStorageConsumerResourceDefinitionGenerator.java
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,59 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2020,2021 Microsoft Corporation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
|
||
package org.eclipse.edc.connector.provision.azure.blob; | ||
|
||
import org.eclipse.edc.azure.blob.AzureBlobStoreSchema; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.provision.ConsumerResourceDefinitionGenerator; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.types.ResourceDefinition; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcess; | ||
import org.eclipse.edc.policy.model.Policy; | ||
import org.eclipse.edc.spi.types.domain.DataAddress; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import static java.util.Optional.ofNullable; | ||
import static java.util.UUID.randomUUID; | ||
|
||
public class ObjectStorageConsumerResourceDefinitionGenerator implements ConsumerResourceDefinitionGenerator { | ||
|
||
@Override | ||
public @Nullable ResourceDefinition generate(TransferProcess transferProcess, Policy policy) { | ||
var destination = transferProcess.getDataDestination(); | ||
var id = randomUUID().toString(); | ||
var account = destination.getStringProperty(AzureBlobStoreSchema.ACCOUNT_NAME); | ||
var container = destination.getStringProperty(AzureBlobStoreSchema.CONTAINER_NAME); | ||
var folderName = destination.getStringProperty(AzureBlobStoreSchema.FOLDER_NAME); | ||
|
||
if (container == null) { | ||
container = randomUUID().toString(); | ||
} | ||
return ObjectStorageResourceDefinition.Builder.newInstance() | ||
.id(id) | ||
.accountName(account) | ||
.containerName(container) | ||
.folderName(folderName) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public boolean canGenerate(TransferProcess dataRequest, Policy policy) { | ||
var type = ofNullable(dataRequest.getDataDestination()).map(DataAddress::getType).orElse(null); | ||
return AzureBlobStoreSchema.TYPE.equals(type); | ||
} | ||
} |
Oops, something went wrong.