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 'staging' of draft service-versions. #933

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kpfleming
Copy link
Contributor

@kpfleming kpfleming commented Feb 25, 2025

This adds a 'stage' attribute to both fastly_service_vcl and
fastly_service_compute resources, with a default of 'false' (no change
to existing behavior).

If 'stage' is set to 'true', then 'plan' operations which make changes
to service versions will also 'stage' those service versions, whether
they are also activated or not. The expected usage is to have 'stage =
true' and 'activate = false', so that the provider will clone when
necessary to make draft versions, apply changes to those draft
versions and stage them, but otherwise leave them alone. When 'stage =
true' an existing draft version will not be cloned in order to apply
additional changes to it, they will be applied to that draft version.

Additional implementation notes:

  • Added a new function in fastly_test.go to render templates (from the
    text/template module), which can be used by acceptance tests for
    generating HCL. The acceptance tests for the staging feature use
    templates.

  • Moved a function from resource_fastly_service_vcl_test.go to
    fastly_test.go, refactored it, and fixed bugs in it. This function
    is used in acceptance tests to compare the list of expected backends
    for a service to the list of actual backends for the service.

  • Added golang-set as a new dependency, which is used in the function
    mentioned in the last bullet.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  • Does your submission pass tests?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

User Impact

  • What is the user impact of this change? - it adds new functionality

@kpfleming kpfleming marked this pull request as ready for review February 26, 2025 21:39
@kpfleming kpfleming requested a review from a team as a code owner February 26, 2025 21:39
philippschulte
philippschulte previously approved these changes Feb 28, 2025
Copy link
Member

@philippschulte philippschulte left a comment

Choose a reason for hiding this comment

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

This took me a while to wrap my head around. The changes look good and make sense now.

I think it's worth to mention somewhere in the provider docs that the following doesn't make sense:

resource "fastly_service_vcl" "test" {
  ...
  
  activate = true
  stage = true
  
  ...
  }

Specially because activate = true is the default. Why would you activate staging and production at the same time. Since we don't check this during the plan I think it would be good to to have a notice in the docs which points out that when you use stage to set activate to false. Maybe the Guides section would be the right place or even under the stage field description itself.

@kpfleming
Copy link
Contributor Author

A new 'Activation and Staging' section has been added to the docs for both Delivery and Compute services.

Copy link
Contributor

@anthony-gomez-fastly anthony-gomez-fastly left a comment

Choose a reason for hiding this comment

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

LGTM

philippschulte
philippschulte previously approved these changes Mar 5, 2025
Copy link
Member

@philippschulte philippschulte left a comment

Choose a reason for hiding this comment

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

Thank you for adding detailed docs!

Copy link
Member

@mattcone mattcone left a comment

Choose a reason for hiding this comment

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

LGTM! I've left some comments regarding some minor formatting issues.

kpfleming and others added 4 commits March 6, 2025 13:45
This adds a 'stage' attribute to both fastly_service_vcl and
fastly_service_compute resources, with a default of 'false' (no change
to existing behavior).

If 'stage' is set to 'true', then 'plan' operations which make changes
to service versions will also 'stage' those service versions, whether
they are also activated or not. The expected usage is to have 'stage =
true' and 'activate = false', so that the provider will clone when
necessary to make draft versions, apply changes to those draft
versions and stage them, but otherwise leave them alone. When 'stage =
true' an existing draft version will *not* be cloned in order to apply
additional changes to it, they will be applied to that draft version.

Additional implementation notes:

* Added a new function in fastly_test.go to render templates (from the
  text/template module), which can be used by acceptance tests for
  generating HCL. The acceptance tests for the staging feature use
  templates.

* Moved a function from resource_fastly_service_vcl_test.go to
  fastly_test.go, refactored it, and fixed bugs in it. This function
  is used in acceptance tests to compare the list of expected backends
  for a service to the list of actual backends for the service.

* Added golang-set as a new dependency, which is used in the function
  mentioned in the last bullet.
@kpfleming
Copy link
Contributor Author

OK, this needs final check-offs from @philippschulte and @anthony-gomez-fastly and it's ready to be merged. Thanks to everyone for the feedback!

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.

4 participants