-
Notifications
You must be signed in to change notification settings - Fork 10
Ability to ignore resource instances #162
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
base: master
Are you sure you want to change the base?
Conversation
This "implements" ignoring of resource instances, but for my usecase of ignoring teams: - It hardcodes the team into the code, currently no clue how to integrate that into an HCL file - It also requires specifying all individual members to ignore and breaks if there's unlisted members, making this currently useless.. Not sure how to make it work for now Reason for needing this is because the NixOS org has a frequently changing team of ~4000 members, which we don't want to include in the config.
TeamMember: [ | ||
'noteam2:infinisil', | ||
'noteam2:infinisil-github-test', | ||
'noteam2:infinixbot' | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given we know a TeamMember
consists of the team name and the user's username, can we not just do a prefix check?
@@ -39,6 +39,16 @@ export class State { | |||
|
|||
private _ignoredProperties: Record<string, string[]> = {} | |||
private _ignoredTypes: string[] = [] | |||
private _ignoredNames: Record<string, string[]> = { | |||
// TODO: Populate from config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See
github-as-code/scripts/src/terraform/state.ts
Lines 99 to 100 in 647b086
this.updateIgnoredTypesFrom(`${env.TF_WORKING_DIR}/locals.tf`) | |
this.updateIgnoredTypesFrom(`${env.TF_WORKING_DIR}/locals_override.tf`) |
github-as-code/scripts/src/terraform/state.ts
Lines 63 to 73 in 647b086
private updateIgnoredTypesFrom(path: string) { | |
if (fs.existsSync(path)) { | |
const hcl = HCL.parseToObject(fs.readFileSync(path))?.at(0) | |
const types = hcl?.locals?.at(0)?.resource_types | |
if (types !== undefined) { | |
this._ignoredTypes = ResourceConstructors.map(c => c.StateType).filter( | |
t => !types.includes(t) | |
) | |
} | |
} | |
} |
I made a more complete version of this at https://github.com/Infinisil-s-Test-Organization/github-as-code/tree/ignore-team-wip, which adds an My main concern with the generalized route is that it adds some complexity on the implementation's end, e.g. we have to special case @galargh If the Thanks for your work on this, it was really easy to extend. 🙂 |
Alternatively, we could use the general framework laid out in my patch, and add a few more common fields: think |
Hey! Thank you for all the contributions <3 I think this would be a great addition to the project! Let me think about it overnight and I'll get back to you on this either tomorrow or day after. |
@infinisil @winterqt I finally had a second to think it through and I think I came up with a setup that should work pretty well. I took heavy inspiration from Infinisil-s-Test-Organization/github-as-code@master...ignore-team-wip but pushed the actual process of ignoring the resources all the way to the GitHub client. This resulted in #172 Let me know what you think. If you're OK with this approach, then I'll add some tests and we can roll it out! |
If we want to use this project for the NixOS org (cc NixOS/org#40, @galargh), we need the ability to ignore the Nixpkgs maintainers team for now, because it has 3.5k members and changes very frequently.
While I've never touched this codebase or Typescript before, I just went ahead and spent a bit of time to make something that kind of works, but not really. I'd be happy for any input on how to make this work properly!
The problems with the current approach:
How I hackily test this locally for those who want to jump in
To get the right version of terraform:
Get any version of nodejs:
Create this
.envrc
, fill in the XXXXXXX's and rundirenv allow
orsource .envrc
if you don't have direnv:Inside the
terraform
directory, runInside the
script
directory, runMake changes to the code, then run this to test them:
Check the file
github/Infinisil-s-Test-Organization.yml
to see the resultLSP set up with https://github.com/typescript-language-server/typescript-language-server is easy and recommended, needs to be set up with your editor though
Can do print debugging with
console.log('hello')