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

adds deprecation warnings to pack stack comands #1706

Merged
merged 5 commits into from
Apr 13, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
`)
})
})
}