Skip to content

Commit

Permalink
add last deployment info to stage
Browse files Browse the repository at this point in the history
part of #36
  • Loading branch information
Ivan Vlasic committed Nov 28, 2021
1 parent c5a2c4f commit f6c154b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions cli/controller/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func (d *Deploy) deploy() error {
}
}

d.stage.SetLastDeployment()
if err := d.store.Store(); err != nil {
return log.Wrap(err)
}
Expand Down
30 changes: 22 additions & 8 deletions domain/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,35 @@ import (
"fmt"
"html/template"
"strings"
"time"
)

const (
EnvMantilConfig = "MANTIL_CONFIG"
)

type Stage struct {
Name string `yaml:"name"`
Default bool `yaml:"default,omitempty"`
NodeName string `yaml:"node"`
Endpoints *StageEndpoints `yaml:"endpoints,omitempty"`
Functions []*Function `yaml:"functions,omitempty"`
Public *Public `yaml:"public,omitempty"`
project *Project
node *Node
Name string `yaml:"name"`
Default bool `yaml:"default,omitempty"`
NodeName string `yaml:"node"`
Endpoints *StageEndpoints `yaml:"endpoints,omitempty"`
LastDeployment *LastDeployment `yaml:"last_deployment,omitempty"`
Functions []*Function `yaml:"functions,omitempty"`
Public *Public `yaml:"public,omitempty"`
project *Project
node *Node
}

type Public struct {
Bucket string `yaml:"bucket"`
Hash string `yaml:"hash,omitempty"`
}

type LastDeployment struct {
Version string `yaml:"version"`
Time time.Time `yaml:"time"`

This comment has been minimized.

Copy link
@ianic

ianic Dec 5, 2021

Member

za sada imamo:

CreatedAt int64
Timestamp int64

ovdje je:
Time time.Time

Je li moguce imati jedan nacin biljezenja trenuka u vremenu?

This comment has been minimized.

Copy link
@IvanVlasic

IvanVlasic Dec 6, 2021

Contributor

Naravno, taj time.Time sam stavio da bude human readable kada korisnik procita file. U ispisu ga onda zaokruzim na sekunde da bude pregledan ispis i da moze prenijeti nekakvu informaciju.

Sto ti se cini bolje od tih formata pa da zamijenim na svim mjestima?

This comment has been minimized.

Copy link
@ianic

ianic Dec 6, 2021

Member

U jednom trenutku sam se odlucio biljeziti vrijeme i duration u ms.
Razumijem da sam time zrtvovao citljivost. Dobio nesto kompaktniji format.

Bitno mi je da je isto, ne koji je format.

Da nema svaki komad koda svoju konvenciju.
Ko onaj Kviletov potpis:

if nil == nesto {

Ako ces mijenjati vidi a Anom sto to njoj znaci u eventima i dynamo table.
Da joj ne izmaknemo stolicu, a mozda i njoj olaksas.

}

func (s *Stage) ResourceTags() map[string]string {
// stage resource tags include tags from both node and project
tags := s.node.ResourceTags()
Expand Down Expand Up @@ -102,6 +109,13 @@ func (s *Stage) SetEndpoints(rest, ws string) {
}
}

func (s *Stage) SetLastDeployment() {
s.LastDeployment = &LastDeployment{
Version: s.node.Version,
Time: time.Now().Round(time.Second),
}
}

func (s *Stage) applyConfiguration(ec *EnvironmentConfig) bool {
if ec == nil {
return false
Expand Down

0 comments on commit f6c154b

Please sign in to comment.