Skip to content

Commit

Permalink
Merge pull request #885 from aziontech/dev
Browse files Browse the repository at this point in the history
Deploy to production - 2024/07/09
  • Loading branch information
PatrickMenoti authored Jul 9, 2024
2 parents 2a12e6c + a02c08f commit eeac250
Show file tree
Hide file tree
Showing 76 changed files with 3,063 additions and 1,250 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ on:
issue_comment:
types: [created]
pull_request_target:
types: [opened,closed,synchronize]
types: [opened, synchronize]

jobs:
CLAssistant:
runs-on: ubuntu-latest
container:
image: ubuntu:18.04
image: ubuntu:24.04
steps:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
# Beta Release
uses: cla-assistant/github-action@v2.1.3-beta
uses: cla-assistant/github-action@v2.4.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
runs-on: ubuntu-latest
container:
image: golang:1.22.4
image: golang:1.22.5
outputs:
binver: ${{ steps.binversion.outputs.BIN_VERSION }}
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
runs-on: ubuntu-latest
container:
image: golang:1.22.4
image: golang:1.22.5
env:
CGO_ENABLED: 0 # Statically linked

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
runs-on: ubuntu-latest
container:
image: golang:1.22.4
image: golang:1.22.5
env:
CGO_ENABLED: 0 # Statically linked

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/package-audit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: Package Auditor (GoVulnCheck)
runs-on: ubuntu-latest
container:
image: golang:1.22.4
image: golang:1.22.5
steps:
- name: Checkout Repository
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
runs-on: ubuntu-latest
container:
image: golang:1.22.4
image: golang:1.22.5

steps:
- name: Setting GIT
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_vulcan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
runs-on: ubuntu-latest
container:
image: golang:1.22.4
image: golang:1.22.5
env:
CGO_ENABLED: 0 # Statically linked

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.4
FROM golang:1.22.5

WORKDIR /go/src/app

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SHELL := env PATH=$(PATH) /bin/bash
NAME := azion

ifeq (, $(GO))
$(error "No go binary found in your system, please install go 1.22.4 before continuing")
$(error "No go binary found in your system, please install go 1.22.5 before continuing")
endif

GOPATH ?= $(shell $(GO) env GOPATH)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Angular
- Astro
- Hexo
- React
- Vite

Through it, you can manage all Azion products, create automation using CI/CD scripts or pipelines, provision multiple services that make up your application with a few commands, and also manage your Azion configurations as code.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aziontech/azion-cli

go 1.22.4
go 1.22.5

