Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Replace custom `time.Time` wrapper `DeepCopyTime` with Kubernetes built-in `metav1.Time`.

## [0.2.6] - 2020-04-15

### Added
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jonboulle/clockwork v0.0.0-20141017032234-72f9bd7c4e0c/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
Expand Down Expand Up @@ -279,6 +280,7 @@ github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTd
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.0-20180319062004-c439c4fa0937/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/application/v1alpha1/app_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ type AppStatus struct {

type AppStatusRelease struct {
// LastDeployed is the time when the app was last deployed.
LastDeployed DeepCopyTime `json:"lastDeployed" yaml:"lastDeployed"`
LastDeployed metav1.Time `json:"lastDeployed" yaml:"lastDeployed"`
// Reason is the description of the last status of helm release when the app is
// not installed successfully, e.g. deploy resource already exists.
Reason string `json:"reason,omitempty" yaml:"reason,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/application/v1alpha1/chart_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ type ChartStatus struct {

type ChartStatusRelease struct {
// LastDeployed is the time when the deployed chart was last deployed.
LastDeployed DeepCopyTime `json:"lastDeployed" yaml:"lastDeployed"`
LastDeployed metav1.Time `json:"lastDeployed" yaml:"lastDeployed"`
// Revision is the revision number for this deployed chart.
Revision int `json:"revision" yaml:"revision"`
// Status is the status of the deployed chart,
Expand Down
15 changes: 0 additions & 15 deletions pkg/apis/application/v1alpha1/deep_copy.go

This file was deleted.

10 changes: 0 additions & 10 deletions pkg/apis/application/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 0 additions & 15 deletions pkg/apis/backup/v1alpha1/deep_copy.go

This file was deleted.

8 changes: 4 additions & 4 deletions pkg/apis/backup/v1alpha1/etcd_backup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ type ETCDBackupStatus struct {
// Status of the whole backup job (can be 'Pending', 'Running'. 'Completed', 'Failed')
Status string `json:"status" yaml:"status"`
// Timestamp when the first attempt was made
StartedTimestamp DeepCopyTime `json:"startedTimestamp,omitempty" yaml:"startedTimestamp"`
StartedTimestamp metav1.Time `json:"startedTimestamp,omitempty" yaml:"startedTimestamp"`
// Timestamp when the last (final) attempt was made (when the Phase became either 'Completed' or 'Failed'
FinishedTimestamp DeepCopyTime `json:"finishedTimestamp,omitempty" yaml:"finishedTimestamp"`
FinishedTimestamp metav1.Time `json:"finishedTimestamp,omitempty" yaml:"finishedTimestamp"`
}

type ETCDInstanceBackupStatusIndex struct {
Expand All @@ -129,9 +129,9 @@ type ETCDInstanceBackupStatus struct {
// Status of this isntance's backup job (can be 'Pending', 'Running'. 'Completed', 'Failed')
Status string `json:"status" yaml:"status"`
// Timestamp when the first attempt was made
StartedTimestamp DeepCopyTime `json:"startedTimestamp,omitempty" yaml:"startedTimestamp"`
StartedTimestamp metav1.Time `json:"startedTimestamp,omitempty" yaml:"startedTimestamp"`
// Timestamp when the last (final) attempt was made (when the Phase became either 'Completed' or 'Failed'
FinishedTimestamp DeepCopyTime `json:"finishedTimestamp,omitempty" yaml:"finishedTimestamp"`
FinishedTimestamp metav1.Time `json:"finishedTimestamp,omitempty" yaml:"finishedTimestamp"`
// Latest backup error message
LatestError string `json:"latestError,omitempty" yaml:"latestError,omitempty"`
// Time took by the backup creation process
Expand Down
10 changes: 0 additions & 10 deletions pkg/apis/backup/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/apis/core/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ type ClusterSpec struct {
// creation and made available here.
type ClusterStatus struct {
// LastHeartbeatTime is the last time we got an update on a given condition.
LastHeartbeatTime DeepCopyTime `json:"lastHeartbeatTime" yaml:"lastHeartbeatTime"`
LastHeartbeatTime metav1.Time `json:"lastHeartbeatTime" yaml:"lastHeartbeatTime"`
// LastTransitionTime is the last time the condition transitioned from one
// status to another.
LastTransitionTime DeepCopyTime `json:"lastTransitionTime" yaml:"lastTransitionTime"`
LastTransitionTime metav1.Time `json:"lastTransitionTime" yaml:"lastTransitionTime"`
// Cluster holds cluster specific status information.
Cluster ClusterStatusCluster `json:"cluster" yaml:"cluster"`
// Conditions is a list of status conditions.
Expand Down
15 changes: 0 additions & 15 deletions pkg/apis/core/v1alpha1/deep_copy.go

This file was deleted.

8 changes: 5 additions & 3 deletions pkg/apis/core/v1alpha1/drainer_funcs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package v1alpha1

import "time"
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func (s DrainerConfigStatus) HasDrainedCondition() bool {
return hasDrainerConfigCondition(s.Conditions, DrainerConfigStatusStatusTrue, DrainerConfigStatusTypeDrained)
Expand All @@ -12,15 +14,15 @@ func (s DrainerConfigStatus) HasTimeoutCondition() bool {

func (s DrainerConfigStatus) NewDrainedCondition() DrainerConfigStatusCondition {
return DrainerConfigStatusCondition{
LastTransitionTime: DeepCopyTime{time.Now()},
LastTransitionTime: metav1.Now(),
Status: DrainerConfigStatusStatusTrue,
Type: DrainerConfigStatusTypeDrained,
}
}

func (s DrainerConfigStatus) NewTimeoutCondition() DrainerConfigStatusCondition {
return DrainerConfigStatusCondition{
LastTransitionTime: DeepCopyTime{time.Now()},
LastTransitionTime: metav1.Now(),
Status: DrainerConfigStatusStatusTrue,
Type: DrainerConfigStatusTypeTimeout,
}
Expand Down
18 changes: 10 additions & 8 deletions pkg/apis/core/v1alpha1/drainer_funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package v1alpha1
import (
"testing"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func Test_HasDrainedCondition(t *testing.T) {
Expand All @@ -20,8 +22,8 @@ func Test_HasDrainedCondition(t *testing.T) {
name: "case 1: DrainerConfigStatus with Drained status condition in conditions",
status: DrainerConfigStatus{
Conditions: []DrainerConfigStatusCondition{
DrainerConfigStatusCondition{
LastTransitionTime: DeepCopyTime{time.Now()},
{
LastTransitionTime: metav1.Time{Time: time.Now()},
Status: DrainerConfigStatusStatusTrue,
Type: DrainerConfigStatusTypeDrained,
},
Expand All @@ -33,8 +35,8 @@ func Test_HasDrainedCondition(t *testing.T) {
name: "case 2: DrainerConfigStatus with Timeout status condition in conditions doesn't have Drained condition",
status: DrainerConfigStatus{
Conditions: []DrainerConfigStatusCondition{
DrainerConfigStatusCondition{
LastTransitionTime: DeepCopyTime{time.Now()},
{
LastTransitionTime: metav1.Time{Time: time.Now()},
Status: DrainerConfigStatusStatusTrue,
Type: DrainerConfigStatusTypeTimeout,
},
Expand Down Expand Up @@ -70,8 +72,8 @@ func Test_HasTimeoutCondition(t *testing.T) {
name: "case 1: DrainerConfigStatus with Timeout status condition in conditions",
status: DrainerConfigStatus{
Conditions: []DrainerConfigStatusCondition{
DrainerConfigStatusCondition{
LastTransitionTime: DeepCopyTime{time.Now()},
{
LastTransitionTime: metav1.Time{Time: time.Now()},
Status: DrainerConfigStatusStatusTrue,
Type: DrainerConfigStatusTypeTimeout,
},
Expand All @@ -83,8 +85,8 @@ func Test_HasTimeoutCondition(t *testing.T) {
name: "case 2: DrainerConfigStatus with Drained status condition in conditions doesn't have Timeout condition",
status: DrainerConfigStatus{
Conditions: []DrainerConfigStatusCondition{
DrainerConfigStatusCondition{
LastTransitionTime: DeepCopyTime{time.Now()},
{
LastTransitionTime: metav1.Time{Time: time.Now()},
Status: DrainerConfigStatusStatusTrue,
Type: DrainerConfigStatusTypeDrained,
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/core/v1alpha1/drainer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ type DrainerConfigStatus struct {
// DrainerConfigStatusCondition expresses a condition in which a node may is.
type DrainerConfigStatusCondition struct {
// LastHeartbeatTime is the last time we got an update on a given condition.
LastHeartbeatTime DeepCopyTime `json:"lastHeartbeatTime" yaml:"lastHeartbeatTime"`
LastHeartbeatTime metav1.Time `json:"lastHeartbeatTime" yaml:"lastHeartbeatTime"`
// LastTransitionTime is the last time the condition transitioned from one
// status to another.
LastTransitionTime DeepCopyTime `json:"lastTransitionTime" yaml:"lastTransitionTime"`
LastTransitionTime metav1.Time `json:"lastTransitionTime" yaml:"lastTransitionTime"`
// Status may be True, False or Unknown.
Status string `json:"status" yaml:"status"`
// Type may be Pending, Ready, Draining, Drained.
Expand Down
10 changes: 0 additions & 10 deletions pkg/apis/core/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 15 additions & 13 deletions pkg/apis/infrastructure/v1alpha2/common_cluster_status_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package v1alpha2
import (
"sort"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func (s CommonClusterStatus) GetCreatedCondition() CommonClusterStatusCondition {
Expand Down Expand Up @@ -79,7 +81,7 @@ func (s CommonClusterStatus) LatestVersion() string {

func (s CommonClusterStatus) WithCreatedCondition() []CommonClusterStatusCondition {
newCondition := CommonClusterStatusCondition{
LastTransitionTime: DeepCopyTime{time.Now()},
LastTransitionTime: metav1.Now(),
Condition: ClusterStatusConditionCreated,
}

Expand All @@ -88,7 +90,7 @@ func (s CommonClusterStatus) WithCreatedCondition() []CommonClusterStatusConditi

func (s CommonClusterStatus) WithCreatingCondition() []CommonClusterStatusCondition {
newCondition := CommonClusterStatusCondition{
LastTransitionTime: DeepCopyTime{time.Now()},
LastTransitionTime: metav1.Now(),
Condition: ClusterStatusConditionCreating,
}

Expand All @@ -97,7 +99,7 @@ func (s CommonClusterStatus) WithCreatingCondition() []CommonClusterStatusCondit

func (s CommonClusterStatus) WithDeletedCondition() []CommonClusterStatusCondition {
newCondition := CommonClusterStatusCondition{
LastTransitionTime: DeepCopyTime{time.Now()},
LastTransitionTime: metav1.Now(),
Condition: ClusterStatusConditionDeleted,
}

Expand All @@ -106,7 +108,7 @@ func (s CommonClusterStatus) WithDeletedCondition() []CommonClusterStatusConditi

func (s CommonClusterStatus) WithDeletingCondition() []CommonClusterStatusCondition {
newCondition := CommonClusterStatusCondition{
LastTransitionTime: DeepCopyTime{time.Now()},
LastTransitionTime: metav1.Now(),
Condition: ClusterStatusConditionDeleting,
}

Expand All @@ -115,7 +117,7 @@ func (s CommonClusterStatus) WithDeletingCondition() []CommonClusterStatusCondit

func (s CommonClusterStatus) WithNewVersion(version string) []CommonClusterStatusVersion {
newVersion := CommonClusterStatusVersion{
LastTransitionTime: DeepCopyTime{time.Now()},
LastTransitionTime: metav1.Now(),
Version: version,
}

Expand All @@ -124,7 +126,7 @@ func (s CommonClusterStatus) WithNewVersion(version string) []CommonClusterStatu

func (s CommonClusterStatus) WithUpdatedCondition() []CommonClusterStatusCondition {
newCondition := CommonClusterStatusCondition{
LastTransitionTime: DeepCopyTime{time.Now()},
LastTransitionTime: metav1.Now(),
Condition: ClusterStatusConditionUpdated,
}

Expand All @@ -133,7 +135,7 @@ func (s CommonClusterStatus) WithUpdatedCondition() []CommonClusterStatusConditi

func (s CommonClusterStatus) WithUpdatingCondition() []CommonClusterStatusCondition {
newCondition := CommonClusterStatusCondition{
LastTransitionTime: DeepCopyTime{time.Now()},
LastTransitionTime: metav1.Now(),
Condition: ClusterStatusConditionUpdating,
}

Expand Down Expand Up @@ -219,7 +221,7 @@ func withCondition(conditions []CommonClusterStatusCondition, condition CommonCl
// automatically added condition does not obtain a reasonable timestamp.
// Here we take the timestamp of the new condition we want to track and
// substract one nano second from it to keep the order intact.
LastTransitionTime: DeepCopyTime{condition.LastTransitionTime.Add(-(1 * time.Nanosecond))},
LastTransitionTime: metav1.Time{Time: condition.LastTransitionTime.Add(-(1 * time.Nanosecond))},
Condition: getConditionForPair(condition),
}
newConditions = append(newConditions, injected)
Expand Down Expand Up @@ -259,15 +261,15 @@ func withCondition(conditions []CommonClusterStatusCondition, condition CommonCl
// the grouped item from the list.
if len(g) == 0 {
g = append(g, c)
newConditions = newConditions[1:len(newConditions)]
newConditions = newConditions[1:]
continue
}

// When we find the second item of the pair we are done for this group.
if len(g) == 1 {
if isConditionPair(g[0], c) {
g = append(g, c)
newConditions = newConditions[1:len(newConditions)]
newConditions = newConditions[1:]
}
break
}
Expand All @@ -286,14 +288,14 @@ func withCondition(conditions []CommonClusterStatusCondition, condition CommonCl
for _, g := range conditionGroups {
if len(p) == 0 {
p = append(p, g...)
conditionGroups = conditionGroups[1:len(conditionGroups)]
conditionGroups = conditionGroups[1:]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some extra cleanup--semantics are identical as far as I know.

continue
}

if len(g) >= 1 {
if isConditionPair(p[0], g[0]) || isConditionPair(p[1], g[0]) {
p = append(p, g...)
conditionGroups = conditionGroups[1:len(conditionGroups)]
conditionGroups = conditionGroups[1:]
}
}
}
Expand All @@ -316,7 +318,7 @@ func withCondition(conditions []CommonClusterStatusCondition, condition CommonCl
l = len(p)
}

limittedList = append(limittedList, p[len(p)-l:len(p)]...)
limittedList = append(limittedList, p[len(p)-l:]...)
}

// We reverse the list order to have the item with the highest timestamp at
Expand Down
Loading