mirror of https://github.com/helm/helm
parent
6345f04190
commit
91a6ebfed5
@ -1,14 +1,14 @@
|
|||||||
package release
|
package release
|
||||||
|
|
||||||
import google_protobuf "github.com/golang/protobuf/ptypes/timestamp"
|
import "time"
|
||||||
|
|
||||||
// Info describes release information.
|
// Info describes release information.
|
||||||
type Info struct {
|
type Info struct {
|
||||||
Status *Status `json:"status,omitempty"`
|
Status *Status `json:"status,omitempty"`
|
||||||
FirstDeployed *google_protobuf.Timestamp `json:"first_deployed,omitempty"`
|
FirstDeployed time.Time `json:"first_deployed,omitempty"`
|
||||||
LastDeployed *google_protobuf.Timestamp `json:"last_deployed,omitempty"`
|
LastDeployed time.Time `json:"last_deployed,omitempty"`
|
||||||
// Deleted tracks when this object was deleted.
|
// Deleted tracks when this object was deleted.
|
||||||
Deleted *google_protobuf.Timestamp `json:"deleted,omitempty"`
|
Deleted time.Time `json:"deleted,omitempty"`
|
||||||
// Description is human-friendly "log entry" about this release.
|
// Description is human-friendly "log entry" about this release.
|
||||||
Description string `json:"Description,omitempty"`
|
Description string `json:"Description,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package release
|
package release
|
||||||
|
|
||||||
import google_protobuf "github.com/golang/protobuf/ptypes/timestamp"
|
import "time"
|
||||||
|
|
||||||
// TestSuite comprises of the last run of the pre-defined test suite of a release version
|
// TestSuite comprises of the last run of the pre-defined test suite of a release version
|
||||||
type TestSuite struct {
|
type TestSuite struct {
|
||||||
// StartedAt indicates the date/time this test suite was kicked off
|
// StartedAt indicates the date/time this test suite was kicked off
|
||||||
StartedAt *google_protobuf.Timestamp `json:"started_at,omitempty"`
|
StartedAt time.Time `json:"started_at,omitempty"`
|
||||||
// CompletedAt indicates the date/time this test suite was completed
|
// CompletedAt indicates the date/time this test suite was completed
|
||||||
CompletedAt *google_protobuf.Timestamp `json:"completed_at,omitempty"`
|
CompletedAt time.Time `json:"completed_at,omitempty"`
|
||||||
// Results are the results of each segment of the test
|
// Results are the results of each segment of the test
|
||||||
Results []*TestRun `json:"results,omitempty"`
|
Results []*TestRun `json:"results,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 The Kubernetes Authors All rights reserved.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*Package timeconv contains utilities for converting time.
|
|
||||||
|
|
||||||
The gRPC/Protobuf libraries contain time implementations that require conversion
|
|
||||||
to and from Go times. This library provides utilities and convenience functions
|
|
||||||
for performing conversions.
|
|
||||||
*/
|
|
||||||
package timeconv // import "k8s.io/helm/pkg/timeconv"
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 The Kubernetes Authors All rights reserved.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package timeconv
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/golang/protobuf/ptypes/timestamp"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Now creates a timestamp.Timestamp representing the current time.
|
|
||||||
func Now() *timestamp.Timestamp {
|
|
||||||
return Timestamp(time.Now())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Timestamp converts a time.Time to a protobuf *timestamp.Timestamp.
|
|
||||||
func Timestamp(t time.Time) *timestamp.Timestamp {
|
|
||||||
return ×tamp.Timestamp{
|
|
||||||
Seconds: t.Unix(),
|
|
||||||
Nanos: int32(t.Nanosecond()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Time converts a protobuf *timestamp.Timestamp to a time.Time.
|
|
||||||
func Time(ts *timestamp.Timestamp) time.Time {
|
|
||||||
return time.Unix(ts.Seconds, int64(ts.Nanos))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format formats a *timestamp.Timestamp into a string.
|
|
||||||
//
|
|
||||||
// This follows the rules for time.Time.Format().
|
|
||||||
func Format(ts *timestamp.Timestamp, layout string) string {
|
|
||||||
return Time(ts).Format(layout)
|
|
||||||
}
|
|
||||||
|
|
||||||
// String formats the timestamp into a user-friendly string.
|
|
||||||
//
|
|
||||||
// Currently, this uses the 'time.ANSIC' format string, but there is no guarantee
|
|
||||||
// that this will not change.
|
|
||||||
//
|
|
||||||
// This is a convenience function for formatting timestamps for user display.
|
|
||||||
func String(ts *timestamp.Timestamp) string {
|
|
||||||
return Format(ts, time.ANSIC)
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 The Kubernetes Authors All rights reserved.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package timeconv
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestNow(t *testing.T) {
|
|
||||||
now := time.Now()
|
|
||||||
ts := Now()
|
|
||||||
var drift int64 = 5
|
|
||||||
if ts.Seconds < int64(now.Second())-drift {
|
|
||||||
t.Errorf("Unexpected time drift: %d", ts.Seconds)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestTimestamp(t *testing.T) {
|
|
||||||
now := time.Now()
|
|
||||||
ts := Timestamp(now)
|
|
||||||
|
|
||||||
if now.Unix() != ts.Seconds {
|
|
||||||
t.Errorf("Unexpected time drift: %d to %d", now.Second(), ts.Seconds)
|
|
||||||
}
|
|
||||||
|
|
||||||
if now.Nanosecond() != int(ts.Nanos) {
|
|
||||||
t.Errorf("Unexpected nano drift: %d to %d", now.Nanosecond(), ts.Nanos)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestTime(t *testing.T) {
|
|
||||||
nowts := Now()
|
|
||||||
now := Time(nowts)
|
|
||||||
|
|
||||||
if now.Unix() != nowts.Seconds {
|
|
||||||
t.Errorf("Unexpected time drift %d", now.Unix())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFormat(t *testing.T) {
|
|
||||||
now := time.Now()
|
|
||||||
nowts := Timestamp(now)
|
|
||||||
|
|
||||||
if now.Format(time.ANSIC) != Format(nowts, time.ANSIC) {
|
|
||||||
t.Error("Format mismatch")
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue