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

feat: Enable populating of data directory and .sample files and update dependencies in 0-cicd-github #1240

Conversation

antonkovach
Copy link
Collaborator

The Readme.md files reference the data directory and .sample files, but the code did not allow for their populating. This update enables the copying of the data directory and .sample files, with the data directory being populating as a data.sample directory to prevent overwriting any existing data directory.

Additionally, dependencies have been updated by adding the depends_on section to several resources to ensure that the dependencies are in the correct order. This update addresses some states that were not being handled previously.

There is a minor known issue with Pull Request creation in the current state of the code. The Pull Request is only created after the first run has occurred. A fix for this issue is currently being worked on and will be addressed in a separate Pull Request. However, this issue does not affect the main functionality of the code.

Please review the changes and suggest any possible improvements or approve the pull request.

…ndencies

The Readme.md files reference the data directory and .sample files, but the code did not allow for their populating. This update enables the copying of the data directory and .sample files, with the data directory being populating as a data.sample directory to prevent overwriting any existing data directory.

Additionally, dependencies have been updated by adding the depends_on section to several resources to ensure that the dependencies are in the correct order. This update addresses some states that were not being handled previously.

There is a minor known issue with Pull Request creation in the current state of the code. The Pull Request is only created after the first run has occurred. A fix for this issue is currently being worked on and will be addressed in a separate Pull Request. However, this issue does not affect the main functionality of the code.
@ludoo
Copy link
Collaborator

ludoo commented Mar 11, 2023

Hey Anton, I'm not entirely sure we want to copy sample files: in my opinion once you have CI/CD set up you don't need samples and have the correct files in place.
On data I have mixed feelings: I think actual data for factories should live into a different folder and be referenced explicitly in the factories data path variable. This avoids conflicts between the dummy files we provide, and actual files used for customer infrastructure.

@antonkovach
Copy link
Collaborator Author

antonkovach commented Mar 11, 2023

I agree with your opinion. I also had mixed feelings about the idea. From my own experience, it took me several hours to deduce the functionality of the modules and variables from the source code, including the structure and contents of the data directory. Similarly, I did not expect to find terraform.tfvars.sample in the original repo. Having copies of these files in the current repo would have saved me a lot of time as I was reading the Readme.md file and getting acquainted with the provisioned repo. Perhaps we could add a note in the Readme.md files to indicate the location of such files in the original repo.

Pros:

  • Sample data and files make it easier to get started with the code.
  • The sample files provide insight into the best practices in the provisioned repository.
  • Sample files automatically update if the structure of the data or vars files are updated, making it easy to see changes, such as with the last network or billing account update.

Cons:

  • Sample files become unnecessary once CI/CD is set up since the correct files are already in place.
  • Provisioning can be slightly slower when copying sample files.

I will, of course, accept your decision. Could you please let me know what the decision is?

@ludoo
Copy link
Collaborator

ludoo commented Mar 12, 2023

I see your points, and also that we have two different approaches to CI/CD.

What I and most of my colleagues do, is to initially apply the stages manually a few times until everything is working well, the custom tfvars have the desired values, etc. then transfer the files to CI/CD, at which point you already have tfvars and factory data has been customized.

For our approach, moving tfvars and data potentially creates a problem, or at least adds non-relevant files to the repo.

Why don't we do both the things you suggested, with twist? We add a notice to the READMEs, and we also implement this change but we gate it behind a boolean variable, possibly defaulting to false? And we explain in the cicd github stage that it exists, and should be used when CI/CD is used right from the start.

Would this work for you?

@antonkovach antonkovach marked this pull request as draft March 12, 2023 10:13
@antonkovach
Copy link
Collaborator Author

antonkovach commented Mar 12, 2023

@ludoo I would like to check the proposal. Which version would be better?

Simple:

repositories = {
  gcp_fast_00_bootstrap = {
    create_options = {
      description = "FAST bootstrap."
    }
    features = {
      issues = true
    }
    populate_from    = "../../stages/0-bootstrap"
    populate_samples = true
  }
# tftest skip

More future-proof:

repositories = {
  gcp_fast_00_bootstrap = {
    create_options = {
      description = "FAST bootstrap."
    }
    features = {
      issues = true
    }
    populate_from    = "../../stages/0-bootstrap"
    populate_options = {
      populate_samples = true
    }
  }
# tftest skip

@ludoo
Copy link
Collaborator

ludoo commented Mar 13, 2023

I prefer the first one, but either works fine if you have a strong preference :)

@antonkovach antonkovach marked this pull request as ready for review March 13, 2023 20:19
ludoo and others added 3 commits March 14, 2023 08:27
@antonkovach antonkovach requested a review from ludoo March 15, 2023 09:07
@ludoo
Copy link
Collaborator

ludoo commented Mar 15, 2023

check your mail, you should then be able to merge yourself

…-of-data-directory-sample-files-and-update-dependencies
@antonkovach antonkovach removed the request for review from ludoo March 15, 2023 11:02
@antonkovach antonkovach merged commit d799170 into GoogleCloudPlatform:master Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants