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

Add support for Immutable Storage on container #1144

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

xperiandri
Copy link
Contributor

@xperiandri xperiandri commented Oct 24, 2024

Implemented:

  • ImmutableStorageWithVersioning
  • RequireInfrastructureEncryptionThis PR closes #

I have read the contributing guidelines and have completed the following:

  • Tested my code end-to-end against a live Azure subscription.
  • Updated the documentation in the docs folder for the affected changes.
  • Written unit tests against the modified code that I have made.
  • Updated the release notes with a new entry for this PR.
  • Checked the coding standards outlined in the contributions guide and ensured my code adheres to them.

If I haven't completed any of the tasks above, I include the reasons why here:
Which test would you recommend to modify or implement?

Below is a minimal example configuration that includes the new features, which can be used to deploy to Azure:

let storage = storageAccount {
    name "wormtest222"
    sku Farmer.Storage.Sku.Standard_GRS
    disable_blob_public_access
    add_private_container
        "container"
        (blobContainerImmutabilityPolicies {
            allow_protected_append_writes AllAppendAllowed
            immutability_period_since_creation (365<Days> * 5)
        })
}

@xperiandri xperiandri force-pushed the storage-2023-05-01 branch 3 times, most recently from de707a0 to 3c3a3d8 Compare October 25, 2024 12:51
@xperiandri
Copy link
Contributor Author

@ninjarobot do you have any remarks?

@isaacabraham
Copy link
Member

You want to write at least one test confirmation the JSON that is emitted in the generate ARM template is correct i.e. checking fields etc.

@isaacabraham
Copy link
Member

From an API design, what happens if you don't want to set any policies - do you need to provide a policy regardless (bear in mind computation expressions don't allow optional arguments AFAIK, and overloads must all have the same number of arguments)? I think perhaps creating a dedicated container { } CE which can have members on it including e.g.:

  • name
  • accessibility (public / private)
  • immutability_policy

would be a better way to go.

@isaacabraham
Copy link
Member

Also can you make an issue first which clearly outlines what this PR is designed to solve - normally we create issues, get them approved, and then create a PR to resolve them (in that order :-))

Copy link
Collaborator

@ninjarobot ninjarobot left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for adding this support for newer storage account functionality. I made a few minor suggestions you can take or leave as applicable.

src/Farmer/Types.fs Outdated Show resolved Hide resolved
src/Farmer/Builders/Builders.Storage.fs Show resolved Hide resolved
src/Farmer/Builders/Builders.Storage.fs Outdated Show resolved Hide resolved
src/Farmer/Types.fs Show resolved Hide resolved
@ninjarobot ninjarobot added this to the 1.9.3 milestone Oct 26, 2024
@isaacabraham isaacabraham self-requested a review October 27, 2024 14:54
Copy link
Member

@isaacabraham isaacabraham left a comment

Choose a reason for hiding this comment

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

Before merging, we need to modify the API - the use of a CE in this regard isn't going to work, from what I can see, from a usability perspective.

@xperiandri
Copy link
Contributor Author

From an API design, what happens if you don't want to set any policies - do you need to provide a policy regardless (bear in mind computation expressions don't allow optional arguments AFAIK, and overloads must all have the same number of arguments)?

@isaacabraham, actually it works fine as all the tests pass. I verified that it works both ways and allow that optional parameter to be specified and omitted

@isaacabraham
Copy link
Member

@isaacabraham, actually it works fine as all the tests pass. I verified that it works both ways and allow that optional parameter to be specified and omitted

That's good :-) Nonetheless, I think moving to a dedicated container { } CE at this stage makes more sense.

This PR still needs tests for the new code that's been created as well as the other points mentioned (including an issue / issues that reflect the actual changes that are being made here - it's not so much about upgrading the versions but about immutable blobs etc.).

Happy to talk through with you the API choices and anything else that's needed.

@xperiandri
Copy link
Contributor Author

I thought about that but considered immutable policy as not so big change to introduce container CE.
However further container customization support may need a CE

@xperiandri
Copy link
Contributor Author

I've implemented tests. Let me know if I miss something

@xperiandri
Copy link
Contributor Author

Before merging, we need to modify the API - the use of a CE in this regard isn't going to work, from what I can see, from a usability perspective.

@isaacabraham my idea was to add now and preserve in the future ability to specify immutability policy
And add blobContainer CE and operations to storageAccount CE accepting BlobContainerConfig along with supporting additional container settings.
I have no intent to add them right now as it widens the scope of this PR.
Do you think blobContainer should be coupled with these changes?

@isaacabraham
Copy link
Member

I think so, yes. If you look elsewhere in the Farmer API, you won't really much in the way of CEs being supplied as secondary arguments to a custom keyword, and I really would like to retain the pattern that we have.

You can repurpose the CE you've already built to actually be the container one - just add in the extra name parameter. You can then add that as an overload for the top-level CE add_private_container member.

What do you think?

Thanks for adding the tests.

@ninjarobot ninjarobot modified the milestones: 1.9.3, 1.9.4 Nov 3, 2024
@isaacabraham isaacabraham changed the title Updated Microsoft.Storage/storageAccounts to 2023-05-01 Add support for Immutable Storage on container Nov 5, 2024
@ninjarobot ninjarobot modified the milestones: 1.9.4, 1.9.5, 1.9.6 Nov 6, 2024
@xperiandri xperiandri force-pushed the storage-2023-05-01 branch 2 times, most recently from 6a01d5e to 21088d9 Compare November 15, 2024 14:52
@xperiandri
Copy link
Contributor Author

@isaacabraham I've implemented storageBlobContainer CE as you suggested.
Any other remarks?

@ninjarobot ninjarobot modified the milestones: 1.9.6, 1.9.7 Nov 20, 2024
@ninjarobot
Copy link
Collaborator

@isaacabraham can you please review this again?

@ninjarobot ninjarobot modified the milestones: 1.9.7, 1.9.8 Dec 6, 2024
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