Skip to content

Commit

Permalink
Merge pull request #822 from aziontech/dev
Browse files Browse the repository at this point in the history
Deploy to production - 2024/05/23
  • Loading branch information
maxwelbm authored May 24, 2024
2 parents d4afac2 + e6f3c47 commit 1e38da0
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/package-audit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Package Auditing

on:
pull_request:
types: [opened, synchronize]

jobs:
PackageAuditing:
name: Package Auditor (GoVulnCheck)
runs-on: ubuntu-latest
container:
image: golang:1.22.3
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: GoVulnCheck
run: make govulncheck
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ endif
GOPATH ?= $(shell $(GO) env GOPATH)
GOBIN ?= $(GOPATH)/bin
GOSEC ?= $(GOBIN)/gosec
GOVULNCHECK ?= $(GOBIN)/govulncheck
GOLINT ?= $(GOBIN)/golint
GOFMT ?= $(GOBIN)/gofmt
RELOAD ?= $(GOBIN)/CompileDaemon
Expand Down Expand Up @@ -86,6 +87,14 @@ get-gosec-deps:
@ cd $(GOPATH); \
$(GO) install github.com/securego/gosec/v2/cmd/gosec@latest

.PHONY: govulncheck
govulncheck: get-govulncheck-deps ## running GoVulnCheck
@ $(GOVULNCHECK) ./...

.PHONY: get-govulncheck-deps
get-govulncheck-deps:
@ $(GO) install golang.org/x/vuln/cmd/govulncheck@latest

.PHONY : build
build: ## build application
@ $(GO) version
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/delete/edge_storage/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (b *bucket) runE(cmd *cobra.Command, _ []string) error {
}
}
logger.FInfo(b.factory.IOStreams.Out, "Delete all objects from bucket\n")
logger.FInfo(b.factory.IOStreams.Out, "Deleting objects...")
if err := deleteAllObjects(client, ctx, b.name, ""); err != nil {
return err
}
Expand Down
11 changes: 8 additions & 3 deletions pkg/cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,16 @@ func NewCobraCmd(rootCmd *RootCmd, f *cmdutil.Factory) *cobra.Command {
if strings.HasPrefix(configFlag, PREFIX_FLAG) {
return msg.ErrorPrefix
}
schedule.ExecSchedules(f)
return doPreCommandCheck(cmd, f, PreCmd{

if err := doPreCommandCheck(cmd, f, PreCmd{
config: configFlag,
token: tokenFlag,
})
}); err != nil {
return err
}

schedule.ExecSchedules(f)
return nil
},
Example: heredoc.Doc(`
$ azion
Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
api "github.com/aziontech/azion-cli/pkg/api/storage"
)

const DELETE_BUCKET = "DeleteBucket"
const DELETE_BUCKET = "DeleteBucket"

func TriggerDeleteBucket(f *cmdutil.Factory, name string) error {
client := api.NewClient(
Expand Down
9 changes: 8 additions & 1 deletion pkg/schedule/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,28 @@ func readFileSchedule() ([]Schedule, error) {
}

func ExecSchedules(factory *cmdutil.Factory) {
logger.Debug("Exec Schedules")
schedules, err := readFileSchedule()
if err != nil {
logger.Debug("Error while reading the schedule", zap.Error(err))
return
}
}

scheds := []Schedule{}
for _, s := range schedules {
if CheckIf24HoursPassed(s.Time) {
if s.Kind == DELETE_BUCKET {
if err := TriggerDeleteBucket(factory, s.Name); err != nil {
logger.Debug("Event execution error", zap.Error(err))
scheds = append(scheds, s)
}
}
}
}

if err := createFileSchedule(scheds); err != nil {
logger.Debug("Scheduling error", zap.Error(err))
}
}

// CheckIf24HoursPassed Checks if the current time is before 24 hours after the time 's'.
Expand Down

0 comments on commit 1e38da0

Please sign in to comment.