Skip to content

Commit

Permalink
add s2ib last run start time (#70)
Browse files Browse the repository at this point in the history
* add s2ib last run start time

* fix NPE

* fix panic

* fix
  • Loading branch information
runzexia authored and ks-ci-bot committed Apr 1, 2019
1 parent b1758e5 commit dc48c60
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
- change s2ir status [@runzexia](https://github.com/kubesphere/s2ioperator/pull/65)
- fix s2ib validate, add s2ir validate [https://github.com/kubesphere/s2ioperator/pull/66]
- add field json tag [@runzexia](https://github.com/kubesphere/s2ioperator/pull/67)
- add s2ib status lastRunStartTime [@runzexia]()

## [ 0.0.7 ] - 2019-03-25
- add informer client [@runzexia](https://github.com/kubesphere/s2ioperator/pull/56)
Expand Down
8 changes: 8 additions & 0 deletions config/crds/devops_v1alpha1_s2ibuilder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ spec:
- JSONPath: .status.lastRunName
name: LastRunName
type: string
- JSONPath: .status.lastRunStartTime
name: LastRunStartTime
type: date
group: devops.kubesphere.io
names:
kind: S2iBuilder
Expand Down Expand Up @@ -386,6 +389,11 @@ spec:
description: LastRunState return the name of the newest run of this
builder
type: string
lastRunStartTime:
description: LastRunStartTime return the startTime of the newest run
of this builder
format: date-time
type: string
lastRunState:
description: LastRunState return the state of the newest run of this
builder
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/devops/v1alpha1/s2ibuilder_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ type S2iBuilderStatus struct {
LastRunState RunState `json:"lastRunState,omitempty"`
//LastRunState return the name of the newest run of this builder
LastRunName *string `json:"lastRunName,omitempty"`
//LastRunStartTime return the startTime of the newest run of this builder
LastRunStartTime *metav1.Time `json:"lastRunStartTime,omitempty"`
}

// +genclient
Expand All @@ -435,6 +437,7 @@ type S2iBuilderStatus struct {
// +kubebuilder:printcolumn:name="RunCount",type="integer",JSONPath=".status.runCount"
// +kubebuilder:printcolumn:name="LastRunState",type="string",JSONPath=".status.lastRunState"
// +kubebuilder:printcolumn:name="LastRunName",type="string",JSONPath=".status.lastRunName"
// +kubebuilder:printcolumn:name="LastRunStartTime",type="date",JSONPath=".status.lastRunStartTime"
// +kubebuilder:resource:shortName=s2ib
type S2iBuilder struct {
metav1.TypeMeta `json:",inline"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/s2ibuilder/s2ibuilder_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,17 @@ func (r *ReconcileS2iBuilder) Reconcile(request reconcile.Request) (reconcile.Re
instance.Status.LastRunName = new(string) //should use defaulting instead of creating here
}
*(instance.Status.LastRunName) = item.Name
if instance.Status.LastRunStartTime == nil {
instance.Status.LastRunStartTime = new(metav1.Time)
}
*(instance.Status.LastRunStartTime) = *item.Status.StartTime
}
}
}
if instance.Status.RunCount == 0 {
instance.Status.LastRunName = nil
instance.Status.LastRunState = ""
instance.Status.LastRunStartTime = nil
}
if !reflect.DeepEqual(instance.Status, origin.Status) {
if err := r.Status().Update(context.Background(), instance); err != nil {
Expand Down

0 comments on commit dc48c60

Please sign in to comment.