Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy to Production - 2023/03/13 #329

Merged
merged 25 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0307eae
fix: fixed bug fails in case cdn dependency on package.json to run wi…
maxwelbm Mar 3, 2023
3c84197
fix: message from cdn referred to unused package.json, it was changed…
maxwelbm Mar 7, 2023
24c8561
feat: add creations of version-id
PatrickMenoti Mar 7, 2023
7418b3c
fix: add error verification to hash.Write
PatrickMenoti Mar 7, 2023
ca290e4
fix: remove println
PatrickMenoti Mar 7, 2023
eda9cd6
Merge pull request #324 from aziontech/versionID-create
PatrickMenoti Mar 7, 2023
ebdbb2e
Merge pull request #323 from aziontech/fix-init-cdn
maxwelbm Mar 7, 2023
9459ecf
chore: remove update to build script
PatrickMenoti Mar 8, 2023
4971ee2
Merge pull request #325 from aziontech/packagejson-update
PatrickMenoti Mar 8, 2023
86ccf34
chore: remove user input of AWS credentials
PatrickMenoti Mar 9, 2023
1411dfd
Merge pull request #326 from aziontech/remove-AWS
PatrickMenoti Mar 9, 2023
adeb57e
feat: start of upload implementation using storageapi
maxwelbm Mar 9, 2023
d443440
feat: upload running successfully and a simple loading
maxwelbm Mar 10, 2023
accb7f4
ref: loading style improves and pathstatic updated
maxwelbm Mar 10, 2023
d26b513
ref: Returns nil early
maxwelbm Mar 10, 2023
26c1212
ref: update env storage_url and message wait build, and set the file …
maxwelbm Mar 10, 2023
385b987
style: output seending files and link url clicked
maxwelbm Mar 10, 2023
1d6fe9a
fix: adjust test unit
maxwelbm Mar 10, 2023
954757f
fix: versionID being caught before being built
maxwelbm Mar 10, 2023
0cab1e2
fix: bad log
Mar 11, 2023
aeda1ad
ref: removing all references to aws that is no longer used
maxwelbm Mar 11, 2023
876d83f
fix: build project before reading azion file
PatrickMenoti Mar 12, 2023
972d87a
Merge pull request #327 from aziontech/feat-upload-storageapi
maxwelbm Mar 13, 2023
6178b56
fix: add colon to domain url
PatrickMenoti Mar 13, 2023
f717fec
Merge pull request #328 from aziontech/small-fix-publish
PatrickMenoti Mar 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
API_URL: https://api.azionapi.net
STORAGE_URL: ${{ secrets.STORAGE_API_STAGE }}
STORAGE_URL: https://storage-api.azion.com
AUTH_URL: https://sso.azion.com/api/user/me
TEMPLATE_BRANCH: main
4 changes: 2 additions & 2 deletions env/prod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
API_URL=https://api.azionapi.net
AUTH_URL=https://sso.azion.com/api/user/me
STORAGE_URL=${STORAGE_API}
STORAGE_URL=https://storage-api.azion.com
TEMPLATE_BRANCH=main
TEMPLATE_MAJOR=0
TEMPLATE_MAJOR=0
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.17

