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 quick demo of SSH source implementation #137

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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('use-ssh-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(`Use SSH Source Format: ${configInstance.useSSHSourceFormat}`);

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
Loading