-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
169 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
golang 1.22.3 | ||
golangci-lint 1.58.1 | ||
nodejs 22.2.0 | ||
pnpm 9.1.2 | ||
pnpm 9.1.4 | ||
protoc 25.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/gvkhna/warpdive/dive" | ||
"github.com/gvkhna/warpdive/runtime" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var exportCmd = &cobra.Command{ | ||
Use: "export [IMAGE ID]", | ||
Short: "Exports a container image to a .warpdive file. For use with warpdive.xyz/viewer", | ||
Run: doExportCmd, | ||
} | ||
|
||
// var outputFilePath string | ||
|
||
func init() { | ||
rootCmd.AddCommand(exportCmd) | ||
} | ||
|
||
// doExportCmd implements the steps taken for the export command | ||
func doExportCmd(cmd *cobra.Command, args []string) { | ||
|
||
userImage := args[0] | ||
if userImage == "" { | ||
fmt.Println("No image argument given") | ||
os.Exit(1) | ||
} | ||
|
||
var sourceType dive.ImageSource | ||
var imageStr string | ||
|
||
sourceType, imageStr = dive.DeriveImageSource(userImage) | ||
|
||
if sourceType == dive.SourceUnknown { | ||
sourceType = dive.ParseImageSource(defaultSource) | ||
if sourceType == dive.SourceUnknown { | ||
fmt.Printf("unable to determine image source: %v\n", defaultSource) | ||
os.Exit(1) | ||
} | ||
|
||
imageStr = userImage | ||
} | ||
|
||
// ignoreErrors, err := cmd.PersistentFlags().GetBool("ignore-errors") | ||
// if err != nil { | ||
// logrus.Error("unable to get 'ignore-errors' option:", err) | ||
// } | ||
|
||
runtime.Run(runtime.Options{ | ||
// Ci: isCi, | ||
Image: imageStr, | ||
Engine: defaultSource, | ||
Source: dive.ParseImageSource(defaultSource), | ||
// Source: dive.ParseImageSource(engine), | ||
PushArgs: args, | ||
ExportFile: exportFile, | ||
// CiConfig: ciConfig, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import {chromium} from 'playwright' | ||
import * as readline from 'readline' | ||
|
||
// run pnpx playwright install | ||
|
||
async function main() { | ||
// Launch the browser | ||
const browser = await chromium.launch({ | ||
headless: false // Set to false to see the browser UI | ||
}) | ||
|
||
// Create a new page with a specific viewport size | ||
const page = await browser.newPage({ | ||
viewport: { | ||
width: 1280, | ||
height: 727 | ||
} | ||
}) | ||
|
||
// Navigate to a URL | ||
await page.goto('http://localhost:4321/viewer/') | ||
|
||
// Create readline interface | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}) | ||
|
||
console.log('Press ENTER to take a screenshot...') | ||
|
||
// Wait for user input | ||
rl.on('line', async () => { | ||
// Take screenshot on user input | ||
await page.screenshot({path: 'screenshot.tmp.png'}) | ||
console.log('Screenshot saved as screenshot.tmp.png') | ||
|
||
// Cleanup | ||
await browser.close() | ||
rl.close() | ||
}) | ||
} | ||
|
||
main().catch((err) => { | ||
console.error('Error:', err) | ||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters