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

3037 last patch date #3579

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
8 changes: 3 additions & 5 deletions src/api/v1alpha1/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ const (
FileVariableType VariableType = "file"
)

var (
// IsUppercaseNumberUnderscore is a regex for uppercase, numbers and underscores.
// https://regex101.com/r/tfsEuZ/1
IsUppercaseNumberUnderscore = regexp.MustCompile(`^[A-Z0-9_]+$`).MatchString
)
// IsUppercaseNumberUnderscore is a regex for uppercase, numbers and underscores.
// https://regex101.com/r/tfsEuZ/1
var IsUppercaseNumberUnderscore = regexp.MustCompile(`^[A-Z0-9_]+$`).MatchString

// Zarf looks for these strings in zarf.yaml to make dynamic changes
const (
Expand Down
9 changes: 5 additions & 4 deletions src/cmd/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (o *packageCreateOptions) run(cmd *cobra.Command, args []string) error {
l := logger.From(ctx)
pkgConfig.CreateOpts.BaseDir = setBaseDirectory(args)

var isCleanPathRegex = regexp.MustCompile(`^[a-zA-Z0-9\_\-\/\.\~\\:]+$`)
isCleanPathRegex := regexp.MustCompile(`^[a-zA-Z0-9\_\-\/\.\~\\:]+$`)
if !isCleanPathRegex.MatchString(config.CommonOptions.CachePath) {
// TODO(mkcp): Remove message on logger release
message.Warnf(lang.CmdPackageCreateCleanPathErr, config.ZarfDefaultCachePath)
Expand Down Expand Up @@ -601,6 +601,7 @@ func (o *packageListOptions) complete(ctx context.Context) error {

// packageListInfo represents the package information for output.
type packageListInfo struct {
Created string `json:"created_at"`
Package string `json:"package"`
Version string `json:"version"`
Components []string `json:"components"`
Expand All @@ -611,14 +612,14 @@ func (o *packageListOptions) run(ctx context.Context) error {
if err != nil && len(deployedZarfPackages) == 0 {
return fmt.Errorf("unable to get the packages deployed to the cluster: %w", err)
}

var packageList []packageListInfo
for _, pkg := range deployedZarfPackages {
var components []string
for _, component := range pkg.DeployedComponents {
components = append(components, component.Name)
}
packageList = append(packageList, packageListInfo{
Created: pkg.Timestamp,
Package: pkg.Name,
Version: pkg.Data.Metadata.Version,
Components: components,
Expand All @@ -639,11 +640,11 @@ func (o *packageListOptions) run(ctx context.Context) error {
}
fmt.Fprint(o.outputWriter, string(output))
case outputTable:
header := []string{"Package", "Version", "Components"}
header := []string{"Created", "Package", "Version", "Components"}
var packageData [][]string
for _, info := range packageList {
packageData = append(packageData, []string{
info.Package, info.Version, fmt.Sprintf("%v", info.Components),
info.Created, info.Package, info.Version, fmt.Sprintf("%v", info.Components),
})
}
message.TableWithWriter(o.outputWriter, header, packageData)
Expand Down
1 change: 1 addition & 0 deletions src/pkg/cluster/zarf.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (c *Cluster) GetDeployedZarfPackages(ctx context.Context) ([]types.Deployed
errs = append(errs, fmt.Errorf("unable to unmarshal the secret %s/%s", secret.Namespace, secret.Name))
continue
}
deployedPackage.Timestamp = secret.ManagedFields[0].Time.UTC().Format(time.RFC3339)
deployedPackages = append(deployedPackages, deployedPackage)
}

Expand Down
1 change: 1 addition & 0 deletions src/types/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type ZarfState struct {
// This object is saved as the data of a k8s secret within the 'Zarf' namespace (not as part of the ZarfState secret).
type DeployedPackage struct {
Name string `json:"name"`
Timestamp string `json:"timestamp"`
Data v1alpha1.ZarfPackage `json:"data"`
CLIVersion string `json:"cliVersion"`
Generation int `json:"generation"`
Expand Down