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

Ignore deprecated release tag from manifests #647

Merged
merged 11 commits into from
Feb 11, 2022
11 changes: 0 additions & 11 deletions cmd/create_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type newPackageAnswers struct {
Title string
Description string
Categories []string
Release string
KibanaVersion string `survey:"kibana_version"`
GithubOwner string `survey:"github_owner"`
}
Expand Down Expand Up @@ -78,15 +77,6 @@ func createPackageCommandAction(cmd *cobra.Command, args []string) error {
},
Validate: survey.Required,
},
{
Name: "release",
Prompt: &survey.Select{
Message: "Release:",
Options: []string{"experimental", "beta", "ga"},
Default: "experimental",
},
Validate: survey.Required,
},
{
Name: "kibana_version",
Prompt: &survey.Input{
Expand Down Expand Up @@ -136,7 +126,6 @@ func createPackageDescriptorFromAnswers(answers newPackageAnswers) archetype.Pac
Owner: packages.Owner{
Github: answers.GithubOwner,
},
Release: answers.Release,
Description: answers.Description,
License: "basic",
Categories: answers.Categories,
Expand Down
15 changes: 8 additions & 7 deletions cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ func statusCommandAction(cmd *cobra.Command, args []string) error {
options := registry.SearchOptions{
All: showAll,
KibanaVersion: kibanaVersion,
Experimental: true,
Prerelease: true,

// Deprecated
Experimental: true,
}
packageStatus, err := getPackageStatus(packageName, options)
if err != nil {
Expand Down Expand Up @@ -127,21 +130,19 @@ func print(p *status.PackageStatus, w io.Writer) error {
}

bold.Fprintln(w, "Package Versions:")
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Environment", "Version", "Release", "Title", "Description"})
table := tablewriter.NewWriter(w)
table.SetHeader([]string{"Environment", "Version", "Title", "Description"})
table.SetHeaderColor(
twColor(tablewriter.Colors{tablewriter.Bold}),
twColor(tablewriter.Colors{tablewriter.Bold}),
twColor(tablewriter.Colors{tablewriter.Bold}),
twColor(tablewriter.Colors{tablewriter.Bold}),
twColor(tablewriter.Colors{tablewriter.Bold}),
)
table.SetColumnColor(
twColor(tablewriter.Colors{tablewriter.Bold, tablewriter.FgCyanColor}),
twColor(tablewriter.Colors{tablewriter.Bold, tablewriter.FgRedColor}),
tablewriter.Colors{},
tablewriter.Colors{},
tablewriter.Colors{},
)
table.SetRowLine(true)
table.AppendBulk(environmentTable)
Expand All @@ -165,7 +166,7 @@ func formatChangelogEntry(change changelog.Entry) []string {
// formatManifests returns a row of data ffor a set of versioned packaged manifests
func formatManifests(environment string, manifests []packages.PackageManifest) []string {
if len(manifests) == 0 {
return []string{environment, "-", "-", "-", "-"}
return []string{environment, "-", "-", "-"}
}
var extraVersions []string
for i, m := range manifests {
Expand All @@ -182,7 +183,7 @@ func formatManifest(environment string, manifest packages.PackageManifest, extra
if len(extraVersions) > 0 {
version = fmt.Sprintf("%s (%s)", version, strings.Join(extraVersions, ", "))
}
return []string{environment, version, manifest.Release, manifest.Title, manifest.Description}
return []string{environment, version, manifest.Title, manifest.Description}
}

// twColor no-ops the color setting if we don't want to colorize the output
Expand Down
116 changes: 116 additions & 0 deletions cmd/status_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package cmd

import (
"bytes"
"flag"
"io/ioutil"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/internal/packages/status"
)

var generateFlag = flag.Bool("generate", false, "Write golden files")

func fooPackage(version string) packages.PackageManifest {
return packages.PackageManifest{
Name: "foo",
Version: version,
Title: "Foo",
Description: "Foo integration",
}
}

func TestStatusFormatAndPrint(t *testing.T) {
cases := []struct {
title string
pkgStatus *status.PackageStatus
expected string
}{
{
title: "no versions",
pkgStatus: &status.PackageStatus{Name: "foo"},
expected: "./testdata/status-no-versions",
},
{
title: "version-one-stage",
pkgStatus: &status.PackageStatus{
Name: "foo",
Production: []packages.PackageManifest{
fooPackage("1.0.0"),
},
},
expected: "./testdata/status-version-one-stage",
},
{
title: "some versions",
pkgStatus: &status.PackageStatus{
Name: "foo",
Production: []packages.PackageManifest{
fooPackage("1.0.0"),
},
Staging: []packages.PackageManifest{
fooPackage("1.1.0-beta1"),
},
Snapshot: []packages.PackageManifest{
fooPackage("2.0.0-rc1"),
},
},
expected: "./testdata/status-some-versions",
},
{
title: "multiple versions in stage",
pkgStatus: &status.PackageStatus{
Name: "foo",
Production: []packages.PackageManifest{
fooPackage("1.0.0"),
fooPackage("1.0.1"),
fooPackage("1.0.2"),
},
Staging: []packages.PackageManifest{
fooPackage("1.0.0"),
fooPackage("1.0.1"),
fooPackage("1.0.2"),
fooPackage("1.1.0-beta1"),
},
Snapshot: []packages.PackageManifest{
fooPackage("1.0.0"),
fooPackage("1.0.1"),
fooPackage("1.0.2"),
fooPackage("1.1.0-beta1"),
fooPackage("2.0.0-rc1"),
},
},
expected: "./testdata/status-multiple-versions-in-stage",
},
}

for _, c := range cases {
t.Run(c.title, func(t *testing.T) {
var buf bytes.Buffer
err := print(c.pkgStatus, &buf)
require.NoError(t, err)

assertOutputWithFile(t, c.expected, buf.String())
})
}
}

func assertOutputWithFile(t *testing.T, path string, out string) {
if *generateFlag {
err := ioutil.WriteFile(path, []byte(out), 0644)
require.NoError(t, err)
}

d, err := ioutil.ReadFile(path)
require.NoError(t, err)

assert.Equal(t, string(d), out)
}
13 changes: 13 additions & 0 deletions cmd/testdata/status-multiple-versions-in-stage
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Package: foo
Package Versions:
+-------------+--------------------------------+-------+-----------------+
| ENVIRONMENT | VERSION | TITLE | DESCRIPTION |
+-------------+--------------------------------+-------+-----------------+
| Snapshot | 2.0.0-rc1 (1.0.0, 1.0.1, | Foo | Foo integration |
| | 1.0.2, 1.1.0-beta1) | | |
+-------------+--------------------------------+-------+-----------------+
| Staging | 1.1.0-beta1 (1.0.0, 1.0.1, | Foo | Foo integration |
| | 1.0.2) | | |
+-------------+--------------------------------+-------+-----------------+
| Production | 1.0.2 (1.0.0, 1.0.1) | Foo | Foo integration |
+-------------+--------------------------------+-------+-----------------+
11 changes: 11 additions & 0 deletions cmd/testdata/status-no-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Package: foo
Package Versions:
+-------------+---------+-------+-------------+
| ENVIRONMENT | VERSION | TITLE | DESCRIPTION |
+-------------+---------+-------+-------------+
| Snapshot | - | - | - |
+-------------+---------+-------+-------------+
| Staging | - | - | - |
+-------------+---------+-------+-------------+
| Production | - | - | - |
+-------------+---------+-------+-------------+
11 changes: 11 additions & 0 deletions cmd/testdata/status-some-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Package: foo
Package Versions:
+-------------+-------------+-------+-----------------+
| ENVIRONMENT | VERSION | TITLE | DESCRIPTION |
+-------------+-------------+-------+-----------------+
| Snapshot | 2.0.0-rc1 | Foo | Foo integration |
+-------------+-------------+-------+-----------------+
| Staging | 1.1.0-beta1 | Foo | Foo integration |
+-------------+-------------+-------+-----------------+
| Production | 1.0.0 | Foo | Foo integration |
+-------------+-------------+-------+-----------------+
11 changes: 11 additions & 0 deletions cmd/testdata/status-version-one-stage
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Package: foo
Package Versions:
+-------------+---------+-------+-----------------+
| ENVIRONMENT | VERSION | TITLE | DESCRIPTION |
+-------------+---------+-------+-----------------+
| Snapshot | - | - | - |
+-------------+---------+-------+-----------------+
| Staging | - | - | - |
+-------------+---------+-------+-----------------+
| Production | 1.0.0 | Foo | Foo integration |
+-------------+---------+-------+-----------------+
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

replace github.com/elastic/package-spec v1.3.0 => github.com/jsoriano/package-spec v0.0.0-20220112095620-98e0d531845d
Copy link
Member Author

@jsoriano jsoriano Jan 14, 2022

Choose a reason for hiding this comment

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

This change won't be included.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that this PR is blocked on the other one: elastic/package-spec#256?

4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,6 @@ github.com/elastic/go-licenser v0.4.0 h1:jLq6A5SilDS/Iz1ABRkO6BHy91B9jBora8FwGRs
github.com/elastic/go-licenser v0.4.0/go.mod h1:V56wHMpmdURfibNBggaSBfqgPxyT1Tldns1i87iTEvU=
github.com/elastic/go-ucfg v0.8.4 h1:OAHTnubzXKsYYYWVzl8psLcS5mCbNKjXxtMY41itthk=
github.com/elastic/go-ucfg v0.8.4/go.mod h1:4E8mPOLSUV9hQ7sgLEJ4bvt0KhMuDJa8joDT2QGAEKA=
github.com/elastic/package-spec v1.3.0 h1:ntd8EfZ0heZqaZdZpyHJPBFUml9LMlSSZTp04dLZyAg=
github.com/elastic/package-spec v1.3.0/go.mod h1:KzGTSDqCkdhmL1IFpOH2ZQNSSE9JEhNtndxU3ZrQilA=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153 h1:yUdfgN0XgIJw7foRItutHYUIhlcKzcSf5vDpdhQAKTc=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
Expand Down Expand Up @@ -701,6 +699,8 @@ github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jsoriano/package-spec v0.0.0-20220112095620-98e0d531845d h1:9ff/wZIp2jRzwVjCDWtIxOpFaG5A4GD11A6AQCDr8LU=
github.com/jsoriano/package-spec v0.0.0-20220112095620-98e0d531845d/go.mod h1:KzGTSDqCkdhmL1IFpOH2ZQNSSE9JEhNtndxU3ZrQilA=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
Expand Down
1 change: 0 additions & 1 deletion internal/packages/archetype/package_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type: {{.Manifest.Type}}
categories:{{range $category := .Manifest.Categories}}
- {{$category}}
{{- end}}
release: {{.Manifest.Release}}
conditions:
kibana.version: "{{.Manifest.Conditions.Kibana.Version}}"
screenshots:
Expand Down
8 changes: 0 additions & 8 deletions internal/packages/archetype/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ func TestPackage(t *testing.T) {
pd := createPackageDescriptorForTest()
pd.Manifest.Version = ""

err := createAndCheckPackage(t, pd)
require.Error(t, err)
})
t.Run("missing-release", func(t *testing.T) {
pd := createPackageDescriptorForTest()
pd.Manifest.Release = ""

err := createAndCheckPackage(t, pd)
require.Error(t, err)
})
Expand Down Expand Up @@ -74,7 +67,6 @@ func createPackageDescriptorForTest() PackageDescriptor {
Owner: packages.Owner{
Github: "mtojek",
},
Release: "experimental",
Description: "This package has been generated by a Go unit test.",
License: "basic",
Categories: []string{"aws", "custom"},
Expand Down
2 changes: 0 additions & 2 deletions internal/packages/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ type PackageManifest struct {
PolicyTemplates []PolicyTemplate `config:"policy_templates" json:"policy_templates" yaml:"policy_templates"`
Vars []Variable `config:"vars" json:"vars" yaml:"vars"`
Owner Owner `config:"owner" json:"owner" yaml:"owner"`
Release string `config:"release" json:"release" yaml:"release"`
Description string `config:"description" json:"description" yaml:"description"`
License string `config:"license" json:"license" yaml:"license"`
Categories []string `config:"categories" json:"categories" yaml:"categories"`
Expand All @@ -115,7 +114,6 @@ type DataStreamManifest struct {
Title string `config:"title" json:"title" yaml:"title"`
Type string `config:"type" json:"type" yaml:"type"`
Dataset string `config:"dataset" json:"dataset" yaml:"dataset"`
Release string `config:"release" json:"release" yaml:"release"`
Elasticsearch *struct {
IngestPipeline *struct {
Name string `config:"name" json:"name" yaml:"name"`
Expand Down
5 changes: 4 additions & 1 deletion internal/registry/revisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ import (

// SearchOptions specify the query parameters without the package name for the search API
type SearchOptions struct {
Experimental bool `url:"experimental"`
Prerelease bool `url:"prerelease"`
Copy link
Contributor

Choose a reason for hiding this comment

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

... oh, and on the EPR release.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I think this will be the last piece to merge.

All bool `url:"all"`
KibanaVersion string `url:"kibana.version,omitempty"`

// Deprecated
Experimental bool `url:"experimental"`
}

// searchQuery specify the package and query parameters for the search API
Expand Down