Edits history of script submission #18203 for ' Delete an environment variable from a container (qovery)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Delete an environment variable from a container
     * - To delete an environment variable from an container you must have the project user permission
    - You can't delete a BUILT_IN variable
    - If you delete a variable having override or alias, the associated override/alias will be deleted as well
    
     */
    export async function main(auth: RT.Qovery, containerId: string, environmentVariableId: string) {
    	const url = new URL(
    		`https://api.qovery.com/container/${containerId}/environmentVariable/${environmentVariableId}`
    	)
    
    	const response = await fetch(url, {
    		method: 'DELETE',
    		headers: {
    			Authorization: 'Token ' + auth.apiKey
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.text()
    }
    

    Submitted by hugo697 235 days ago