Skip to content

Commit

Permalink
Storage account public access
Browse files Browse the repository at this point in the history
  • Loading branch information
harjain99 committed Jul 9, 2024
1 parent a60ea11 commit a7b85f4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/main/java/gyro/azure/storage/StorageAccountResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public class StorageAccountResource extends AzureResource implements Copyable<St
private Map<String, String> tags;
private StorageLifeCycle lifecycle;
private Boolean upgradeAccountV2;
private Boolean blobPublicAccess;

/**
* The cors rules associated with the Storage Account.
Expand Down Expand Up @@ -203,6 +204,16 @@ public void setUpgradeAccountV2(Boolean upgradeAccountV2) {
this.upgradeAccountV2 = upgradeAccountV2;
}

@Updatable
@Required
public Boolean getBlobPublicAccess() {
return blobPublicAccess;
}

public void setBlobPublicAccess(Boolean blobPublicAccess) {
this.blobPublicAccess = blobPublicAccess;
}

@Override
public void copyFrom(StorageAccount storageAccount) {
setId(storageAccount.id());
Expand All @@ -211,6 +222,7 @@ public void copyFrom(StorageAccount storageAccount) {
setResourceGroup(findById(ResourceGroupResource.class, storageAccount.resourceGroupName()));
setId(storageAccount.id());
setUpgradeAccountV2(storageAccount.kind().equals(Kind.STORAGE_V2));
setBlobPublicAccess(storageAccount.isBlobPublicAccessAllowed());

getTags().clear();
storageAccount.tags().forEach((key, value) -> getTags().put(key, value));
Expand Down Expand Up @@ -250,6 +262,16 @@ public void create(GyroUI ui, State state) throws URISyntaxException, InvalidKey

setId(storageAccount.id());

StorageAccount.Update update = storageAccount.update();

if (Boolean.TRUE.equals(getBlobPublicAccess())) {
update = update.enableBlobPublicAccess();
} else {
update = update.disableBlobPublicAccess();
}

update.apply();

// TODO lifecycle and cors
}

Expand All @@ -271,6 +293,14 @@ public void update(GyroUI ui, State state, Resource current, Set<String> changed
}
}

if (changedFieldNames.contains("blob-public-access")) {
if (Boolean.TRUE.equals(getBlobPublicAccess())) {
update = update.enableBlobPublicAccess();
} else {
update = update.disableBlobPublicAccess();
}
}

update.apply();
}

Expand Down

0 comments on commit a7b85f4

Please sign in to comment.