Skip to content

Commit

Permalink
Merge pull request #961 from aziontech/dev
Browse files Browse the repository at this point in the history
Deploy to Production - 2024/10/03 (Equalize)
  • Loading branch information
PatrickMenoti authored Oct 8, 2024
2 parents a818ad8 + a0e80fd commit e04e6f7
Show file tree
Hide file tree
Showing 37 changed files with 957 additions and 1,298 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy_stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ jobs:
AZION_API: ${{ secrets.AZION_API_STAGE }}
AZION_SSO: ${{ secrets.AZION_SSO_STAGE }}
STORAGE_API: ${{ secrets.STORAGE_API_STAGE }}
CONSOLE_URL: ${{ secrets.CONSOLE_STAGE }}
run: make build ENVFILE=./env/stage

- name: Cross-build
env:
AZION_API: ${{ secrets.AZION_API_STAGE }}
AZION_SSO: ${{ secrets.AZION_SSO_STAGE }}
STORAGE_API: ${{ secrets.STORAGE_API_STAGE }}
CONSOLE_URL: ${{ secrets.CONSOLE_STAGE }}
run: make cross-build ENVFILE=./env/stage

- name: Install AWS CLI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test Vulcan Functionalities
name: End-to-End test

on:
pull_request:
Expand Down Expand Up @@ -30,6 +30,14 @@ jobs:
- name: Setting up a secure repository
run: git config --global --add safe.directory /__w/azion/azion

