Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package will now be listed, sorted by lastupdatedtime #1334

Merged
merged 4 commits into from Oct 1, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/apis/fission.io/v1/types.go
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package v1

import (
"time"

apiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -280,6 +282,9 @@ type (

// BuildLog stores build log during the compilation.
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"`
viveksinghggits marked this conversation as resolved.
Show resolved Hide resolved
}

// PackageRef is a reference to the package.
Expand Down
6 changes: 4 additions & 2 deletions pkg/buildermgr/common.go
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"net/http"
"strings"
"time"

"github.com/dchest/uniuri"
"github.com/pkg/errors"
Expand Down Expand Up @@ -124,8 +125,9 @@ func updatePackage(logger *zap.Logger, fissionClient *crd.FissionClient,
uploadResp *types.ArchiveUploadResponse) (*fv1.Package, error) {

pkg.Status = fv1.PackageStatus{
BuildStatus: status,
BuildLog: buildLogs,
BuildStatus: status,
BuildLog: buildLogs,
LastUpdateTimestamp: time.Now().UTC(),
}

if uploadResp != nil {
Expand Down
23 changes: 16 additions & 7 deletions pkg/fission-cli/package.go
Expand Up @@ -29,8 +29,10 @@ import (
"os"
"path"
"path/filepath"
"sort"
"strings"
"text/tabwriter"
"time"

"github.com/dchest/uniuri"
"github.com/fission/fission/pkg/utils"
Expand Down Expand Up @@ -209,7 +211,8 @@ func updatePackage(client *client.Client, pkg *fv1.Package, envName, envNamespac
if needToBuild || forceRebuild {
// change into pending state to trigger package build
pkg.Status = fv1.PackageStatus{
BuildStatus: fv1.BuildStatusPending,
BuildStatus: fv1.BuildStatusPending,
LastUpdateTimestamp: time.Now().UTC(),
viveksinghggits marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -331,20 +334,25 @@ func pkgList(c *cli.Context) error {
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)
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 {
for _, pkg := range pkgList {
fnList, err := getFunctionsByPackage(client, pkg.Metadata.Name, pkg.Metadata.Namespace)
util.CheckErr(err, fmt.Sprintf("get functions sharing package %s", pkg.Metadata.Name))
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 {
for _, pkg := range pkgList {
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))
}
}

Expand Down Expand Up @@ -621,12 +629,13 @@ func createPackage(c *cli.Context, client *client.Client, pkgNamespace string, e
},
Spec: pkgSpec,
Status: fv1.PackageStatus{
BuildStatus: pkgStatus,
BuildStatus: pkgStatus,
LastUpdateTimestamp: time.Now().UTC(),
},
}

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)))
util.CheckErr(err, "read specs")
if m := fr.SpecExists(pkg, false, true); m != nil {
Expand Down