Remove salt

This commit is contained in:
Shreerang Kale 2025-07-21 11:37:52 +05:30
parent 75989d9f34
commit e57c4b24ad
3 changed files with 29 additions and 35 deletions

View File

@ -224,17 +224,9 @@ export async function POST(request: NextRequest) {
// Sanitize the app name to ensure it's DNS-compatible (only alphanumeric and dashes)
const sanitizedAppName = appName.replace(/[^a-zA-Z0-9-]/g, '-').toLowerCase();
// Generate a random salt (6 alphanumeric characters) to prevent name collisions
const generateSalt = (): string => {
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
return Array.from({ length: 6 }, () => chars.charAt(Math.floor(Math.random() * chars.length))).join('');
};
const salt = generateSalt();
console.log(`Generated salt: ${salt}`);
// Create DNS name in format: app_name-shortcommithash-salt
const dnsName = `${sanitizedAppName}-${shortHash}-${salt}`;
console.log(`DNS name with salt: ${dnsName} (sanitized from: ${appName})`);
// Create DNS name in format: app_name-shortcommithash
const dnsName = `${sanitizedAppName}-${shortHash}`;
console.log(`DNS name: ${dnsName} (sanitized from: ${appName})`);
// Ensure the DNS name doesn't have consecutive dashes or start/end with a dash
let cleanDnsName = dnsName
@ -243,10 +235,9 @@ export async function POST(request: NextRequest) {
// Ensure DNS name is valid (63 chars max per label, all lowercase, starts with a letter)
if (cleanDnsName.length > 63) {
// If too long, truncate but preserve both the commit hash and salt parts
const suffixPart = `-${shortHash}-${salt}`;
const maxAppNameLength = 63 - suffixPart.length;
cleanDnsName = sanitizedAppName.substring(0, maxAppNameLength) + suffixPart;
// If too long, truncate but preserve both the commit hash
const maxAppNameLength = 63 - shortHash.length;
cleanDnsName = sanitizedAppName.substring(0, maxAppNameLength) + shortHash;
}
// If the DNS name ended up empty (unlikely) or doesn't start with a letter (possible),
@ -255,7 +246,7 @@ export async function POST(request: NextRequest) {
cleanDnsName = `app-${cleanDnsName}`;
}
console.log(`Final DNS name with salt: ${cleanDnsName}`);
console.log(`Final DNS name: ${cleanDnsName}`);
// Set up Registry config
const config = getRegistryConfig()
@ -273,9 +264,8 @@ export async function POST(request: NextRequest) {
const registry = getRegistry()
// Create LRN for the application with commit hash and salt
// We already have the salt from earlier, so we use it directly
const lrn = `lrn://${config.authority}/applications/${appName}-${shortHash}-${salt}`;
// Create LRN for the application with commit hash
const lrn = `lrn://${config.authority}/applications/${appName}-${shortHash}`;
// Get current timestamp for the meta note
const timestamp = new Date().toUTCString();
@ -284,7 +274,7 @@ export async function POST(request: NextRequest) {
console.log('Step 1: Publishing ApplicationRecord...');
const applicationRecord = {
type: 'ApplicationRecord',
name: `${appName}-${shortHash}-${salt}`, // Include commit hash and salt in the record name
name: `${appName}-${shortHash}`, // Include commit hash in the record name
version: '1.0.0',
app_type: 'webapp',
repository: [repoUrl],
@ -365,8 +355,8 @@ export async function POST(request: NextRequest) {
const deploymentRequestData = {
type: 'ApplicationDeploymentRequest',
version: '1.0.0',
name: `${appName}-${shortHash}-${salt}`, // Update name to match application record
application: lrn, // LRN already includes commit hash and salt
name: `${appName}-${shortHash}`, // Update name to match application record
application: lrn, // LRN already includes commit hash
deployer: deployerLrn,
dns: cleanDnsName,
config: {

View File

@ -28,7 +28,7 @@ export default function StatusDisplay({
error,
}: StatusDisplayProps) {
// Get domain suffix from environment variable
const domainSuffix = process.env.NEXT_PUBLIC_DOMAIN_SUFFIX || '';
const domainSuffix = process.env.NEXT_PUBLIC_DOMAIN_SUFFIX;
if (status === 'idle') return null;
const StatusBadge = ({ type }: { type: 'creating' | 'success' | 'error' }) => {
@ -129,7 +129,11 @@ export default function StatusDisplay({
{appRecordId && <InfoItem label="Laconic Application Record ID" value={appRecordId} />}
{recordId && <InfoItem label="Laconic Deployment Request Record ID" value={recordId} />}
{lrn && <InfoItem label="Laconic Resource Name (LRN)" value={lrn} />}
{dns && <InfoItem label="Deployment URL (ready in 2-3 minutes)" value={domainSuffix ? `https://${dns}${domainSuffix}` : `http://${dns}`} />}
{dns && (
domainSuffix
? <InfoItem label="Deployment URL (ready in 2-3 minutes)" value={`https://${dns}${domainSuffix}`} />
: <InfoItem label="Please set domain suffix" value="" />
)}
</div>
)}