Skip to content

Commit

Permalink
Rename sourcecode package to scanner, and move out of internal
Browse files Browse the repository at this point in the history
  • Loading branch information
jsierles committed Jul 8, 2022
1 parent eec7c01 commit aa3519b
Show file tree
Hide file tree
Showing 61 changed files with 850 additions and 800 deletions.
8 changes: 4 additions & 4 deletions cmd/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/superfly/flyctl/helpers"
"github.com/superfly/flyctl/internal/build/imgsrc"
"github.com/superfly/flyctl/internal/filemu"
"github.com/superfly/flyctl/internal/sourcecode"
"github.com/superfly/flyctl/scanner"
"github.com/superfly/graphql"
)

Expand Down Expand Up @@ -138,7 +138,7 @@ func runLaunch(cmdCtx *cmdctx.CmdContext) error {

fmt.Println("Creating app in", dir)

var srcInfo = new(sourcecode.SourceInfo)
var srcInfo = new(scanner.SourceInfo)

if img := cmdCtx.Config.GetString("image"); img != "" {
fmt.Println("Using image", img)
Expand All @@ -153,7 +153,7 @@ func runLaunch(cmdCtx *cmdctx.CmdContext) error {
} else {
fmt.Println("Scanning source code")

if si, err := sourcecode.Scan(dir); err != nil {
if si, err := scanner.Scan(dir); err != nil {
return err
} else {
srcInfo = si
Expand Down Expand Up @@ -489,7 +489,7 @@ func runLaunch(cmdCtx *cmdctx.CmdContext) error {
return nil
}

func execInitCommand(ctx context.Context, command sourcecode.InitCommand) (err error) {
func execInitCommand(ctx context.Context, command scanner.InitCommand) (err error) {
binary, err := exec.LookPath(command.Command)
if err != nil {
return fmt.Errorf("%s not found in $PATH - make sure app dependencies are installed and try again", command.Command)
Expand Down
6 changes: 3 additions & 3 deletions flyctl/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/BurntSushi/toml"
"github.com/superfly/flyctl/helpers"
"github.com/superfly/flyctl/internal/sourcecode"
"github.com/superfly/flyctl/scanner"
)

type ConfigFormat string
Expand Down Expand Up @@ -443,11 +443,11 @@ func (ac *AppConfig) SetProcess(name, value string) {
ac.Definition["processes"] = processes
}

func (ac *AppConfig) SetStatics(statics []sourcecode.Static) {
func (ac *AppConfig) SetStatics(statics []scanner.Static) {
ac.Definition["statics"] = statics
}

func (ac *AppConfig) SetVolumes(volumes []sourcecode.Volume) {
func (ac *AppConfig) SetVolumes(volumes []scanner.Volume) {
ac.Definition["mounts"] = volumes
}

Expand Down
6 changes: 3 additions & 3 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/superfly/flyctl/api"
"github.com/superfly/flyctl/client"
"github.com/superfly/flyctl/helpers"
"github.com/superfly/flyctl/internal/sourcecode"
"github.com/superfly/flyctl/scanner"
)

const (
Expand Down Expand Up @@ -584,10 +584,10 @@ func (c *Config) SetProcess(name, value string) {
c.Definition["processes"] = processes
}

func (c *Config) SetStatics(statics []sourcecode.Static) {
func (c *Config) SetStatics(statics []scanner.Static) {
c.Definition["statics"] = statics
}

func (c *Config) SetVolumes(volumes []sourcecode.Volume) {
func (c *Config) SetVolumes(volumes []scanner.Volume) {
c.Definition["mounts"] = volumes
}
18 changes: 9 additions & 9 deletions internal/command/machine/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/superfly/flyctl/internal/filemu"
"github.com/superfly/flyctl/internal/flag"
"github.com/superfly/flyctl/internal/prompt"
"github.com/superfly/flyctl/internal/sourcecode"
"github.com/superfly/flyctl/iostreams"
"github.com/superfly/flyctl/scanner"
)

func newLaunch() (cmd *cobra.Command) {
Expand Down Expand Up @@ -150,7 +150,7 @@ func run(ctx context.Context) (err error) {

appConfig.SetPrimaryRegion(regionCode)

var srcInfo *sourcecode.SourceInfo
var srcInfo *scanner.SourceInfo

// Determine whether to deploy from an image
if img := flag.GetString(ctx, "image"); img != "" {
Expand Down Expand Up @@ -233,13 +233,13 @@ func run(ctx context.Context) (err error) {
return
}

func scanAndConfigure(ctx context.Context, dir string, appConfig *app.Config) (srcInfo *sourcecode.SourceInfo, err error) {
func scanAndConfigure(ctx context.Context, dir string, appConfig *app.Config) (srcInfo *scanner.SourceInfo, err error) {

io := iostreams.FromContext(ctx)

srcInfo = new(sourcecode.SourceInfo)
srcInfo = new(scanner.SourceInfo)

scannedDirInfo, err := sourcecode.Scan(dir)
scannedDirInfo, err := scanner.Scan(dir)

if err != nil {
return srcInfo, err
Expand Down Expand Up @@ -279,7 +279,7 @@ func scanAndConfigure(ctx context.Context, dir string, appConfig *app.Config) (s
return
}

func setScannerPrefs(ctx context.Context, appConfig *app.Config, srcInfo *sourcecode.SourceInfo) (err error) {
func setScannerPrefs(ctx context.Context, appConfig *app.Config, srcInfo *scanner.SourceInfo) (err error) {

client := client.FromContext(ctx).API()

Expand Down Expand Up @@ -425,7 +425,7 @@ func setScannerPrefs(ctx context.Context, appConfig *app.Config, srcInfo *source
return
}

func installFiles(ctx context.Context, dir string, srcInfo *sourcecode.SourceInfo) (err error) {
func installFiles(ctx context.Context, dir string, srcInfo *scanner.SourceInfo) (err error) {
for _, f := range srcInfo.Files {
path := filepath.Join(dir, f.Path)

Expand Down Expand Up @@ -456,7 +456,7 @@ func installFiles(ctx context.Context, dir string, srcInfo *sourcecode.SourceInf
return
}

func printAppType(ctx context.Context, srcInfo *sourcecode.SourceInfo) {
func printAppType(ctx context.Context, srcInfo *scanner.SourceInfo) {
io := iostreams.FromContext(ctx)

var article string = "a"
Expand Down Expand Up @@ -493,7 +493,7 @@ func setupHttpService(ctx context.Context, appConfig *app.Config) (err error) {
return
}

func execInitCommand(ctx context.Context, command sourcecode.InitCommand) (err error) {
func execInitCommand(ctx context.Context, command scanner.InitCommand) (err error) {
binary, err := exec.LookPath(command.Command)
if err != nil {
return fmt.Errorf("%s not found in $PATH - make sure app dependencies are installed and try again", command.Command)
Expand Down

0 comments on commit aa3519b

Please sign in to comment.