Merge branch 'main' into lint
						commit
						ed59ede1d9
					
				@ -0,0 +1,147 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 | 
				
			||||||
 | 
					<svg
 | 
				
			||||||
 | 
					   xmlns:dc="http://purl.org/dc/elements/1.1/"
 | 
				
			||||||
 | 
					   xmlns:cc="http://creativecommons.org/ns#"
 | 
				
			||||||
 | 
					   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 | 
				
			||||||
 | 
					   xmlns:svg="http://www.w3.org/2000/svg"
 | 
				
			||||||
 | 
					   xmlns="http://www.w3.org/2000/svg"
 | 
				
			||||||
 | 
					   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
 | 
				
			||||||
 | 
					   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
 | 
				
			||||||
 | 
					   xml:space="preserve"
 | 
				
			||||||
 | 
					   width="560"
 | 
				
			||||||
 | 
					   height="560"
 | 
				
			||||||
 | 
					   version="1.1"
 | 
				
			||||||
 | 
					   style="clip-rule:evenodd;fill-rule:evenodd;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision"
 | 
				
			||||||
 | 
					   viewBox="0 0 560 560"
 | 
				
			||||||
 | 
					   id="svg44"
 | 
				
			||||||
 | 
					   sodipodi:docname="icon_raw.svg"
 | 
				
			||||||
 | 
					   inkscape:version="0.92.3 (2405546, 2018-03-11)"
 | 
				
			||||||
 | 
					   inkscape:export-filename="/home/umarcor/filebrowser/logo/icon_raw.svg.png"
 | 
				
			||||||
 | 
					   inkscape:export-xdpi="96"
 | 
				
			||||||
 | 
					   inkscape:export-ydpi="96"><metadata
 | 
				
			||||||
 | 
					   id="metadata48"><rdf:RDF><cc:Work
 | 
				
			||||||
 | 
					       rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
 | 
				
			||||||
 | 
					         rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
 | 
				
			||||||
 | 
					   pagecolor="#ffffff"
 | 
				
			||||||
 | 
					   bordercolor="#666666"
 | 
				
			||||||
 | 
					   borderopacity="1"
 | 
				
			||||||
 | 
					   objecttolerance="10"
 | 
				
			||||||
 | 
					   gridtolerance="10"
 | 
				
			||||||
 | 
					   guidetolerance="10"
 | 
				
			||||||
 | 
					   inkscape:pageopacity="0"
 | 
				
			||||||
 | 
					   inkscape:pageshadow="2"
 | 
				
			||||||
 | 
					   inkscape:window-width="1366"
 | 
				
			||||||
 | 
					   inkscape:window-height="711"
 | 
				
			||||||
 | 
					   id="namedview46"
 | 
				
			||||||
 | 
					   showgrid="false"
 | 
				
			||||||
 | 
					   inkscape:zoom="0.33714286"
 | 
				
			||||||
 | 
					   inkscape:cx="-172.33051"
 | 
				
			||||||
 | 
					   inkscape:cy="280"
 | 
				
			||||||
 | 
					   inkscape:window-x="0"
 | 
				
			||||||
 | 
					   inkscape:window-y="20"
 | 
				
			||||||
 | 
					   inkscape:window-maximized="1"
 | 
				
			||||||
 | 
					   inkscape:current-layer="svg44" />
 | 
				
			||||||
 | 
					  <defs
 | 
				
			||||||
 | 
					   id="defs4">
 | 
				
			||||||
 | 
					    <style
 | 
				
			||||||
 | 
					   type="text/css"
 | 
				
			||||||
 | 
					   id="style2">
 | 
				
			||||||
 | 
					      <![CDATA[
 | 
				
			||||||
 | 
					       .fil1 {fill:#FEFEFE}
 | 
				
			||||||
 | 
					       .fil6 {fill:#006498}
 | 
				
			||||||
 | 
					       .fil7 {fill:#0EA5EB}
 | 
				
			||||||
 | 
					       .fil8 {fill:#2979FF}
 | 
				
			||||||
 | 
					       .fil3 {fill:#2BBCFF}
 | 
				
			||||||
 | 
					       .fil0 {fill:#455A64}
 | 
				
			||||||
 | 
					       .fil4 {fill:#53C6FC}
 | 
				
			||||||
 | 
					       .fil5 {fill:#BDEAFF}
 | 
				
			||||||
 | 
					       .fil2 {fill:#332C2B;fill-opacity:0.149020}
 | 
				
			||||||
 | 
					      ]]>
 | 
				
			||||||
 | 
					    </style>
 | 
				
			||||||
 | 
					  </defs>
 | 
				
			||||||
 | 
					  <g
 | 
				
			||||||
 | 
					   id="g85"
 | 
				
			||||||
 | 
					   transform="translate(-70,-70)"><path
 | 
				
			||||||
 | 
					     class="fil1"
 | 
				
			||||||
 | 
					     d="M 350,71 C 504,71 629,196 629,350 629,504 504,629 350,629 196,629 71,504 71,350 71,196 196,71 350,71 Z"
 | 
				
			||||||
 | 
					     id="path9"
 | 
				
			||||||
 | 
					     inkscape:connector-curvature="0"
 | 
				
			||||||
 | 
					     style="fill:#fefefe" /><path
 | 
				
			||||||
 | 
					     class="fil2"
 | 
				
			||||||
 | 
					     d="M 475,236 593,387 C 596,503 444,639 301,585 L 225,486 339,330 c 0,0 138,-95 136,-94 z"
 | 
				
			||||||
 | 
					     id="path11"
 | 
				
			||||||
 | 
					     inkscape:connector-curvature="0"
 | 
				
			||||||
 | 
					     style="fill:#332c2b;fill-opacity:0.14902003" /><path
 | 
				
			||||||
 | 
					     class="fil3"
 | 
				
			||||||
 | 
					     d="m 231,211 h 208 l 38,24 v 246 c 0,5 -3,8 -8,8 H 231 c -5,0 -8,-3 -8,-8 V 219 c 0,-5 3,-8 8,-8 z"
 | 
				
			||||||
 | 
					     id="path13"
 | 
				
			||||||
 | 
					     inkscape:connector-curvature="0"
 | 
				
			||||||
 | 
					     style="fill:#2bbcff" /><path
 | 
				
			||||||
 | 
					     class="fil4"
 | 
				
			||||||
 | 
					     d="m 231,211 h 208 l 38,24 v 2 L 440,214 H 231 c -4,0 -7,3 -7,7 v 263 c -1,-1 -1,-2 -1,-3 V 219 c 0,-5 3,-8 8,-8 z"
 | 
				
			||||||
 | 
					     id="path15"
 | 
				
			||||||
 | 
					     inkscape:connector-curvature="0"
 | 
				
			||||||
 | 
					     style="fill:#53c6fc" /><polygon
 | 
				
			||||||
 | 
					     class="fil5"
 | 
				
			||||||
 | 
					     points="305,212 418,212 418,310 305,310 "
 | 
				
			||||||
 | 
					     id="polygon17"
 | 
				
			||||||
 | 
					     style="fill:#bdeaff" /><path
 | 
				
			||||||
 | 
					     class="fil5"
 | 
				
			||||||
 | 
					     d="m 255,363 h 189 c 3,0 5,2 5,4 V 483 H 250 V 367 c 0,-2 2,-4 5,-4 z"
 | 
				
			||||||
 | 
					     id="path19"
 | 
				
			||||||
 | 
					     inkscape:connector-curvature="0"
 | 
				
			||||||
 | 
					     style="fill:#bdeaff" /><polygon
 | 
				
			||||||
 | 
					     class="fil6"
 | 
				
			||||||
 | 
					     points="250,470 449,470 449,483 250,483 "
 | 
				
			||||||
 | 
					     id="polygon21"
 | 
				
			||||||
 | 
					     style="fill:#006498" /><path
 | 
				
			||||||
 | 
					     class="fil6"
 | 
				
			||||||
 | 
					     d="m 380,226 h 10 c 3,0 6,2 6,5 v 40 c 0,3 -3,6 -6,6 h -10 c -3,0 -6,-3 -6,-6 v -40 c 0,-3 3,-5 6,-5 z"
 | 
				
			||||||
 | 
					     id="path23"
 | 
				
			||||||
 | 
					     inkscape:connector-curvature="0"
 | 
				
			||||||
 | 
					     style="fill:#006498" /><path
 | 
				
			||||||
 | 
					     class="fil1"
 | 
				
			||||||
 | 
					     d="m 254,226 c 10,0 17,7 17,17 0,9 -7,16 -17,16 -9,0 -17,-7 -17,-16 0,-10 8,-17 17,-17 z"
 | 
				
			||||||
 | 
					     id="path25"
 | 
				
			||||||
 | 
					     inkscape:connector-curvature="0"
 | 
				
			||||||
 | 
					     style="fill:#fefefe" /><path
 | 
				
			||||||
 | 
					     class="fil6"
 | 
				
			||||||
 | 
					     d="m 267,448 h 165 c 2,0 3,1 3,3 v 0 c 0,1 -1,3 -3,3 H 267 c -2,0 -3,-2 -3,-3 v 0 c 0,-2 1,-3 3,-3 z"
 | 
				
			||||||
 | 
					     id="path27"
 | 
				
			||||||
 | 
					     inkscape:connector-curvature="0"
 | 
				
			||||||
 | 
					     style="fill:#006498" /><path
 | 
				
			||||||
 | 
					     class="fil6"
 | 
				
			||||||
 | 
					     d="m 267,415 h 165 c 2,0 3,1 3,3 v 0 c 0,1 -1,2 -3,2 H 267 c -2,0 -3,-1 -3,-2 v 0 c 0,-2 1,-3 3,-3 z"
 | 
				
			||||||
 | 
					     id="path29"
 | 
				
			||||||
 | 
					     inkscape:connector-curvature="0"
 | 
				
			||||||
 | 
					     style="fill:#006498" /><path
 | 
				
			||||||
 | 
					     class="fil6"
 | 
				
			||||||
 | 
					     d="m 267,381 h 165 c 2,0 3,2 3,3 v 0 c 0,2 -1,3 -3,3 H 267 c -2,0 -3,-1 -3,-3 v 0 c 0,-1 1,-3 3,-3 z"
 | 
				
			||||||
 | 
					     id="path31"
 | 
				
			||||||
 | 
					     inkscape:connector-curvature="0"
 | 
				
			||||||
 | 
					     style="fill:#006498" /><path
 | 
				
			||||||
 | 
					     class="fil1"
 | 
				
			||||||
 | 
					     d="m 236,472 c 3,0 5,2 5,5 0,2 -2,4 -5,4 -3,0 -5,-2 -5,-4 0,-3 2,-5 5,-5 z"
 | 
				
			||||||
 | 
					     id="path33"
 | 
				
			||||||
 | 
					     inkscape:connector-curvature="0"
 | 
				
			||||||
 | 
					     style="fill:#fefefe" /><path
 | 
				
			||||||
 | 
					     class="fil1"
 | 
				
			||||||
 | 
					     d="m 463,472 c 3,0 5,2 5,5 0,2 -2,4 -5,4 -3,0 -5,-2 -5,-4 0,-3 2,-5 5,-5 z"
 | 
				
			||||||
 | 
					     id="path35"
 | 
				
			||||||
 | 
					     inkscape:connector-curvature="0"
 | 
				
			||||||
 | 
					     style="fill:#fefefe" /><polygon
 | 
				
			||||||
 | 
					     class="fil6"
 | 
				
			||||||
 | 
					     points="305,212 284,212 284,310 305,310 "
 | 
				
			||||||
 | 
					     id="polygon37"
 | 
				
			||||||
 | 
					     style="fill:#006498" /><path
 | 
				
			||||||
 | 
					     class="fil7"
 | 
				
			||||||
 | 
					     d="m 477,479 v 2 c 0,5 -3,8 -8,8 H 231 c -5,0 -8,-3 -8,-8 v -2 c 0,4 3,8 8,8 h 238 c 5,0 8,-4 8,-8 z"
 | 
				
			||||||
 | 
					     id="path39"
 | 
				
			||||||
 | 
					     inkscape:connector-curvature="0"
 | 
				
			||||||
 | 
					     style="fill:#0ea5eb" /><path
 | 
				
			||||||
 | 
					     class="fil8"
 | 
				
			||||||
 | 
					     d="M 350,70 C 505,70 630,195 630,350 630,505 505,630 350,630 195,630 70,505 70,350 70,195 195,70 350,70 Z m 0,46 C 479,116 584,221 584,350 584,479 479,584 350,584 221,584 116,479 116,350 116,221 221,116 350,116 Z"
 | 
				
			||||||
 | 
					     id="path41"
 | 
				
			||||||
 | 
					     inkscape:connector-curvature="0"
 | 
				
			||||||
 | 
					     style="fill:#2979ff" /></g>
 | 
				
			||||||
 | 
					</svg>
 | 
				
			||||||
| 
		 After Width: | Height: | Size: 5.4 KiB  | 
											
												Binary file not shown.
											
										
									
								| 
		 After Width: | Height: | Size: 88 KiB  | 
@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					---
 | 
				
			||||||
 | 
					display_name: File Browser
 | 
				
			||||||
 | 
					description: A file browser for your workspace
 | 
				
			||||||
 | 
					icon: ../.icons/filebrowser.svg
 | 
				
			||||||
 | 
					maintainer_github: coder
 | 
				
			||||||
 | 
					verified: true
 | 
				
			||||||
 | 
					tags: [helper, filebrowser]
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# File Browser
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					A file browser for your workspace.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```hcl
 | 
				
			||||||
 | 
					module "filebrowser" {
 | 
				
			||||||
 | 
					    source = "https://registry.coder.com/modules/filebrowser"
 | 
				
			||||||
 | 
					    agent_id = coder_agent.example.id
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Examples
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Serve a specific directory
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```hcl
 | 
				
			||||||
 | 
					module "filebrowser" {
 | 
				
			||||||
 | 
					    source = "https://registry.coder.com/modules/filebrowser"
 | 
				
			||||||
 | 
					    agent_id = coder_agent.example.id
 | 
				
			||||||
 | 
					    folder = "/home/coder/project"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
@ -0,0 +1,57 @@
 | 
				
			|||||||
 | 
					terraform {
 | 
				
			||||||
 | 
					  required_version = ">= 1.0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  required_providers {
 | 
				
			||||||
 | 
					    coder = {
 | 
				
			||||||
 | 
					      source  = "coder/coder"
 | 
				
			||||||
 | 
					      version = ">= 0.12"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Add required variables for your modules and remove any unneeded variables
 | 
				
			||||||
 | 
					variable "agent_id" {
 | 
				
			||||||
 | 
					  type        = string
 | 
				
			||||||
 | 
					  description = "The ID of a Coder agent."
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					variable "log_path" {
 | 
				
			||||||
 | 
					  type        = string
 | 
				
			||||||
 | 
					  description = "The path to log filebrowser to."
 | 
				
			||||||
 | 
					  default     = "/tmp/filebrowser.log"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					variable "port" {
 | 
				
			||||||
 | 
					  type        = number
 | 
				
			||||||
 | 
					  description = "The port to run filebrowser on."
 | 
				
			||||||
 | 
					  default     = 13339
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					variable "folder" {
 | 
				
			||||||
 | 
					  type        = string
 | 
				
			||||||
 | 
					  description = "--root value for filebrowser."
 | 
				
			||||||
 | 
					  default     = "~"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					resource "coder_script" "filebrowser" {
 | 
				
			||||||
 | 
					  agent_id     = var.agent_id
 | 
				
			||||||
 | 
					  display_name = "File Browser"
 | 
				
			||||||
 | 
					  icon         = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg"
 | 
				
			||||||
 | 
					  script = templatefile("${path.module}/run.sh", {
 | 
				
			||||||
 | 
					    LOG_PATH : var.log_path,
 | 
				
			||||||
 | 
					    PORT : var.port,
 | 
				
			||||||
 | 
					    FOLDER : var.folder,
 | 
				
			||||||
 | 
					    LOG_PATH : var.log_path,
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					  run_on_start = true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					resource "coder_app" "filebrowser" {
 | 
				
			||||||
 | 
					  agent_id     = var.agent_id
 | 
				
			||||||
 | 
					  slug         = "filebrowser"
 | 
				
			||||||
 | 
					  display_name = "File Browser"
 | 
				
			||||||
 | 
					  url          = "http://localhost:${var.port}"
 | 
				
			||||||
 | 
					  icon         = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg"
 | 
				
			||||||
 | 
					  subdomain    = true
 | 
				
			||||||
 | 
					  share        = "owner"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BOLD='\033[0;1m'
 | 
				
			||||||
 | 
					echo "$${BOLD}Installing filebrowser \n\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo "🥳 Installation comlete! \n\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo "👷 Starting filebrowser in background... \n\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ROOT_DIR=${FOLDER}
 | 
				
			||||||
 | 
					ROOT_DIR=$${ROOT_DIR/\~/$HOME}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}' \n\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					filebrowser --noauth --root $ROOT_DIR --port ${PORT} >${LOG_PATH} 2>&1 &
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo "📝 Logs at ${LOG_PATH} \n\n"
 | 
				
			||||||
@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					import { serve } from "bun";
 | 
				
			||||||
 | 
					import { describe } from "bun:test";
 | 
				
			||||||
 | 
					import {
 | 
				
			||||||
 | 
					  createJSONResponse,
 | 
				
			||||||
 | 
					  runTerraformInit,
 | 
				
			||||||
 | 
					  testRequiredVariables,
 | 
				
			||||||
 | 
					} from "../test";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					describe("jfrog", async () => {
 | 
				
			||||||
 | 
					  await runTerraformInit(import.meta.dir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Run a fake JFrog server so the provider can initialize
 | 
				
			||||||
 | 
					  // correctly. This saves us from having to make remote requests!
 | 
				
			||||||
 | 
					  const fakeFrogHost = serve({
 | 
				
			||||||
 | 
					    fetch: (req) => {
 | 
				
			||||||
 | 
					      const url = new URL(req.url);
 | 
				
			||||||
 | 
					      // See https://jfrog.com/help/r/jfrog-rest-apis/license-information
 | 
				
			||||||
 | 
					      if (url.pathname === "/artifactory/api/system/license")
 | 
				
			||||||
 | 
					        return createJSONResponse({
 | 
				
			||||||
 | 
					          type: "Commercial",
 | 
				
			||||||
 | 
					          licensedTo: "JFrog inc.",
 | 
				
			||||||
 | 
					          validThrough: "May 15, 2036",
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					      if (url.pathname === "/access/api/v1/tokens")
 | 
				
			||||||
 | 
					        return createJSONResponse({
 | 
				
			||||||
 | 
					          token_id: "xxx",
 | 
				
			||||||
 | 
					          access_token: "xxx",
 | 
				
			||||||
 | 
					          scope: "any",
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					      return createJSONResponse({});
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    port: 0,
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  testRequiredVariables(import.meta.dir, {
 | 
				
			||||||
 | 
					    agent_id: "some-agent-id",
 | 
				
			||||||
 | 
					    jfrog_url: "http://" + fakeFrogHost.hostname + ":" + fakeFrogHost.port,
 | 
				
			||||||
 | 
					    artifactory_access_token: "XXXX",
 | 
				
			||||||
 | 
					    package_managers: "{}",
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
@ -0,0 +1,71 @@
 | 
				
			|||||||
 | 
					terraform {
 | 
				
			||||||
 | 
					  required_version = ">= 1.0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  required_providers {
 | 
				
			||||||
 | 
					    coder = {
 | 
				
			||||||
 | 
					      source  = "coder/coder"
 | 
				
			||||||
 | 
					      version = ">= 0.12"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    artifactory = {
 | 
				
			||||||
 | 
					      source  = "registry.terraform.io/jfrog/artifactory"
 | 
				
			||||||
 | 
					      version = "~> 8.4.0"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					variable "jfrog_url" {
 | 
				
			||||||
 | 
					  type        = string
 | 
				
			||||||
 | 
					  description = "JFrog instance URL. e.g. https://YYY.jfrog.io"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					variable "artifactory_access_token" {
 | 
				
			||||||
 | 
					  type        = string
 | 
				
			||||||
 | 
					  description = "The admin-level access token to use for JFrog."
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Configure the Artifactory provider
 | 
				
			||||||
 | 
					provider "artifactory" {
 | 
				
			||||||
 | 
					  url          = join("/", [var.jfrog_url, "artifactory"])
 | 
				
			||||||
 | 
					  access_token = var.artifactory_access_token
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					resource "artifactory_scoped_token" "me" {
 | 
				
			||||||
 | 
					  # This is hacky, but on terraform plan the data source gives empty strings,
 | 
				
			||||||
 | 
					  # which fails validation.
 | 
				
			||||||
 | 
					  username = length(data.coder_workspace.me.owner_email) > 0 ? data.coder_workspace.me.owner_email : "plan"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					variable "agent_id" {
 | 
				
			||||||
 | 
					  type        = string
 | 
				
			||||||
 | 
					  description = "The ID of a Coder agent."
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					variable "package_managers" {
 | 
				
			||||||
 | 
					  type        = map(string)
 | 
				
			||||||
 | 
					  description = <<EOF
 | 
				
			||||||
 | 
					A map of package manager names to their respective artifactory repositories.
 | 
				
			||||||
 | 
					For example:
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      "npm": "npm-local",
 | 
				
			||||||
 | 
					      "go": "go-local",
 | 
				
			||||||
 | 
					      "pypi": "pypi-local"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					data "coder_workspace" "me" {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					resource "coder_script" "jfrog" {
 | 
				
			||||||
 | 
					  agent_id     = var.agent_id
 | 
				
			||||||
 | 
					  display_name = "jfrog"
 | 
				
			||||||
 | 
					  icon         = "/icon/jfrog.svg"
 | 
				
			||||||
 | 
					  script = templatefile("${path.module}/run.sh", {
 | 
				
			||||||
 | 
					    JFROG_URL : var.jfrog_url,
 | 
				
			||||||
 | 
					    JFROG_HOST : replace(var.jfrog_url, "https://", ""),
 | 
				
			||||||
 | 
					    ARTIFACTORY_USERNAME : data.coder_workspace.me.owner_email,
 | 
				
			||||||
 | 
					    ARTIFACTORY_ACCESS_TOKEN : artifactory_scoped_token.me.access_token,
 | 
				
			||||||
 | 
					    REPOSITORY_NPM : lookup(var.package_managers, "npm", ""),
 | 
				
			||||||
 | 
					    REPOSITORY_GO : lookup(var.package_managers, "go", ""),
 | 
				
			||||||
 | 
					    REPOSITORY_PYPI : lookup(var.package_managers, "pypi", ""),
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					  run_on_start = true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,49 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BOLD='\033[0;1m'
 | 
				
			||||||
 | 
					echo "$${BOLD}Installing JFrog CLI..."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Install the JFrog CLI.
 | 
				
			||||||
 | 
					curl -fL https://install-cli.jfrog.io | sudo sh
 | 
				
			||||||
 | 
					sudo chmod 755 /usr/local/bin/jf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# The jf CLI checks $CI when determining whether to use interactive
 | 
				
			||||||
 | 
					# flows.
 | 
				
			||||||
 | 
					export CI=true
 | 
				
			||||||
 | 
					# Authenticate with the JFrog CLI.
 | 
				
			||||||
 | 
					jf c rm 0 || true
 | 
				
			||||||
 | 
					echo "${ARTIFACTORY_ACCESS_TOKEN}" | jf c add --access-token-stdin --url "${JFROG_URL}" 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Configure the `npm` CLI to use the Artifactory "npm" repository.
 | 
				
			||||||
 | 
					if [ -z "${REPOSITORY_NPM}" ]; then
 | 
				
			||||||
 | 
					  echo "🤔 REPOSITORY_NPM is not set, skipping npm configuration."
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					  echo "📦 Configuring npm..."
 | 
				
			||||||
 | 
					  jf npmc --global --repo-resolve "${JFROG_URL}/artifactory/api/npm/${REPOSITORY_NPM}"
 | 
				
			||||||
 | 
					  cat << EOF > ~/.npmrc
 | 
				
			||||||
 | 
					email = ${ARTIFACTORY_USERNAME}
 | 
				
			||||||
 | 
					registry = ${JFROG_URL}/artifactory/api/npm/${REPOSITORY_NPM}
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					  jf rt curl /api/npm/auth >> ~/.npmrc
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Configure the `pip` to use the Artifactory "python" repository.
 | 
				
			||||||
 | 
					if [ -z "${REPOSITORY_PYPI}" ]; then
 | 
				
			||||||
 | 
					  echo "🤔 REPOSITORY_PYPI is not set, skipping pip configuration."
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					  echo "🐍 Configuring pip..."
 | 
				
			||||||
 | 
					  mkdir -p ~/.pip
 | 
				
			||||||
 | 
					  cat << EOF > ~/.pip/pip.conf
 | 
				
			||||||
 | 
					[global]
 | 
				
			||||||
 | 
					index-url = https://${ARTIFACTORY_USERNAME}:${ARTIFACTORY_ACCESS_TOKEN}@${JFROG_HOST}/artifactory/api/pypi/${REPOSITORY_PYPI}/simple
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Set GOPROXY to use the Artifactory "go" repository.
 | 
				
			||||||
 | 
					if [ -z "${REPOSITORY_GO}" ]; then
 | 
				
			||||||
 | 
					  echo "🤔 REPOSITORY_GO is not set, skipping go configuration."
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					  echo "🐹 Configuring go..."
 | 
				
			||||||
 | 
					  export GOPROXY="https://${ARTIFACTORY_USERNAME}:${ARTIFACTORY_ACCESS_TOKEN}@${JFROG_HOST}/artifactory/api/go/${REPOSITORY_GO}"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					echo "🥳 Configuration complete!"
 | 
				
			||||||
@ -1,38 +0,0 @@
 | 
				
			|||||||
---
 | 
					 | 
				
			||||||
display_name: vscode-server
 | 
					 | 
				
			||||||
description: VS Code Web - Visual Studio Code in the browser
 | 
					 | 
				
			||||||
icon: ../.icons/code.svg
 | 
					 | 
				
			||||||
maintainer_github: coder
 | 
					 | 
				
			||||||
verified: true
 | 
					 | 
				
			||||||
tags: [helper, ide, vscode, web]
 | 
					 | 
				
			||||||
---
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# VS Code Web
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Automatically install [Visual Studio Code Server](https://code.visualstudio.com/docs/remote/vscode-server) in a workspace using the [VS Code CLIs](https://code.visualstudio.com/docs/editor/command-line) and create an app to access it via the dashboard.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||

 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Examples
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
1. Install VS Code Server with default settings:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   ```hcl
 | 
					 | 
				
			||||||
   module "vscode-web" {
 | 
					 | 
				
			||||||
     source         = "https://registry.coder.com/modules/vscode-server"
 | 
					 | 
				
			||||||
     agent_id       = coder_agent.example.id
 | 
					 | 
				
			||||||
     accept_license = true
 | 
					 | 
				
			||||||
   }
 | 
					 | 
				
			||||||
   ```
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
2. Install VS Code Server to a custom folder:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   ```hcl
 | 
					 | 
				
			||||||
   module "vscode-web" {
 | 
					 | 
				
			||||||
     source          = "https://registry.coder.com/modules/vscode-server"
 | 
					 | 
				
			||||||
     agent_id        = coder_agent.example.id
 | 
					 | 
				
			||||||
     install_dir     = "/home/coder/.vscode-server"
 | 
					 | 
				
			||||||
     folder          = "/home/coder"
 | 
					 | 
				
			||||||
     accept_license  = true
 | 
					 | 
				
			||||||
   }
 | 
					 | 
				
			||||||
   ```
 | 
					 | 
				
			||||||
@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					---
 | 
				
			||||||
 | 
					display_name: VS Code Web
 | 
				
			||||||
 | 
					description: VS Code Web - Visual Studio Code in the browser
 | 
				
			||||||
 | 
					icon: ../.icons/code.svg
 | 
				
			||||||
 | 
					maintainer_github: coder
 | 
				
			||||||
 | 
					verified: true
 | 
				
			||||||
 | 
					tags: [helper, ide, vscode, web]
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# VS Code Web
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Automatically install [Visual Studio Code Server](https://code.visualstudio.com/docs/remote/vscode-server) in a workspace using the [VS Code CLI](https://code.visualstudio.com/docs/editor/command-line) and create an app to access it via the dashboard.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```hcl
 | 
				
			||||||
 | 
					module "vscode-web" {
 | 
				
			||||||
 | 
					  source         = "https://registry.coder.com/modules/vscode-server"
 | 
				
			||||||
 | 
					  agent_id       = coder_agent.example.id
 | 
				
			||||||
 | 
					  accept_license = true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Examples
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Install VS Code Server to a custom folder
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```hcl
 | 
				
			||||||
 | 
					module "vscode-web" {
 | 
				
			||||||
 | 
					  source          = "https://registry.coder.com/modules/vscode-server"
 | 
				
			||||||
 | 
					  agent_id        = coder_agent.example.id
 | 
				
			||||||
 | 
					  install_dir     = "/home/coder/.vscode-server"
 | 
				
			||||||
 | 
					  folder          = "/home/coder"
 | 
				
			||||||
 | 
					  accept_license  = true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
					Loading…
					
					
				
		Reference in New Issue