package will now be listed, sorted by lastupdatedtime (#1334)
This commit is contained in:
committed by
Ta-Ching Chen
parent
b47b3ecb70
commit
96ae708163
@@ -17,6 +17,8 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
@@ -280,6 +282,9 @@ type (
|
|||||||
|
|
||||||
// BuildLog stores build log during the compilation.
|
// BuildLog stores build log during the compilation.
|
||||||
BuildLog string `json:"buildlog,omitempty"` // output of the build (errors etc)
|
BuildLog string `json:"buildlog,omitempty"` // output of the build (errors etc)
|
||||||
|
|
||||||
|
// LastUpdateTimestamp will store the timestamp the package was last updated
|
||||||
|
LastUpdateTimestamp time.Time `json:"lastUpdateTimestamp,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackageRef is a reference to the package.
|
// PackageRef is a reference to the package.
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/dchest/uniuri"
|
"github.com/dchest/uniuri"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@@ -124,8 +125,9 @@ func updatePackage(logger *zap.Logger, fissionClient *crd.FissionClient,
|
|||||||
uploadResp *types.ArchiveUploadResponse) (*fv1.Package, error) {
|
uploadResp *types.ArchiveUploadResponse) (*fv1.Package, error) {
|
||||||
|
|
||||||
pkg.Status = fv1.PackageStatus{
|
pkg.Status = fv1.PackageStatus{
|
||||||
BuildStatus: status,
|
BuildStatus: status,
|
||||||
BuildLog: buildLogs,
|
BuildLog: buildLogs,
|
||||||
|
LastUpdateTimestamp: time.Now().UTC(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if uploadResp != nil {
|
if uploadResp != nil {
|
||||||
|
|||||||
@@ -29,8 +29,10 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/dchest/uniuri"
|
"github.com/dchest/uniuri"
|
||||||
"github.com/fission/fission/pkg/utils"
|
"github.com/fission/fission/pkg/utils"
|
||||||
@@ -209,7 +211,8 @@ func updatePackage(client *client.Client, pkg *fv1.Package, envName, envNamespac
|
|||||||
if needToBuild || forceRebuild {
|
if needToBuild || forceRebuild {
|
||||||
// change into pending state to trigger package build
|
// change into pending state to trigger package build
|
||||||
pkg.Status = fv1.PackageStatus{
|
pkg.Status = fv1.PackageStatus{
|
||||||
BuildStatus: fv1.BuildStatusPending,
|
BuildStatus: fv1.BuildStatusPending,
|
||||||
|
LastUpdateTimestamp: time.Now().UTC(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,20 +334,25 @@ func pkgList(c *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sort the package list by lastUpdatedTimestamp
|
||||||
|
sort.Slice(pkgList, func(i, j int) bool {
|
||||||
|
return pkgList[i].Status.LastUpdateTimestamp.After(pkgList[j].Status.LastUpdateTimestamp)
|
||||||
|
})
|
||||||
|
|
||||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||||
fmt.Fprintf(w, "%v\t%v\t%v\n", "NAME", "BUILD_STATUS", "ENV")
|
fmt.Fprintf(w, "%v\t%v\t%v\t%v\n", "NAME", "BUILD_STATUS", "ENV", "LASTUPDATEDAT")
|
||||||
if listOrphans {
|
if listOrphans {
|
||||||
for _, pkg := range pkgList {
|
for _, pkg := range pkgList {
|
||||||
fnList, err := getFunctionsByPackage(client, pkg.Metadata.Name, pkg.Metadata.Namespace)
|
fnList, err := getFunctionsByPackage(client, pkg.Metadata.Name, pkg.Metadata.Namespace)
|
||||||
util.CheckErr(err, fmt.Sprintf("get functions sharing package %s", pkg.Metadata.Name))
|
util.CheckErr(err, fmt.Sprintf("get functions sharing package %s", pkg.Metadata.Name))
|
||||||
if len(fnList) == 0 {
|
if len(fnList) == 0 {
|
||||||
fmt.Fprintf(w, "%v\t%v\t%v\n", pkg.Metadata.Name, pkg.Status.BuildStatus, pkg.Spec.Environment.Name)
|
fmt.Fprintf(w, "%v\t%v\t%v\t%v\n", pkg.Metadata.Name, pkg.Status.BuildStatus, pkg.Spec.Environment.Name, pkg.Status.LastUpdateTimestamp.Format(time.RFC3339))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for _, pkg := range pkgList {
|
for _, pkg := range pkgList {
|
||||||
fmt.Fprintf(w, "%v\t%v\t%v\n", pkg.Metadata.Name,
|
fmt.Fprintf(w, "%v\t%v\t%v\t%v\n", pkg.Metadata.Name,
|
||||||
pkg.Status.BuildStatus, pkg.Spec.Environment.Name)
|
pkg.Status.BuildStatus, pkg.Spec.Environment.Name, pkg.Status.LastUpdateTimestamp.Format(time.RFC3339))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,12 +629,13 @@ func createPackage(c *cli.Context, client *client.Client, pkgNamespace string, e
|
|||||||
},
|
},
|
||||||
Spec: pkgSpec,
|
Spec: pkgSpec,
|
||||||
Status: fv1.PackageStatus{
|
Status: fv1.PackageStatus{
|
||||||
BuildStatus: pkgStatus,
|
BuildStatus: pkgStatus,
|
||||||
|
LastUpdateTimestamp: time.Now().UTC(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(specFile) > 0 {
|
if len(specFile) > 0 {
|
||||||
// if a package sith the same spec exists, don't create a new spec file
|
// if a package with the same spec exists, don't create a new spec file
|
||||||
fr, err := readSpecs(cmdutils.GetSpecDir(urfavecli.Parse(c)))
|
fr, err := readSpecs(cmdutils.GetSpecDir(urfavecli.Parse(c)))
|
||||||
util.CheckErr(err, "read specs")
|
util.CheckErr(err, "read specs")
|
||||||
if m := fr.SpecExists(pkg, false, true); m != nil {
|
if m := fr.SpecExists(pkg, false, true); m != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user