Skip to content

Commit

Permalink
Add quick demo of SSH source implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
LiamBull committed Jan 23, 2025
1 parent 60d8ca4 commit dcaef09
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function initializeConfig(): Config {
githubToken: getInput('github_token', { required: true }),
moduleChangeExcludePatterns: getArrayInput('module-change-exclude-patterns'),
moduleAssetExcludePatterns: getArrayInput('module-asset-exclude-patterns'),
useSSHSourceFormat: getBooleanInput('source_format', { required: true }),
};

// Validate that *.tf is not in excludePatterns
Expand All @@ -96,6 +97,7 @@ function initializeConfig(): Config {
info(`Wiki Sidebar Changelog Max: ${configInstance.wikiSidebarChangelogMax}`);
info(`Module Change Exclude Patterns: ${configInstance.moduleChangeExcludePatterns.join(', ')}`);
info(`Module Asset Exclude Patterns: ${configInstance.moduleAssetExcludePatterns.join(', ')}`);
info(`Terraform Source Format: ${configInstance.sourceFormat}`);

return configInstance;
} finally {
Expand Down
4 changes: 4 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ export interface Config {
* tests and other non-functional files as needed.
*/
moduleAssetExcludePatterns: string[];
/**
* Whether to format the source in the wiki as SSH rather than HTTPS.
*/
useSSHSourceFormat: boolean;
}

/**
Expand Down
8 changes: 7 additions & 1 deletion src/wiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,18 @@ async function generateWikiModule(terraformModule: TerraformModule): Promise<str
// Generate a module changelog
const changelog = getModuleReleaseChangelog(terraformModule);
const tfDocs = await generateTerraformDocs(terraformModule);
let sourceUrl = `git::${context.repoUrl}.git?ref=${latestTag}`

if (config.useSSHSourceFormat) {
sourceUrl = sourceUrl.replace('::https://github.com/', '@github.com:');
}

const wikiContent = [
'# Usage\n',
'To use this module in your Terraform, refer to the below module example:\n',
'```hcl',
`module "${moduleName.replace(/[^a-zA-Z0-9]/g, '_').toLowerCase()}" {`,
` source = "git::${context.repoUrl}.git?ref=${latestTag}"`,
` source = "${sourceUrl}"`,
'\n # See inputs below for additional required parameters',
'}',
'```',
Expand Down

0 comments on commit dcaef09

Please sign in to comment.