-
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
1 parent
76f1b99
commit 9ff4170
Showing
10 changed files
with
342 additions
and
208 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package deploy | ||
|
||
import ( | ||
"github.com/dream11/odin/cmd" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var deployCmd = &cobra.Command{ | ||
Use: "deploy", | ||
Short: "Deploy resources", | ||
Long: `Deploy resources`, | ||
} | ||
|
||
func init() { | ||
cmd.RootCmd.AddCommand(deployCmd) | ||
} |
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,65 @@ | ||
package deploy | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/dream11/odin/internal/service" | ||
fileUtil "github.com/dream11/odin/pkg/util" | ||
serviceProto "github.com/dream11/odin/proto/gen/go/dream11/od/service/v1" | ||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var env string | ||
var definitionFile string | ||
var provisioningFile string | ||
|
||
var serviceClient = service.Service{} | ||
|
||
var serviceCmd = &cobra.Command{ | ||
Use: "Deploy service", | ||
Short: "Deploy service", | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
return cobra.NoArgs(cmd, args) | ||
}, | ||
Long: "Deploy service using files or service name", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
execute(cmd) | ||
}, | ||
} | ||
|
||
func init() { | ||
serviceCmd.Flags().StringVar(&env, "env", "", "environment for deploying the service") | ||
serviceCmd.Flags().StringVar(&definitionFile, "file", "", "path to the service definition file") | ||
serviceCmd.Flags().StringVar(&provisioningFile, "provisioning", "", "path to the provisioning file") | ||
err := serviceCmd.MarkFlagRequired("env") | ||
if err != nil { | ||
log.Fatal("Error marking 'env' flag as required:", err) | ||
os.Exit(1) | ||
} | ||
|
||
deployCmd.AddCommand(serviceCmd) | ||
} | ||
|
||
func execute(cmd *cobra.Command) { | ||
ctx := cmd.Context() | ||
|
||
definitionData, err := fileUtil.ConvertJsonFileToString(definitionFile) | ||
if err != nil { | ||
log.Fatal("Error while reading definition file ", err) | ||
} | ||
provisioningData, err := fileUtil.ConvertJsonFileToString(provisioningFile) | ||
if err != nil { | ||
log.Fatal("Error while reading provisioning file ", err) | ||
} | ||
|
||
err = serviceClient.DeployService(&ctx, &serviceProto.DeployServiceRequest{ | ||
EnvName: env, | ||
ServiceDefinition: definitionData, | ||
ProvisioningConfig: provisioningData, | ||
}) | ||
|
||
if err != nil { | ||
log.Fatal("Failed to deploy service ", err) | ||
} | ||
} |
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
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
Oops, something went wrong.