From 0c4a2c46c96c403161efed7b9e6bff64399a633a Mon Sep 17 00:00:00 2001 From: Daniel Mikusa Date: Sun, 20 Oct 2024 21:53:11 -0400 Subject: [PATCH] Update stacks - Remove bionic stack which is EOL - Add noble stack - Update tests Signed-off-by: Daniel Mikusa --- stack.go | 38 +++++++++++++-------------- stack_test.go | 71 +++++++++++++++++++++++++++++++++++---------------- 2 files changed, 67 insertions(+), 42 deletions(-) diff --git a/stack.go b/stack.go index d2f26ac..8cee49b 100644 --- a/stack.go +++ b/stack.go @@ -1,5 +1,5 @@ /* - * Copyright 2018-2020 the original author or authors. + * Copyright 2018-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,17 +17,6 @@ package libpak const ( - // BionicStackID is the ID for the Cloud Native Buildpacks bionic stack. - BionicStackID = "io.buildpacks.stacks.bionic" - - // BionicTinyStackID is the ID for the Paketo Buildpacks bionic tiny stack. - BionicTinyStackID = "io.paketo.stacks.tiny" - - // TinyStackID is the ID for the Paketo Buildpacks bionic tiny stack. - // - // Deprecated: use BionicTinyStackID instead - TinyStackID = "io.paketo.stacks.tiny" - // JammyStackID is the ID for the Cloud Native Buildpacks jammy stack. JammyStackID = "io.buildpacks.stacks.jammy" @@ -36,29 +25,38 @@ const ( // JammyStaticStackID is the ID for the Cloud Native Buildpacks jammy static stack. JammyStaticStackID = "io.buildpacks.stacks.jammy.static" -) -// IsBionicStack returns true if the stack is one of the bionic variants -func IsBionicStack(stack string) bool { - return BionicStackID == stack || BionicTinyStackID == stack || TinyStackID == stack -} + // NobleStackID is the ID for the Cloud Native Buildpacks noble stack. + NobleStackID = "io.buildpacks.stacks.noble" + + // NobleTinyStackID is the ID for the Cloud Native Buildpacks noble tiny stack. + NobleTinyStackID = "io.buildpacks.stacks.noble.tiny" + + // NobleStaticStackID is the ID for the Cloud Native Buildpacks noble static stack. + NobleStaticStackID = "io.buildpacks.stacks.noble.static" +) // IsJammyStack returns true if the stack is one of the jammy variants func IsJammyStack(stack string) bool { return JammyStackID == stack || JammyTinyStackID == stack || JammyStaticStackID == stack } +// IsNobleStack returns true if the stack is one of the noble variants +func IsNobleStack(stack string) bool { + return NobleStackID == stack || NobleTinyStackID == stack || NobleStaticStackID == stack +} + // IsTinyStack returns true if the stack is one of the tiny variants func IsTinyStack(stack string) bool { - return BionicTinyStackID == stack || JammyTinyStackID == stack || TinyStackID == stack + return JammyTinyStackID == stack || NobleTinyStackID == stack } // IsStaticStack returns true if the stack is one of the static variants func IsStaticStack(stack string) bool { - return JammyStaticStackID == stack + return JammyStaticStackID == stack || NobleStaticStackID == stack } // IsShellPresentOnStack returns true if the stack is known to have a shell func IsShellPresentOnStack(stack string) bool { - return BionicStackID == stack || JammyStackID == stack + return JammyStackID == stack || NobleStackID == stack } diff --git a/stack_test.go b/stack_test.go index 51cd92c..4d489bb 100644 --- a/stack_test.go +++ b/stack_test.go @@ -1,3 +1,18 @@ +/* + * Copyright 2018-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package libpak_test import ( @@ -14,20 +29,6 @@ func testStack(t *testing.T, context spec.G, it spec.S) { Expect = NewWithT(t).Expect ) - context("bionic stacks", func() { - it("matches standard bionic stack", func() { - Expect(libpak.IsBionicStack("io.buildpacks.stacks.bionic")).To(BeTrue()) - }) - - it("matches tiny bionic stack", func() { - Expect(libpak.IsBionicStack("io.paketo.stacks.tiny")).To(BeTrue()) - }) - - it("does not match non-bionic stack", func() { - Expect(libpak.IsBionicStack("io.buildpacks.stacks.jammy")).To(BeFalse()) - }) - }) - context("jammy stacks", func() { it("matches standard jammy stack", func() { Expect(libpak.IsJammyStack("io.buildpacks.stacks.jammy")).To(BeTrue()) @@ -42,21 +43,39 @@ func testStack(t *testing.T, context spec.G, it spec.S) { }) it("does not match non-jammy stack", func() { - Expect(libpak.IsJammyStack("io.buildpacks.stacks.bionic")).To(BeFalse()) + Expect(libpak.IsJammyStack("io.buildpacks.stacks.noble")).To(BeFalse()) }) }) - context("tiny stacks", func() { - it("matches tiny bionic stack", func() { - Expect(libpak.IsTinyStack("io.paketo.stacks.tiny")).To(BeTrue()) + context("noble stacks", func() { + it("matches standard noble stack", func() { + Expect(libpak.IsNobleStack("io.buildpacks.stacks.noble")).To(BeTrue()) + }) + + it("matches tiny noble stack", func() { + Expect(libpak.IsNobleStack("io.buildpacks.stacks.noble.tiny")).To(BeTrue()) + }) + + it("matches static noble stack", func() { + Expect(libpak.IsNobleStack("io.buildpacks.stacks.noble.static")).To(BeTrue()) + }) + + it("does not match non-noble stack", func() { + Expect(libpak.IsNobleStack("io.buildpacks.stacks.jammy")).To(BeFalse()) }) + }) + context("tiny stacks", func() { it("matches tiny jammy stack", func() { Expect(libpak.IsTinyStack("io.buildpacks.stacks.jammy.tiny")).To(BeTrue()) }) + it("matches tiny noble stack", func() { + Expect(libpak.IsTinyStack("io.buildpacks.stacks.noble.tiny")).To(BeTrue()) + }) + it("does not match full stack", func() { - Expect(libpak.IsTinyStack("io.buildpacks.stacks.bionic")).To(BeFalse()) + Expect(libpak.IsTinyStack("io.buildpacks.stacks.jammy")).To(BeFalse()) }) }) @@ -65,14 +84,22 @@ func testStack(t *testing.T, context spec.G, it spec.S) { Expect(libpak.IsStaticStack("io.buildpacks.stacks.jammy.static")).To(BeTrue()) }) + it("matches static noble stack", func() { + Expect(libpak.IsStaticStack("io.buildpacks.stacks.noble.static")).To(BeTrue()) + }) + it("does not match full stack", func() { - Expect(libpak.IsTinyStack("io.buildpacks.stacks.bionic")).To(BeFalse()) + Expect(libpak.IsTinyStack("io.buildpacks.stacks.jammy")).To(BeFalse()) }) }) context("shell", func() { - it("matches a full stack", func() { - Expect(libpak.IsShellPresentOnStack("io.buildpacks.stacks.bionic")).To(BeTrue()) + it("matches a full jammy stack", func() { + Expect(libpak.IsShellPresentOnStack("io.buildpacks.stacks.jammy")).To(BeTrue()) + }) + + it("matches a full noble stack", func() { + Expect(libpak.IsShellPresentOnStack("io.buildpacks.stacks.noble")).To(BeTrue()) }) it("does not match static jammy stack", func() {