Edits history of script submission #18133 for ' Create a helm (qovery)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Create a helm
     *
     */
    export async function main(auth: RT.Qovery, environmentId: string, body: Body) {
    	const url = new URL(`https://api.qovery.com/environment/${environmentId}/helm`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Token ' + auth.apiKey
    		},
    		body: JSON.stringify(body)
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    
    /* eslint-disable */
    /**
     * This file was automatically generated by json-schema-to-typescript.
     * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
     * and run json-schema-to-typescript to regenerate this file.
     */
    
    export type Body = {
    	ports?: ({
    		name?: string
    		/**
    		 * The listening port of your service.
    		 */
    		internal_port: number
    		/**
    		 * The exposed port for your service. This is optional. If not set a default port will be used.
    		 */
    		external_port?: number
    		namespace?: string
    		protocol?: 'HTTP' | 'GRPC'
    		/**
    		 * is the default port to use for domain
    		 */
    		is_default?: boolean
    		[k: string]: unknown
    	} & (
    		| {
    				service_selectors?: KubernetesSelector[]
    				[k: string]: unknown
    		  }
    		| {
    				service_name?: string
    				[k: string]: unknown
    		  }
    	))[]
    	[k: string]: unknown
    } & {
    	/**
    	 * name is case insensitive
    	 */
    	name: string
    	description?: string
    	/**
    	 * Maximum number of seconds allowed for helm to run before killing it and mark it as failed
    	 *
    	 */
    	timeout_sec?: number
    	/**
    	 * Indicates if the 'environment preview option' is enabled.
    	 * If enabled, a preview environment will be automatically cloned when `/preview` endpoint is called or when a new commit is updated.
    	 * If not specified, it takes the value of the `auto_preview` property from the associated environment.
    	 *
    	 */
    	auto_preview?: boolean
    	/**
    	 * Specify if the helm will be automatically updated after receiving a new image tag or a new commit according to the source type.
    	 *
    	 */
    	auto_deploy: boolean
    	source:
    		| {
    				git_repository?: {
    					/**
    					 * application git repository URL
    					 */
    					url: string
    					/**
    					 * Name of the branch to use. This is optional
    					 * If not specified, then the branch used is the `main` or `master` one
    					 *
    					 */
    					branch?: string
    					/**
    					 * indicates the root path of the application.
    					 */
    					root_path?: string
    					/**
    					 * The git token id on Qovery side
    					 */
    					git_token_id?: string
    					[k: string]: unknown
    				}
    				[k: string]: unknown
    		  }
    		| {
    				helm_repository?: {
    					/**
    					 * The id of the helm repository
    					 */
    					repository?: string
    					/**
    					 * The name of the chart in the repository
    					 */
    					chart_name?: string
    					/**
    					 * The version of the chart to use
    					 */
    					chart_version?: string
    					[k: string]: unknown
    				}
    				[k: string]: unknown
    		  }
    	/**
    	 * The extra arguments to pass to helm
    	 */
    	arguments: string[]
    	/**
    	 * If we should allow the chart to deploy object outside his specified namespace.
    	 * Setting this flag to true, requires special rights
    	 *
    	 */
    	allow_cluster_wide_resources?: boolean
    	/**
    	 * Specify helm values you want to set or override
    	 *
    	 */
    	values_override: {
    		/**
    		 * The input is in json array format: [ [$KEY,$VALUE], [...] ]
    		 */
    		set?: string[][]
    		/**
    		 * The input is in json array format: [ [$KEY,$VALUE], [...] ]
    		 */
    		set_string?: string[][]
    		/**
    		 * The input is in json array format: [ [$KEY,$VALUE], [...] ]
    		 */
    		set_json?: string[][]
    		file?: {
    			git?: {
    				git_repository: {
    					/**
    					 * application git repository URL
    					 */
    					url: string
    					/**
    					 * Name of the branch to use. This is optional
    					 * If not specified, then the branch used is the `main` or `master` one
    					 *
    					 */
    					branch?: string
    					/**
    					 * indicates the root path of the application.
    					 */
    					root_path?: string
    					/**
    					 * The git token id on Qovery side
    					 */
    					git_token_id?: string
    					provider: 'BITBUCKET' | 'GITHUB' | 'GITLAB'
    					[k: string]: unknown
    				}
    				/**
    				 * List of path inside your git repository to locate values file. Must start by a /
    				 */
    				paths: string[]
    				[k: string]: unknown
    			}
    			raw?: {
    				values?: {
    					/**
    					 * The name of the value file
    					 */
    					name?: string
    					/**
    					 * The content of the value file
    					 */
    					content?: string
    					[k: string]: unknown
    				}[]
    				[k: string]: unknown
    			}
    			[k: string]: unknown
    		}
    		[k: string]: unknown
    	}
    	/**
    	 * Icon URI representing the helm service.
    	 */
    	icon_uri?: string
    	[k: string]: unknown
    }
    
    export interface KubernetesSelector {
    	key: string
    	value: string
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago