Skip to content

Commit

Permalink
Merge pull request #1706 from joe-kimmel-vmw/stackrecommenddepwarning
Browse files Browse the repository at this point in the history
adds deprecation warnings to pack stack comands
  • Loading branch information
jkutner authored Apr 13, 2023
2 parents 8cd3ce7 + 750d80f commit 28d211d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
3 changes: 2 additions & 1 deletion internal/commands/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
func NewStackCommand(logger logging.Logger) *cobra.Command {
command := cobra.Command{
Use: "stack",
Short: "Interact with stacks",
Short: "(deprecated) Interact with stacks",
Long: "(Deprecated)\nStacks are deprecated in favor of using BuildImages and RunImages directly, but will continue to be supported throughout all of 2023 and '24 if not longer. Please see our docs for more details- https://buildpacks.io/docs/concepts/components/stack",
RunE: nil,
}

Expand Down
7 changes: 6 additions & 1 deletion internal/commands/stack_suggest.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ type suggestedStack struct {
}

var suggestedStacks = []suggestedStack{
{
ID: "Deprecation Notice",
Description: "Stacks are deprecated in favor of using BuildImages and RunImages directly, but will continue to be supported throughout all of 2023 and 2024 if not longer. Please see our docs for more details- https://buildpacks.io/docs/concepts/components/stack",
Maintainer: "CNB",
},
{
ID: "heroku-20",
Description: "The official Heroku stack based on Ubuntu 20.04",
Expand Down Expand Up @@ -53,7 +58,7 @@ func stackSuggest(logger logging.Logger) *cobra.Command {
cmd := &cobra.Command{
Use: "suggest",
Args: cobra.NoArgs,
Short: "List the recommended stacks",
Short: "(deprecated) List the recommended stacks",
Example: "pack stack suggest",
RunE: logError(logger, func(*cobra.Command, []string) error {
Suggest(logger)
Expand Down
6 changes: 6 additions & 0 deletions internal/commands/stack_suggest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func testStacksSuggestCommand(t *testing.T, when spec.G, it spec.S) {
h.AssertNil(t, command.Execute())
h.AssertEq(t, outBuf.String(), `Stacks maintained by the community:
Stack ID: Deprecation Notice
Description: Stacks are deprecated in favor of using BuildImages and RunImages directly, but will continue to be supported throughout all of 2023 and 2024 if not longer. Please see our docs for more details- https://buildpacks.io/docs/concepts/components/stack
Maintainer: CNB
Build Image:
Run Image:
Stack ID: heroku-20
Description: The official Heroku stack based on Ubuntu 20.04
Maintainer: Heroku
Expand Down
53 changes: 53 additions & 0 deletions internal/commands/stack_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package commands

import (
"bytes"
"testing"

"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
"github.com/spf13/cobra"

"github.com/buildpacks/pack/pkg/logging"
h "github.com/buildpacks/pack/testhelpers"
)

func TestStackCommand(t *testing.T) {
spec.Run(t, "StackCommand", testStackCommand, spec.Parallel(), spec.Report(report.Terminal{}))
}

func testStackCommand(t *testing.T, when spec.G, it spec.S) {
var (
command *cobra.Command
outBuf bytes.Buffer
)

it.Before(func() {
command = NewStackCommand(logging.NewLogWithWriters(&outBuf, &outBuf))
})

when("#Stack", func() {
it("displays stack information", func() {
command.SetArgs([]string{})
bb := bytes.NewBufferString("") // In most tests we don't seem to need to this, not sure why it's necessary here.
command.SetOut(bb)
h.AssertNil(t, command.Execute())
h.AssertEq(t, bb.String(), `(Deprecated)
Stacks are deprecated in favor of using BuildImages and RunImages directly, but will continue to be supported throughout all of 2023 and '24 if not longer. Please see our docs for more details- https://buildpacks.io/docs/concepts/components/stack
Usage:
stack [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
suggest (deprecated) List the recommended stacks
Flags:
-h, --help help for stack
Use "stack [command] --help" for more information about a command.
`)
})
})
}

0 comments on commit 28d211d

Please sign in to comment.