Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
GiGurra committed Jul 12, 2023
1 parent 85445dd commit b571482
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package install
import (
"context"
"fmt"
"github.com/gigurra/flycd/internal/fly_cli"
"github.com/gigurra/flycd/internal/fly_client"
"github.com/gigurra/flycd/internal/flycd"
"github.com/gigurra/flycd/internal/flycd/model"
"github.com/gigurra/flycd/internal/flycd/util/util_packaged"
Expand Down Expand Up @@ -98,7 +98,7 @@ func Cmd(packaged util_packaged.PackagedFileSystem) *cobra.Command {
ctx := context.Background()

fmt.Printf("Check if app named '%s' already exists\n", appName)
appExists, err := fly_cli.ExistsApp(ctx, appName)
appExists, err := fly_client.ExistsApp(ctx, appName)
if err != nil {
fmt.Printf("Error checking if app exists: %v\n", err)
os.Exit(1)
Expand All @@ -124,7 +124,7 @@ func Cmd(packaged util_packaged.PackagedFileSystem) *cobra.Command {
}
}

existsAccessTokenSecret, err := fly_cli.ExistsSecret(ctx, fly_cli.ExistsSecretCmd{
existsAccessTokenSecret, err := fly_client.ExistsSecret(ctx, fly_client.ExistsSecretCmd{
AppName: appName,
SecretName: "FLY_ACCESS_TOKEN",
})
Expand All @@ -136,7 +136,7 @@ func Cmd(packaged util_packaged.PackagedFileSystem) *cobra.Command {
if !existsAccessTokenSecret {

fmt.Printf("App name successfully reserved... creating access token for org '%s'\n", orgSlug)
token, err := fly_cli.CreateOrgToken(ctx, orgSlug)
token, err := fly_client.CreateOrgToken(ctx, orgSlug)
if err != nil {
fmt.Printf("Error creating org token: %v\n", err)
os.Exit(1)
Expand All @@ -145,7 +145,7 @@ func Cmd(packaged util_packaged.PackagedFileSystem) *cobra.Command {

fmt.Printf("Token created.. storing it...\n")

err = fly_cli.StoreSecret(ctx, fly_cli.StoreSecretCmd{
err = fly_client.StoreSecret(ctx, fly_client.StoreSecretCmd{
AppName: appName,
SecretName: "FLY_ACCESS_TOKEN",
SecretValue: token,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fly_cli
package fly_client

import (
"context"
Expand Down
12 changes: 6 additions & 6 deletions internal/flycd/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package flycd
import (
"context"
"fmt"
"github.com/gigurra/flycd/internal/fly_cli"
"github.com/gigurra/flycd/internal/fly_client"
"github.com/gigurra/flycd/internal/flycd/model"
"github.com/gigurra/flycd/internal/flycd/util/util_git"
"github.com/gigurra/flycd/internal/flycd/util/util_toml"
Expand Down Expand Up @@ -249,14 +249,14 @@ func DeployAppFromFolder(ctx context.Context, path string, deployCfg model.Deplo

// Now run fly.io cli and check if the app exists
fmt.Printf("Checking if the app %s exists\n", cfg.App)
appExists, err := fly_cli.ExistsApp(ctx, cfg.App)
appExists, err := fly_client.ExistsApp(ctx, cfg.App)
if err != nil {
return "", fmt.Errorf("error running fly status in folder %s: %w", path, err)
}

if appExists {
fmt.Printf("App %s exists, grabbing its currently deployed config from fly.io\n", cfg.App)
deployedCfg, err := fly_cli.GetDeployedAppConfig(ctx, cfg.App)
deployedCfg, err := fly_client.GetDeployedAppConfig(ctx, cfg.App)
if err != nil {
return "", fmt.Errorf("error getting deployed app config: %w", err)
}
Expand All @@ -266,7 +266,7 @@ func DeployAppFromFolder(ctx context.Context, path string, deployCfg model.Deplo
deployedCfg.Env["FLYCD_APP_VERSION"] != appHash ||
deployedCfg.Env["FLYCD_CONFIG_VERSION"] != cfgHash {
fmt.Printf("App %s needs to be re-deployed, doing it now!\n", cfg.App)
err = fly_cli.DeployExistingApp(ctx, cfg, tempDir, deployCfg)
err = fly_client.DeployExistingApp(ctx, cfg, tempDir, deployCfg)
if err != nil {
return "", err
}
Expand All @@ -277,12 +277,12 @@ func DeployAppFromFolder(ctx context.Context, path string, deployCfg model.Deplo
}
} else {
println("App not found, creating it")
err = fly_cli.CreateNewApp(ctx, cfg, tempDir, true)
err = fly_client.CreateNewApp(ctx, cfg, tempDir, true)
if err != nil {
return "", fmt.Errorf("error creating new app: %w", err)
}
println("Issuing an explicit deploy command, since a fly.io bug when deploying within the launch freezes the operation")
err = fly_cli.DeployExistingApp(ctx, cfg, tempDir, deployCfg)
err = fly_client.DeployExistingApp(ctx, cfg, tempDir, deployCfg)
if err != nil {
return "", err
}
Expand Down

0 comments on commit b571482

Please sign in to comment.