require (
github.com/AlecAivazis/survey/v2 v2.3.7
Expand Down
1 change: 1 addition & 0 deletions messages/init/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const (
FLAG_PRESET = "The Preset's name"
FLAG_TEMPLATE = "The Template's name"
FLAG_PACKAGE_MANAGE = "Specify the package manager to use (e.g., npm, yarn, pnpm)"
FLAG_AUTO = "If sent, the entire flow of the command will be run without interruptions"
)

var (
Expand Down
11 changes: 4 additions & 7 deletions pkg/cmd/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ func NewCobraCmd(build *BuildCmd) *cobra.Command {
SilenceUsage: true,
Example: heredoc.Doc("\n$ azion build\n"),
RunE: func(cmd *cobra.Command, args []string) error {
return build.run(fields)
msgs := []string{}
return build.run(fields, &msgs)
},
}

Expand Down Expand Up @@ -83,11 +84,7 @@ func NewBuildCmd(f *cmdutil.Factory) *BuildCmd {
}
}

func (cmd *BuildCmd) Run(fields *contracts.BuildInfo) error {
return cmd.run(fields)
}

func (cmd *BuildCmd) ExternalRun(fields *contracts.BuildInfo, confPath string) error {
func (cmd *BuildCmd) ExternalRun(fields *contracts.BuildInfo, confPath string, msgs *[]string) error {
fields.ProjectPath = confPath
return cmd.run(fields)
return cmd.run(fields, msgs)
}
8 changes: 4 additions & 4 deletions pkg/cmd/build/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import (
"go.uber.org/zap"
)

func (cmd *BuildCmd) run(fields *contracts.BuildInfo) error {
func (cmd *BuildCmd) run(fields *contracts.BuildInfo, msgs *[]string) error {
logger.Debug("Running build command")

err := RunBuildCmdLine(cmd, fields)
err := RunBuildCmdLine(cmd, fields, msgs)
if err != nil {
return err
}

return nil
}

func RunBuildCmdLine(cmd *BuildCmd, fields *contracts.BuildInfo) error {
func RunBuildCmdLine(cmd *BuildCmd, fields *contracts.BuildInfo, msgs *[]string) error {
var err error

conf, err := cmd.GetAzionJsonContent(fields.ProjectPath)
Expand Down Expand Up @@ -64,6 +64,6 @@ func RunBuildCmdLine(cmd *BuildCmd, fields *contracts.BuildInfo) error {
vulcanParams += " --firewall "
}

return vulcan(cmd, conf, vulcanParams, fields)
return vulcan(cmd, conf, vulcanParams, fields, msgs)

}
35 changes: 29 additions & 6 deletions pkg/cmd/build/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,44 @@ import (

msg "github.com/aziontech/azion-cli/messages/build"
"github.com/aziontech/azion-cli/pkg/logger"
"github.com/aziontech/azion-cli/pkg/output"
"go.uber.org/zap"
)

func runCommand(cmd *BuildCmd, command string) error {
logger.FInfo(cmd.Io.Out, msg.BuildStart)
func runCommand(cmd *BuildCmd, command string, msgs *[]string) error {
var hasDeployMessage bool
if len(*msgs) > 0 {
hasDeployMessage = true
}

logger.FInfoFlags(cmd.Io.Out, msg.BuildStart, cmd.f.Format, cmd.f.Out)
*msgs = append(*msgs, msg.BuildStart)

logger.FInfo(cmd.Io.Out, msg.BuildRunningCmd)
logger.FInfo(cmd.Io.Out, fmt.Sprintf("$ %s\n", command))
logger.FInfoFlags(cmd.Io.Out, msg.BuildRunningCmd, cmd.f.Format, cmd.f.Out)
*msgs = append(*msgs, msg.BuildRunningCmd)
logger.FInfoFlags(cmd.Io.Out, fmt.Sprintf("$ %s\n", command), cmd.f.Format, cmd.f.Out)
*msgs = append(*msgs, fmt.Sprintf("$ %s\n", command))

err := cmd.CommandRunInteractive(cmd.f, command)
if err != nil {
logger.Debug("Error while running command with simultaneous output", zap.Error(err))
return msg.ErrFailedToRunBuildCommand
}

logger.FInfo(cmd.Io.Out, msg.BuildSuccessful)
return nil
logger.FInfoFlags(cmd.Io.Out, msg.BuildSuccessful, cmd.f.Format, cmd.f.Out)
*msgs = append(*msgs, msg.BuildSuccessful)

if hasDeployMessage {
return nil
}

outSlice := output.SliceOutput{
Messages: *msgs,
GeneralOutput: output.GeneralOutput{
Out: cmd.f.IOStreams.Out,
Flags: cmd.f.Flags,
},
}

return output.Print(&outSlice)
}
4 changes: 2 additions & 2 deletions pkg/cmd/build/vulcan.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"go.uber.org/zap"
)

func vulcan(cmd *BuildCmd, conf *contracts.AzionApplicationOptions, vulcanParams string, fields *contracts.BuildInfo) error {
func vulcan(cmd *BuildCmd, conf *contracts.AzionApplicationOptions, vulcanParams string, fields *contracts.BuildInfo, msgs *[]string) error {
// checking if vulcan major is correct
vulcanVer, err := cmd.CommandRunner(cmd.f, "npm show edge-functions version", []string{})
if err != nil {
Expand All @@ -26,7 +26,7 @@ func vulcan(cmd *BuildCmd, conf *contracts.AzionApplicationOptions, vulcanParams

command := vul.Command("", "build --preset %s --mode %s%s", cmd.f)

err = runCommand(cmd, fmt.Sprintf(command, strings.ToLower(conf.Preset), strings.ToLower(conf.Mode), vulcanParams))
err = runCommand(cmd, fmt.Sprintf(command, strings.ToLower(conf.Preset), strings.ToLower(conf.Mode), vulcanParams), msgs)
if err != nil {
return fmt.Errorf(msg.ErrorVulcanExecute.Error(), err.Error())
}
Expand Down
51 changes: 39 additions & 12 deletions pkg/cmd/delete/cache_setting/cache_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
msg "github.com/aziontech/azion-cli/messages/cache_setting"
api "github.com/aziontech/azion-cli/pkg/api/cache_setting"
"github.com/aziontech/azion-cli/pkg/cmdutil"
"github.com/aziontech/azion-cli/pkg/iostreams"
"github.com/aziontech/azion-cli/pkg/logger"
"github.com/aziontech/azion-cli/pkg/output"
"github.com/aziontech/azion-cli/utils"
Expand All @@ -21,20 +22,42 @@ var (
cacheSettingsID int64
)

func NewCmd(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
type DeleteCmd struct {
Io *iostreams.IOStreams
ReadInput func(string) (string, error)
DeleteCache func(context.Context, int64, int64) error
AskInput func(msg string) (string, error)
}

func NewDeleteCmd(f *cmdutil.Factory) *DeleteCmd {
return &DeleteCmd{
Io: f.IOStreams,
ReadInput: func(prompt string) (string, error) {
return utils.AskInput(prompt)
},
DeleteCache: func(ctx context.Context, appID int64, cacheID int64) error {
client := api.NewClient(f.HttpClient, f.Config.GetString("api_url"), f.Config.GetString("token"))
return client.Delete(ctx, appID, cacheID)
},
AskInput: utils.AskInput,
}
}

func NewCobraCmd(delete *DeleteCmd, f *cmdutil.Factory) *cobra.Command {
cobraCmd := &cobra.Command{
Use: msg.Usage,
Short: msg.DeleteShortDescription,
Long: msg.DeleteLongDescription,
SilenceUsage: true,
SilenceErrors: true,
Example: heredoc.Doc(`
$ azion delete cache-setting --application-id 1673635839 --cache-setting-id 107313
`),
$ azion delete cache-setting --application-id 1673635839 --cache-setting-id 107313
`),
RunE: func(cmd *cobra.Command, args []string) error {
var err error

if !cmd.Flags().Changed("application-id") {
answer, err := utils.AskInput(msg.ListAskInputApplicationID)
answer, err := delete.AskInput(msg.ListAskInputApplicationID)
if err != nil {
return err
}
Expand All @@ -49,7 +72,7 @@ func NewCmd(f *cmdutil.Factory) *cobra.Command {
}

if !cmd.Flags().Changed("cache-setting-id") {
answer, err := utils.AskInput(msg.DeleteAskInputCacheID)
answer, err := delete.AskInput(msg.DeleteAskInputCacheID)
if err != nil {
return err
}
Expand All @@ -67,7 +90,7 @@ func NewCmd(f *cmdutil.Factory) *cobra.Command {

ctx := context.Background()

err := client.Delete(ctx, applicationID, cacheSettingsID)
err = client.Delete(ctx, applicationID, cacheSettingsID)
if err != nil {
return fmt.Errorf(msg.ErrorFailToDelete.Error(), err)
}
Expand All @@ -78,12 +101,16 @@ func NewCmd(f *cmdutil.Factory) *cobra.Command {
Flags: f.Flags,
}
return output.Print(&deleteOut)

},
}

cmd.Flags().Int64Var(&applicationID, "application-id", 0, msg.DeleteFlagApplicationID)
cmd.Flags().Int64Var(&cacheSettingsID, "cache-setting-id", 0, msg.DeleteFlagCacheSettingsID)
cmd.Flags().BoolP("help", "h", false, msg.DeleteHelpFlag)
return cmd
cobraCmd.Flags().BoolP("help", "h", false, msg.DeleteHelpFlag)
cobraCmd.Flags().Int64Var(&applicationID, "application-id", 0, msg.DeleteFlagApplicationID)
cobraCmd.Flags().Int64Var(&cacheSettingsID, "cache-setting-id", 0, msg.DeleteFlagCacheSettingsID)

return cobraCmd
}

func NewCmd(f *cmdutil.Factory) *cobra.Command {
return NewCobraCmd(NewDeleteCmd(f), f)
}
Loading

0 comments on commit eeac250

Please sign in to comment.