Skip to content

Commit

Permalink
feat: add created and updated timestamps to the resource metadata
Browse files Browse the repository at this point in the history
This will allow to keep track of when the resource was created and
updated.
Update is tied to the version bump.

Signed-off-by: Artem Chernyshev <artem.0xD2@gmail.com>
  • Loading branch information
Unix4ever authored and talos-bot committed Jun 23, 2021
1 parent 0731be9 commit 1990ad2
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 142 deletions.
9 changes: 6 additions & 3 deletions api/resource/resource.proto
Expand Up @@ -5,6 +5,7 @@ package resource;
option go_package = "github.com/talos-systems/talos/pkg/machinery/api/resource";

import "common/common.proto";
import "google/protobuf/timestamp.proto";

// The resource service definition.
//
Expand All @@ -27,9 +28,11 @@ message Metadata {
string type = 2;
string id = 3;
string version = 4;
string owner = 7;
string phase = 5;
repeated string finalizers = 6;
string owner = 5;
string phase = 6;
google.protobuf.Timestamp created = 7;
google.protobuf.Timestamp updated = 8;
repeated string finalizers = 9;
}

message Spec {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -29,7 +29,7 @@ require (
github.com/containernetworking/plugins v0.9.1
github.com/coreos/go-iptables v0.6.0
github.com/coreos/go-semver v0.3.0
github.com/cosi-project/runtime v0.0.0-20210623125951-f1649aff7641
github.com/cosi-project/runtime v0.0.0-20210623202226-821d5c362131
github.com/docker/distribution v2.7.1+incompatible
github.com/docker/docker v20.10.7+incompatible
github.com/docker/go-connections v0.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -305,8 +305,8 @@ github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzA
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosi-project/runtime v0.0.0-20210623125951-f1649aff7641 h1:InlDrG3Vg+wAwA/V9Uts5h+/upC9cNwmoB6kSYehBPg=
github.com/cosi-project/runtime v0.0.0-20210623125951-f1649aff7641/go.mod h1:v/3MIWNuuOSdXXMl3QgCSwZrAk1fTOmQHEnTAfvDqP4=
github.com/cosi-project/runtime v0.0.0-20210623202226-821d5c362131 h1:eA+2OiAlQ9UdKdpza2uWvKSF+GfV+/lYtU6w1P6TA1I=
github.com/cosi-project/runtime v0.0.0-20210623202226-821d5c362131/go.mod h1:v/3MIWNuuOSdXXMl3QgCSwZrAk1fTOmQHEnTAfvDqP4=
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
Expand Down
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/cosi-project/runtime/pkg/state"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
"gopkg.in/yaml.v3"

"github.com/talos-systems/talos/pkg/grpc/middleware/authz"
Expand All @@ -36,6 +37,8 @@ func marshalResource(r resource.Resource) (*resourceapi.Resource, error) {
Version: r.Metadata().Version().String(),
Phase: r.Metadata().Phase().String(),
Owner: r.Metadata().Owner(),
Created: timestamppb.New(r.Metadata().Created()),
Updated: timestamppb.New(r.Metadata().Updated()),
}

for _, fin := range *r.Metadata().Finalizers() {
Expand Down
295 changes: 162 additions & 133 deletions pkg/machinery/api/resource/resource.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/machinery/go.mod
Expand Up @@ -11,7 +11,7 @@ require (
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/containerd/go-cni v1.0.2
github.com/containernetworking/cni v0.8.1 // indirect; security fix in 0.8.1
github.com/cosi-project/runtime v0.0.0-20210623125951-f1649aff7641
github.com/cosi-project/runtime v0.0.0-20210623202226-821d5c362131
github.com/dustin/go-humanize v1.0.0
github.com/evanphx/json-patch v4.11.0+incompatible
github.com/ghodss/yaml v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions pkg/machinery/go.sum
Expand Up @@ -17,8 +17,8 @@ github.com/containerd/go-cni v1.0.2/go.mod h1:nrNABBHzu0ZwCug9Ije8hL2xBCYh/pjfMb
github.com/containernetworking/cni v0.8.0/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY=
github.com/containernetworking/cni v0.8.1 h1:7zpDnQ3T3s4ucOuJ/ZCLrYBxzkg0AELFfII3Epo9TmI=
github.com/containernetworking/cni v0.8.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY=
github.com/cosi-project/runtime v0.0.0-20210623125951-f1649aff7641 h1:InlDrG3Vg+wAwA/V9Uts5h+/upC9cNwmoB6kSYehBPg=
github.com/cosi-project/runtime v0.0.0-20210623125951-f1649aff7641/go.mod h1:v/3MIWNuuOSdXXMl3QgCSwZrAk1fTOmQHEnTAfvDqP4=
github.com/cosi-project/runtime v0.0.0-20210623202226-821d5c362131 h1:eA+2OiAlQ9UdKdpza2uWvKSF+GfV+/lYtU6w1P6TA1I=
github.com/cosi-project/runtime v0.0.0-20210623202226-821d5c362131/go.mod h1:v/3MIWNuuOSdXXMl3QgCSwZrAk1fTOmQHEnTAfvDqP4=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
2 changes: 2 additions & 0 deletions website/content/docs/v0.11/Reference/api.md
Expand Up @@ -3096,6 +3096,8 @@ The ListResponse message contains the Resource returned.
| version | [string](#string) | | |
| owner | [string](#string) | | |
| phase | [string](#string) | | |
| created | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| updated | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| finalizers | [string](#string) | repeated | |


Expand Down

0 comments on commit 1990ad2

Please sign in to comment.