From a4a96b52ce29ebd656191c824acb0648aa83257f Mon Sep 17 00:00:00 2001 From: PatrickMenoti <82882574+PatrickMenoti@users.noreply.github.com> Date: Fri, 19 Jul 2024 13:22:40 -0300 Subject: [PATCH] chore: improve sync and manifest deploy --- pkg/cmd/sync/tasks.go | 7 ++++--- pkg/manifest/manifest.go | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/cmd/sync/tasks.go b/pkg/cmd/sync/tasks.go index bb2fd44eb..af3adf3a8 100644 --- a/pkg/cmd/sync/tasks.go +++ b/pkg/cmd/sync/tasks.go @@ -118,8 +118,9 @@ func (synch *SyncCmd) syncRules(info contracts.SyncOpts, f *cmdutil.Factory) err continue } newRule := contracts.AzionJsonDataRules{ - Id: rule.GetId(), - Name: rule.GetName(), + Id: rule.GetId(), + Name: rule.GetName(), + Phase: rule.GetPhase(), } info.Conf.RulesEngine.Rules = append(info.Conf.RulesEngine.Rules, newRule) err := synch.WriteAzionJsonContent(info.Conf, ProjectConf) @@ -145,7 +146,7 @@ func (synch *SyncCmd) syncEnv(f *cmdutil.Factory) error { envs, err := godotenv.Read(synch.EnvPath) if err != nil { logger.Debug("Error while loading .env file", zap.Error(err)) - return err + return nil // not every project has a .env file... this should not stop the execution } for _, variable := range resp { diff --git a/pkg/manifest/manifest.go b/pkg/manifest/manifest.go index 89b7aa6cc..e203cf312 100644 --- a/pkg/manifest/manifest.go +++ b/pkg/manifest/manifest.go @@ -120,7 +120,7 @@ func (man *ManifestInterpreter) CreateResources( } updated, err := clientOrigin.Update(ctx, conf.Application.ID, OriginKeys[origin.Name], requestUpdate) if err != nil { - return fmt.Errorf("%w: %s", msg.ErrorUpdateOrigin, err.Error()) + return fmt.Errorf("%w - '%s': %s", msg.ErrorUpdateOrigin, updated.GetName(), err.Error()) } newEntry := contracts.AzionJsonDataOrigin{ @@ -142,7 +142,7 @@ func (man *ManifestInterpreter) CreateResources( } created, err := clientOrigin.Create(ctx, conf.Application.ID, requestCreate) if err != nil { - return fmt.Errorf("%w: %s", msg.ErrorCreateOrigin, err.Error()) + return fmt.Errorf("%w - '%s': %s", msg.ErrorCreateOrigin, created.GetName(), err.Error()) } newOrigin := contracts.AzionJsonDataOrigin{ OriginId: created.GetOriginId(), @@ -177,7 +177,7 @@ func (man *ManifestInterpreter) CreateResources( } updated, err := clientCache.Update(ctx, requestUpdate, conf.Application.ID, id) if err != nil { - return fmt.Errorf("%w: %s", msg.ErrorUpdateCache, err.Error()) + return fmt.Errorf("%w - '%s': %s", msg.ErrorUpdateCache, updated.GetName(), err.Error()) } newCache := contracts.AzionJsonDataCacheSettings{ Id: updated.GetId(), @@ -196,7 +196,7 @@ func (man *ManifestInterpreter) CreateResources( } created, err := clientCache.Create(ctx, requestUpdate, conf.Application.ID) if err != nil { - return fmt.Errorf("%w: %s", msg.ErrorCreateCache, err.Error()) + return fmt.Errorf("%w - '%s': %s", msg.ErrorCreateCache, created.GetName(), err.Error()) } newCache := contracts.AzionJsonDataCacheSettings{ Id: created.GetId(), @@ -236,7 +236,7 @@ func (man *ManifestInterpreter) CreateResources( requestUpdate.IdApplication = conf.Application.ID updated, err := client.UpdateRulesEngine(ctx, requestUpdate) if err != nil { - return fmt.Errorf("%w: %s", msg.ErrorUpdateRule, err.Error()) + return fmt.Errorf("%w - '%s': %s", msg.ErrorUpdateRule, updated.GetName(), err.Error()) } newRule := contracts.AzionJsonDataRules{ Id: updated.GetId(), @@ -262,7 +262,7 @@ func (man *ManifestInterpreter) CreateResources( requestCreate.Order = &rule.Order created, err := client.CreateRulesEngine(ctx, conf.Application.ID, rule.Phase, requestCreate) if err != nil { - return fmt.Errorf("%w: %s", msg.ErrorCreateRule, err.Error()) + return fmt.Errorf("%w - '%s': %s", msg.ErrorCreateRule, created.GetName(), err.Error()) } newRule := contracts.AzionJsonDataRules{ Id: created.GetId(),