require (
github.com/MaxwelMazur/tablecli v0.0.0-20230208145104-c9458b902b58
github.com/aziontech/azionapi-go-sdk v0.27.0
github.com/aziontech/azionapi-go-sdk v0.29.0
github.com/fatih/color v1.13.0
github.com/go-git/go-git/v5 v5.4.2
github.com/spf13/cobra v1.6.1
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/aziontech/azionapi-go-sdk v0.27.0 h1:khueEI4CMPJ79IoUD9DsNGX5G2WjntbjZJFwm0J8IFg=
github.com/aziontech/azionapi-go-sdk v0.27.0/go.mod h1:wL7eJYyE2qU853U2iKnQuFHoY69N5WwGnQJwySsdtX0=
github.com/aziontech/azionapi-go-sdk v0.28.0 h1:KLgDgW9BQlr3xL+X2HrcgKV+svOilwlGrRH9woFm0g0=
github.com/aziontech/azionapi-go-sdk v0.28.0/go.mod h1:wL7eJYyE2qU853U2iKnQuFHoY69N5WwGnQJwySsdtX0=
github.com/aziontech/azionapi-go-sdk v0.29.0 h1:dBkDEqZxhG9Z1L8fDcxQc/JFX3toKJJ3VKGvj7OMeZo=
github.com/aziontech/azionapi-go-sdk v0.29.0/go.mod h1:wL7eJYyE2qU853U2iKnQuFHoY69N5WwGnQJwySsdtX0=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand Down
4 changes: 2 additions & 2 deletions messages/edge_applications/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ var (
FailedUpdatingScriptsDeployField = errors.New("Failed to update scripts.deploy field in package.json file. Make sure you have the needed permissions and try again. If the error persists, contact the Azion support")
FailedUpdatingScriptsBuildField = errors.New("Failed to update scripts.build field in package.json file. Make sure you have the needed permissions and try again. If the error persists, contact the Azion support")
FailedUpdatingNameField = errors.New("Failed to update name field in package.json file. Make sure you have the needed permissions and try again. If the error persists, contact the Azion support")
ErrorMandatoryEnvs = errors.New("You must provide the following enviroment variables: AWS_SECRET_ACCESS_KEY and AWS_ACCESS_KEY_ID. Please edit the following file 'azion/webdev.env' and add your credentials")
ErrorFailedCreatingWorkerDirectory = errors.New("Failed to create the worker directory. The worker's parent directory is read-only and/or isn't accessible. Change the permissions of the parent directory to read and write and/or give access to it")
ErrorFailedCreatingPublicDirectory = errors.New("Failed to create the public directory. The public's parent directory is read-only and/or isn't accessible. Change the permissions of the parent directory to read and write and/or give access to it")
ErrorFailedCreatingAzionDirectory = errors.New("Failed to create the azion directory. The public's parent directory is read-only and/or isn't accessible. Change the permissions of the parent directory to read and write and/or give access to it")
Expand Down Expand Up @@ -64,5 +63,6 @@ var (
ErrorMissingAzionJson = errors.New("Azion.json file is missing. Please initialize and publish your project first before using cascade delete")
ErrorFailedUpdateAzionJson = errors.New("Failed to update azion.json file to remove IDs of deleted resource")

ErrorNoFieldInformed = errors.New("Inform at least one field to be updated. It is not possible to update an edge application without specifying the fields that will be updated. Run ‘azioncli edge_applications update --help’ to display more information and try again. If the error persists, contact Azion support.")
ErrorNoFieldInformed = errors.New("Inform at least one field to be updated. It is not possible to update an edge application without specifying the fields that will be updated. Run ‘azioncli edge_applications update --help’ to display more information and try again. If the error persists, contact Azion support.")
ErrorCreateVersionID = errors.New("Failed to create the VersionID.The VersionID is generated based on the files in your working directory. Check the files in your working directory and try again. If the error persists, contact Azion support")
)
10 changes: 5 additions & 5 deletions messages/edge_applications/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ var (
EdgeApplicationsBuildShortDescription = "Builds an Edge Application"
EdgeApplicationsBuildLongDescription = "Builds your Edge Application to run on Azion’s Edge Computing Platform"
EdgeApplicationsBuildRunningCmd = "Running build step command:\n\n"
EdgeApplicationsBuildStart = "Building your Edge Application\n"
EdgeApplicationsBuildStart = "Building your Edge Application. This process may take a few minutes\n"
EdgeApplicationsBuildSuccessful = "Your Edge Application was built successfully\n"
EdgeApplicationsBuildFlagHelp = "Displays more information about the build subcommand"
EdgeApplicationsBuildCdn = "Skipping build step. Build isn't applied to the type 'CDN'"


UploadSuccessful = "Your Upload completed successfully!\n"

//init cmd
EdgeApplicationsInitUsage = `init [flags]
--type string The type of Edge application
Expand All @@ -42,6 +45,7 @@ var (
EdgeApplicationsInitFlagHelp = "Displays more information about the init subcommand"
EdgeApplicationsInitSuccessful = "Your project %s was initialized successfully"
EdgeApplicationsInitNameNotSent = "The Project Name was not sent through the --name flag; By default when --name is not informed the one found in your package.json file or working directory is used\n"
EdgeApplicationsInitNameNotSentCdn = "The project name was not sent by the --name flag; By default, when --name is not given, the working directory is used\n"
EdgeApplicationsUpdateNamePackageJson = "Updating your package.json name field with the value informed through the --name flag"
EdgeApplicationsInitTypeNotSent = "The Project Type was not sent through the --type flag; By default when --type is not informed it is auto-detected based on the framework used by the user\n"

Expand All @@ -63,10 +67,6 @@ var (
EdgeApplicationsPublishFlagHelp = "Displays more information about the publish subcommand"
EdgeApplicationsPublishPropagation = "Content is being propagated to all Azion POPs and it might take a few minutes for all edges to be up to date\n"

EdgeApplicationsAWSMesaage = "Please inform your AWS credentials below:\n"
EdgeApplicationsAWSSecret = "AWS_SECRET_ACCESS_KEY: "
EdgeApplicationsAWSAcess = "AWS_ACCESS_KEY_ID: "

//CRUD
//list cmd
EdgeApplicationsListUsage = "list [flags]"
Expand Down
42 changes: 42 additions & 0 deletions pkg/api/storage/storage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package storage

import (
"context"
"fmt"
"net/http"

"github.com/aziontech/azion-cli/pkg/cmd/version"

"os"

"github.com/aziontech/azion-cli/utils"
sdk "github.com/aziontech/azionapi-go-sdk/storageapi"
)

type Client struct {
apiClient *sdk.APIClient
}

func NewClient(c *http.Client, url string, token string) *Client {
conf := sdk.NewConfiguration()
conf.AddDefaultHeader("Authorization", "Token "+token)
conf.AddDefaultHeader("Accept", "application/json; version=3")
conf.AddDefaultHeader("Content-Type", "application/json")
conf.UserAgent = "Azion_CLI/" + version.BinVersion
conf.Servers = sdk.ServerConfigurations{
{URL: url},
}
return &Client{
apiClient: sdk.NewAPIClient(conf),
}
}

func (c *Client) Upload(ctx context.Context, versionID, path string, file *os.File) error {
c.apiClient.GetConfig().DefaultHeader["Content-Disposition"] = fmt.Sprintf("attachment; filename=\"%s\"", path)
req := c.apiClient.DefaultApi.StorageVersionIdPost(ctx, versionID).XAzionStaticPath(path).Body(file)
_, httpResp, err := req.Execute()
if err != nil {
return utils.ErrorPerStatusCode(httpResp, err)
}
return nil
}
2 changes: 1 addition & 1 deletion pkg/cmd/cache_settings/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewCmd(f *cmdutil.Factory) *cobra.Command {
$ azioncli cache_settings update -a 1673635839 -c 115247 --name "cachesettingstest"
$ azioncli cache_settings update -a 1673635839 -c 115247 --name "cachesettingswithfields" --browser-cache-settings honor --cdn-cache-settings honor --cache-by-query-string ignore
$ azioncli cache_settings update -a 1673635839 --in "update.json"
$ azioncli cache_settings update -a 1674767911 -c 115247 --name "updateagain" --browser-cache-settings override --browser-cache-settings-maximum-ttl 60 --cdn-cache-settings honor --cnd-cache-settings-maximum-ttl 60 --cache-by-query-string ignore --cache-by-query-string whitelist --query-string-fields "heyyy,yoooo" --adaptive-delivery-action ignore --cache-by-cookies blacklist --cookie-names "nem,vem" --enable-caching-for-options true --enable-caching-for-post true --enable-caching-string-sort true --slice-configuration-enabled true
$ azioncli cache_settings update -a 1674767911 -c 115247 --name "updateagain" --browser-cache-settings override --browser-cache-settings-maximum-ttl 60 --cdn-cache-settings honor --cnd-cache-settings-maximum-ttl 60 --cache-by-query-string ignore --cache-by-query-string whitelist --query-string-fields "heyyy,yoooo" --adaptive-delivery-action ignore --cache-by-cookies blacklist --cookie-names "nem,vem" --enable-caching-for-options true --enable-caching-for-post true --enable-caching-string-sort true --slice-configuration-enabled true
`),
RunE: func(cmd *cobra.Command, args []string) error {
client := api.NewClient(f.HttpClient, f.Config.GetString("api_url"), f.Config.GetString("token"))
Expand Down
Loading