-
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.
* deployed service proto update * deploye service set cmd implementation * name correction * lint changes * pr changes * pr changes
- Loading branch information
1 parent
556fb98
commit 2280c6a
Showing
8 changed files
with
1,261 additions
and
592 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,71 @@ | ||
package deploy | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
|
||
serviceDto "github.com/dream11/odin/proto/gen/go/dream11/od/dto/v1" | ||
serviceProto "github.com/dream11/odin/proto/gen/go/dream11/od/service/v1" | ||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var serviceSetName string | ||
var serviceSetDeployCmd = &cobra.Command{ | ||
Use: "service-set", | ||
Short: "Deploy service-set", | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
return cobra.NoArgs(cmd, args) | ||
}, | ||
Long: "Deploy service-set using files or service set name", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
executeDeployServiceSet(cmd) | ||
}, | ||
} | ||
|
||
func init() { | ||
|
||
serviceSetDeployCmd.Flags().StringVar(&env, "env", "", "environment for deploying the service-set") | ||
serviceSetDeployCmd.Flags().StringVar(&provisioningFile, "file", "", "path to the service set provisioning file") | ||
serviceSetDeployCmd.Flags().StringVar(&serviceSetName, "name", "", "released service set name") | ||
|
||
err := serviceSetDeployCmd.MarkFlagRequired("env") | ||
if err != nil { | ||
log.Fatal("Error marking 'env' flag as required:", err) | ||
} | ||
|
||
deployCmd.AddCommand(serviceSetDeployCmd) | ||
} | ||
|
||
func executeDeployServiceSet(cmd *cobra.Command) { | ||
ctx := cmd.Context() | ||
if serviceSetName == "" && provisioningFile == "" { | ||
log.Fatal("Please provide either --name or --file.") | ||
} | ||
if provisioningFile != "" && serviceSetName != "" { | ||
log.Fatal("--name should not be provided when --file is provided.") | ||
} | ||
var deployServiceSetRequestDTO serviceDto.ServiceSet | ||
var deployServiceSetRequest serviceProto.DeployServiceSetRequest | ||
|
||
deployServiceSetRequest.EnvName = env | ||
|
||
if provisioningFile != "" { | ||
provisioningData, err := os.ReadFile(provisioningFile) | ||
if err != nil { | ||
log.Fatal("Error while reading provisioning file ", err) | ||
} | ||
if err := json.Unmarshal(provisioningData, &deployServiceSetRequestDTO); err != nil { | ||
log.Fatal("error unmarshalling provisioning file: %w", err) | ||
} | ||
deployServiceSetRequest = serviceClient.ConvertToDeployServiceSetRequest(&deployServiceSetRequestDTO, env) | ||
} | ||
if serviceSetName != "" { | ||
deployServiceSetRequest.Name = serviceSetName | ||
} | ||
|
||
err := serviceClient.DeployServiceSet(&ctx, &deployServiceSetRequest) | ||
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
Oops, something went wrong.