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

Add chainguard global option, specify wolfi-baselayout where missing #413

Merged
merged 1 commit into from
Mar 31, 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
5 changes: 5 additions & 0 deletions globals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ options:
- bash
- busybox
- git
chainguard:
contents:
packages:
add:
- chainguard-baselayout
2 changes: 0 additions & 2 deletions images/static/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
| **OCI Reference** | `cgr.dev/chainguard/static` |
| **Variants/Tags** | ![](https://storage.googleapis.com/chainguard-images-build-outputs/summary/static.svg) |

*[Contact Chainguard](https://www.chainguard.dev/chainguard-images) for enterprise support, SLAs, and access to older tags.*

---
<!--monopod:end-->

Expand Down
1 change: 1 addition & 0 deletions images/static/image.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
excludeContact: true
versions:
- apko:
config: configs/latest.apko.yaml
Expand Down
17 changes: 12 additions & 5 deletions monopod/pkg/commands/readme.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ func (i *readmeImpl) check() error {
}

imageToStatusMap := map[string]string{}
imageToExcludeContactMap := map[string]bool{}
imageToReferenceMap := map[string]string{}
imageToVariantMap := map[string][]string{}
for _, image := range allImages {
imageToStatusMap[image.ImageName] = image.ImageStatus
imageToExcludeContactMap[image.ImageName] = image.ExcludeContact
imageToReferenceMap[image.ImageName] = fmt.Sprintf("`%s`", image.ApkoBaseTag)
variant := fmt.Sprintf("`%s`", image.ApkoTargetTag)
if image.ApkoAdditionalTags != "" {
Expand All @@ -106,8 +108,10 @@ func (i *readmeImpl) check() error {
readmeInsert := fmt.Sprintf("# %s\n| | |\n| - | - |\n", k)
readmeInsert += fmt.Sprintf("| **Status** | %s |\n", imageToStatusMap[k])
readmeInsert += fmt.Sprintf("| **OCI Reference** | %s |\n", imageToReferenceMap[k])
readmeInsert += fmt.Sprintf("| **Variants/Tags** | %s |\n", fmt.Sprintf("![](%s/%s.svg)", i.SummaryRootUrl, k))
readmeInsert += "\n*[Contact Chainguard](https://www.chainguard.dev/chainguard-images) for enterprise support, SLAs, and access to older tags.*\n\n"
readmeInsert += fmt.Sprintf("| **Variants/Tags** | %s |\n\n", fmt.Sprintf("![](%s/%s.svg)", i.SummaryRootUrl, k))
if !imageToExcludeContactMap[k] {
readmeInsert += "*[Contact Chainguard](https://www.chainguard.dev/chainguard-images) for enterprise support, SLAs, and access to older tags.*\n\n"
}
readmeInsert += "---"

filename := path.Join(constants.ImagesDirName, k, "README.md")
Expand Down Expand Up @@ -157,10 +161,12 @@ func (i *readmeImpl) fixAllReadmes() error {

// Individual image README.md files
imageToStatusMap := map[string]string{}
imageToExcludeContactMap := map[string]bool{}
imageToReferenceMap := map[string]string{}
imageToVariantMap := map[string][]string{}
for _, image := range allImages {
imageToStatusMap[image.ImageName] = image.ImageStatus
imageToExcludeContactMap[image.ImageName] = image.ExcludeContact
imageToReferenceMap[image.ImageName] = fmt.Sprintf("`%s`", image.ApkoBaseTag)
variant := fmt.Sprintf("`%s`", image.ApkoTargetTag)
if image.ApkoAdditionalTags != "" {
Expand All @@ -184,11 +190,12 @@ func (i *readmeImpl) fixAllReadmes() error {
readmeInsert := fmt.Sprintf("# %s\n| | |\n| - | - |\n", k)
readmeInsert += fmt.Sprintf("| **Status** | %s |\n", imageToStatusMap[k])
readmeInsert += fmt.Sprintf("| **OCI Reference** | %s |\n", imageToReferenceMap[k])
readmeInsert += fmt.Sprintf("| **Variants/Tags** | %s |\n", fmt.Sprintf("![](%s/%s.svg)", i.SummaryRootUrl, k))
readmeInsert += "\n*[Contact Chainguard](https://www.chainguard.dev/chainguard-images) for enterprise support, SLAs, and access to older tags.*\n\n"
readmeInsert += fmt.Sprintf("| **Variants/Tags** | %s |\n\n", fmt.Sprintf("![](%s/%s.svg)", i.SummaryRootUrl, k))
if !imageToExcludeContactMap[k] {
readmeInsert += "*[Contact Chainguard](https://www.chainguard.dev/chainguard-images) for enterprise support, SLAs, and access to older tags.*\n\n"
}
readmeInsert += "---"
padded := fmt.Sprintf("%s\n%s\n%s\n", constants.ImageReadmeGenStartComment, readmeInsert, constants.ImageReadmeGenEndComment)

filename := path.Join(constants.ImagesDirName, k, "README.md")
existingContent, err := os.ReadFile(filename)
if err != nil {
Expand Down
19 changes: 14 additions & 5 deletions monopod/pkg/images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ type Image struct {
TestCommandExe string `json:"testCommandExe"`
TestCommandDir string `json:"testCommandDir"`
ExcludeTags string `json:"excludeTags"`
ExcludeContact bool `json:"-"`
}

type ImageManifest struct {
Ref string `yaml:"ref"`
Status string `yaml:"status"`
Variants []ImageManifestVariant `yaml:"versions"`
Ref string `yaml:"ref"`
Status string `yaml:"status"`
ExcludeContact bool `yaml:"excludeContact"`
Variants []ImageManifestVariant `yaml:"versions"`
}

type ImageManifestVariant struct {
Expand All @@ -51,6 +53,7 @@ type ImageManifestVariant struct {

type ImageManifestVariantApko struct {
Config string `yaml:"config"`
Options []string `yaml:"options"`
ExtractTagsFrom ImageManifestVariantApkoExtractTagsFrom `yaml:"extractTagsFrom"`
Tags []string `yaml:"tags"`
Subvariants []ImageManifestVariantApkoSubvariant `yaml:"subvariants"`
Expand Down Expand Up @@ -127,6 +130,7 @@ func ListAll(opts ...ListOption) ([]Image, error) {
if imageStatus == "" {
imageStatus = constants.DefaultImageStatus
}
imageExcludeContact := m.ExcludeContact
variants := []variantIterator{}
for _, variant := range m.Variants {
variants = append(variants, variantIterator{
Expand All @@ -146,11 +150,15 @@ func ListAll(opts ...ListOption) ([]Image, error) {
apkoTargetTag := strings.Replace(filepath.Base(apkoConfig), constants.ApkoYamlFileExtension, "", 1)
apkoAdditionalTags := strings.Join(variant.Apko.Tags, ",")
apkoTargetTagSuffix := ""
apkoBuildOptions := ""
apkoBuildOptions := strings.Join(iterator.Variant.Apko.Options, ",")
if subvariant.Suffix != "" {
apkoTargetTag = apkoTargetTag + subvariant.Suffix
apkoTargetTagSuffix = subvariant.Suffix
apkoBuildOptions = strings.Join(subvariant.Options, ",")
if apkoBuildOptions != "" {
apkoBuildOptions = strings.Join([]string{apkoBuildOptions, strings.Join(subvariant.Options, ",")}, ",")
} else {
apkoBuildOptions = strings.Join(subvariant.Options, ",")
}
}

// Ensure that we dont have duplicate entries for any image/variant combo
Expand Down Expand Up @@ -278,6 +286,7 @@ func ListAll(opts ...ListOption) ([]Image, error) {
TestCommandExe: testCommandExe,
TestCommandDir: testCommandDir,
ExcludeTags: strings.Join(variant.Apko.ExtractTagsFrom.Exclude, ","),
ExcludeContact: imageExcludeContact,
}
allImages = append(allImages, i)
}
Expand Down