- name: test vulcan
- name: Install jq
run: |
bash ./scripts/test.sh
apt update
apt install -y jq
- name: e2e test
run: |
bash ./scripts/e2e.sh
env:
TOKEN: ${{ secrets.E2E_TOKEN }}
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ LDFLAGS=-X github.com/aziontech/azion-cli/pkg/cmd/version.BinVersion=$(BIN_VERSI
-X github.com/aziontech/azion-cli/pkg/constants.StorageApiURL=$$STORAGE_URL \
-X github.com/aziontech/azion-cli/pkg/constants.AuthURL=$$AUTH_URL \
-X github.com/aziontech/azion-cli/pkg/constants.ApiURL=$$API_URL \
-X github.com/aziontech/azion-cli/pkg/cmd/deploy.DeployURL=$$CONSOLE \
-X github.com/aziontech/azion-cli/pkg/cmd/deploy.ScriptID=$$SCRIPT_ID \
-X github.com/aziontech/azion-cli/pkg/cmd/edge_applications/init.TemplateBranch=$$TEMPLATE_BRANCH \
-X github.com/aziontech/azion-cli/pkg/cmd/edge_applications/init.TemplateMajor=$$TEMPLATE_MAJOR
LDFLAGS_STRIP=-s -w
Expand Down
2 changes: 1 addition & 1 deletion cmd/azion/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func main() {
streams := iostreams.System()
httpClient := &http.Client{
Timeout: 10 * time.Second, // TODO: Configure this somewhere
Timeout: 20 * time.Second, // TODO: Configure this somewhere
}

tok, _ := token.ReadSettings()
Expand Down
2 changes: 2 additions & 0 deletions env/prod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
API_URL=https://api.azionapi.net
AUTH_URL=https://sso.azion.com/api
STORAGE_URL=https://api.azion.com
CONSOLE=https://console.azion.com
SCRIPT_ID=17ac912d-5ce9-4806-9fa7-480779e43f58
TEMPLATE_BRANCH=main
TEMPLATE_MAJOR=0
2 changes: 2 additions & 0 deletions env/stage
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
API_URL=https://${AZION_API}
AUTH_URL=https://${AZION_SSO}/api
STORAGE_URL=https://${STORAGE_API}
CONSOLE=https://${CONSOLE_URL}
SCRIPT_ID=92480a31-b88b-495b-8615-3ed5eff6314e
TEMPLATE_BRANCH=dev
TEMPLATE_MAJOR=0
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ require (
github.com/aziontech/azionapi-go-sdk v0.133.0
github.com/aziontech/go-thoth v0.0.0-20240228144710-d061a88cc39f
github.com/aziontech/tablecli v0.0.0-20240513193320-c4dbf16b013a
github.com/briandowns/spinner v1.23.1
github.com/fatih/color v1.17.0
github.com/go-git/go-git/v5 v5.12.0
github.com/joho/godotenv v1.5.1
github.com/machinebox/graphql v0.2.2
github.com/manifoldco/promptui v0.9.0
github.com/pelletier/go-toml v1.9.5
github.com/pelletier/go-toml/v2 v2.2.3
github.com/pkg/errors v0.9.1
github.com/riywo/loginshell v0.0.0-20200815045211-7d26008be1ab
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
github.com/schollz/progressbar/v3 v3.15.0
Expand Down Expand Up @@ -61,7 +63,6 @@ require (
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ github.com/aziontech/tablecli v0.0.0-20240513193320-c4dbf16b013a h1:jKR7y/1ePDPZ
github.com/aziontech/tablecli v0.0.0-20240513193320-c4dbf16b013a/go.mod h1:1GXfg8O4vlOUrZRtMShaaUjJ0d9CQ5acecAMkpZ+fOo=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/briandowns/spinner v1.23.1 h1:t5fDPmScwUjozhDj4FA46p5acZWIPXYE30qW2Ptu650=
github.com/briandowns/spinner v1.23.1/go.mod h1:LaZeM4wm2Ywy6vO571mvhQNRcWfRUnXOs0RcKV0wYKM=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
Expand Down
1 change: 1 addition & 0 deletions messages/deploy/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ var (
ErrorCreateDomain = errors.New("Failed to create the Domain: %s. Check your settings and try again. If the error persists, contact Azion support")
ErrorUpdateDomain = errors.New("Failed to update the Domain: %s. Check your settings and try again. If the error persists, contact Azion support")
ErrorInvalidToken = errors.New("The configured token is invalid. You must create a new token and configure it to use with the CLI.")
ErrorDeployRemote = errors.New("Failed to read the response from remote deploy process. Please verify if your deploy finished successfully, and update your azion.json file, if necessary.")
)
2 changes: 2 additions & 0 deletions messages/deploy/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ Do you wish to create a Cache Settings configuration with the above specificatio
NameInUseBucket = "Bucket name is already in use. Trying to create bucket with the following name: %s\n"
NameInUseApplication = "Edge Application name is already in use. Trying to create Edge Application with the following name: %s\n"
NameInUseDomain = "Domain name is already in use. Trying to create Domain with the following name: %s\n"

VisitMsg = "Please visit %s in case it did not open automatically, to follow up the full deploy process\n"
)
10 changes: 5 additions & 5 deletions messages/edge_storage/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ const (
ASK_NOT_EMPTY_BUCKET = "Your bucket can't be deleted because it's not empty. Do you want to empty it? (y/N)"

OUTPUT_CREATE_BUCKET = "Bucket created successfully"
OUTPUT_DELETE_BUCKET = "Bucket %s was deleted successfully"
OUTPUT_UPDATE_BUCKET = "Bucket updated successfully"
OUTPUT_UPDATE_OBJECT = "Object updated successfully"
OUTPUT_CREATE_OBJECT = "Object created successfully"
OUTPUT_DELETE_OBJECT = "Object %s was deleted successfully"
OUTPUT_DELETE_BUCKET = "Bucket %s was deleted successfully\n"
OUTPUT_UPDATE_BUCKET = "Bucket updated successfully\n"
OUTPUT_UPDATE_OBJECT = "Object updated successfully\n"
OUTPUT_CREATE_OBJECT = "Object created successfully\n"
OUTPUT_DELETE_OBJECT = "Object %s was deleted successfully\n"
)
25 changes: 25 additions & 0 deletions pkg/api/storage/credentials.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package storage

import (
"context"

"github.com/aziontech/azion-cli/pkg/logger"
"github.com/aziontech/azion-cli/utils"
sdk "github.com/aziontech/azionapi-go-sdk/storage"
"go.uber.org/zap"
)

type RequestCredentials struct {
sdk.S3CredentialCreate
}

func (c *Client) CreateCredentials(ctx context.Context, request RequestCredentials) (*sdk.ResponseS3Credential, error) {
logger.Debug("Creating s3 credentials ", zap.Any("name", request.Name))
req := c.apiClient.StorageAPI.StorageApiS3CredentialsCreate(ctx).S3CredentialCreate(request.S3CredentialCreate)
resp, httpResp, err := req.Execute()
if err != nil {
logger.Debug("Error while creating the user's s3 credentials", zap.Error(err))
return nil, utils.ErrorPerStatusCode(httpResp, err)
}
return resp, nil
}
6 changes: 3 additions & 3 deletions pkg/api/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,18 @@ func (c *Client) ListObject(ctx context.Context, bucketName string, opts *contra
return resp, nil
}

func (c *Client) Upload(ctx context.Context, fileOps *contracts.FileOps, conf *contracts.AzionApplicationOptions) error {
func (c *Client) Upload(ctx context.Context, fileOps *contracts.FileOps, conf *contracts.AzionApplicationOptions, bucket string) error {
file := fileOps.Path
if conf.Prefix != "" {
file = fmt.Sprintf("%s%s", conf.Prefix, fileOps.Path)
}
logger.Debug("Object_key: " + file)
req := c.apiClient.StorageAPI.StorageApiBucketsObjectsCreate(ctx, conf.Bucket, file).Body(fileOps.FileContent).ContentType(fileOps.MimeType)
req := c.apiClient.StorageAPI.StorageApiBucketsObjectsCreate(ctx, bucket, file).Body(fileOps.FileContent).ContentType(fileOps.MimeType)
_, httpResp, err := req.Execute()
if err != nil {
if httpResp != nil {
logger.Debug("Error while uploading file <"+fileOps.Path+"> to storage api", zap.Error(err))
err := utils.LogAndRewindBody(httpResp)
err = utils.LogAndRewindBody(httpResp)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/delete/edge_storage/bucket/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ func NewBucketCmd(delete *DeleteBucketCmd, f *cmdutil.Factory) *cobra.Command {
}
}
logger.FInfo(f.IOStreams.Out, "Delete all objects from bucket\n")
logger.FInfo(f.IOStreams.Out, "Deleting objects...")
logger.FInfo(f.IOStreams.Out, "Deleting objects...\n")
if err := delete.DeleteAll(client, ctx, bucketName, ""); err != nil {
return err
}
err := client.DeleteBucket(ctx, bucketName)
if err != nil {
if msg.ERROR_NO_EMPTY_BUCKET == err.Error() {
logger.FInfo(f.IOStreams.Out, "Bucket deletion was scheduled successfully")
logger.FInfo(f.IOStreams.Out, "Bucket deletion was scheduled successfully\n")
return schedule.NewSchedule(bucketName, schedule.DELETE_BUCKET)
} else {
return fmt.Errorf(msg.ERROR_DELETE_BUCKET, err.Error())
Expand Down
81 changes: 0 additions & 81 deletions pkg/cmd/deploy/bucket.go

This file was deleted.

61 changes: 0 additions & 61 deletions pkg/cmd/deploy/bucket_test.go

This file was deleted.

35 changes: 0 additions & 35 deletions pkg/cmd/deploy/clients.go

This file was deleted.

Loading

0 comments on commit e04e6f7

Please sign in to comment.