Skip to content

Commit

Permalink
Merge pull request #129 from pulumiverse/feature/protect-repos
Browse files Browse the repository at this point in the history
Use Pulumi `protect` to prevent accidental repo deletion
  • Loading branch information
ringods authored Nov 14, 2023
2 parents 49040f8 + 28f8c8e commit d21d9c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/configTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const Repository = RT.Record({
labels: RT.Array(Labels).optional(),
import: RT.Boolean.optional(),
template: RT.String.optional(),
removable: RT.Boolean.optional(),
})

export type Team = Static<typeof Team>
Expand Down
5 changes: 5 additions & 0 deletions src/github/repositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface RepositoryArgs {
allTeams: Map<string, github.Team>;
import: boolean;
template: pulumi.Input<string> | undefined;
removable: boolean;
}
abstract class BaseRepository extends pulumi.ComponentResource {

Expand Down Expand Up @@ -50,6 +51,7 @@ abstract class BaseRepository extends pulumi.ComponentResource {
}
],
transformations: this.repositoryTransformations(),
protect: !args.removable
}
);
const mainBranchProtection = new github.BranchProtection(`${name}_protect_main`,
Expand Down Expand Up @@ -190,6 +192,7 @@ export function configureRepositories(repositoryArgs: Repository[], allTeams: Ma
allTeams: allTeams,
import: repositoryInfo.import || false,
template: repositoryInfo.template,
removable: repositoryInfo.removable || false,
}).repository);
break;
}
Expand All @@ -202,6 +205,7 @@ export function configureRepositories(repositoryArgs: Repository[], allTeams: Ma
allTeams: allTeams,
import: repositoryInfo.import || false,
template: repositoryInfo.template,
removable: repositoryInfo.removable || false,
}).repository);
break;
}
Expand All @@ -215,6 +219,7 @@ export function configureRepositories(repositoryArgs: Repository[], allTeams: Ma
allTeams,
import: repositoryInfo.import || false,
template: repositoryInfo.template,
removable: repositoryInfo.removable || false,
}).repository
);
break;
Expand Down

0 comments on commit d21d9c1

Please sign in to comment.