Skip to content

Commit

Permalink
Update stacks
Browse files Browse the repository at this point in the history
- Remove bionic stack which is EOL
- Add noble stack
- Update tests

Signed-off-by: Daniel Mikusa <[email protected]>
  • Loading branch information
dmikusa committed Oct 21, 2024
1 parent 993c7bb commit 0c4a2c4
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 42 deletions.
38 changes: 18 additions & 20 deletions stack.go
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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"

Expand All @@ -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
}
71 changes: 49 additions & 22 deletions stack_test.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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())
Expand All @@ -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())
})
})

Expand All @@ -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() {
Expand Down

0 comments on commit 0c4a2c4

Please sign in to comment.