Giter Site home page Giter Site logo

paketo-buildpacks / image-labels Goto Github PK

View Code? Open in Web Editor NEW
10.0 7.0 8.0 327 KB

A Cloud Native Buildpack that enables configuration of labels on the created image

License: Apache License 2.0

Go 98.57% Shell 1.43%
cnb image-labels all-applications utilities

image-labels's Introduction

gcr.io/paketo-buildpacks/image-labels

The Paketo Buildpack for Image Labels is a Cloud Native Buildpack that enables configuration of labels on the created image.

This buildpack allows for the configuration of both OCI-specified labels with short environment variable names, as well as arbitrary labels using a space-delimited syntax in a single environment variable.

Behavior

This buildpack will participate if any of the following conditions are met

  • $BP_IMAGE_LABELS is set
  • $BP_OCI_AUTHORS is set
  • $BP_OCI_CREATED is set
  • $BP_OCI_DESCRIPTION is set
  • $BP_OCI_DOCUMENTATION is set
  • $BP_OCI_LICENSES is set
  • $BP_OCI_REF_NAME is set
  • $BP_OCI_REVISION is set
  • $BP_OCI_SOURCE is set
  • $BP_OCI_TITLE is set
  • $BP_OCI_URL is set
  • $BP_OCI_VENDOR is set
  • $BP_OCI_VERSION is set

The buildpack will do the following:

  • If $BP_IMAGE_LABELS is set, it will split the value first along , then along =, respecting quotes and set each of the pairs as image labels
  • If $BP_OCI_AUTHORS is set, it will set the value as the org.opencontainers.image.authors image label
  • If $BP_OCI_CREATED is set, it will set the value as the org.opencontainers.image.created image label
  • If $BP_OCI_DESCRIPTION is set, it will set the value as the org.opencontainers.image.description image lable
  • If $BP_OCI_DOCUMENTATION is set, it will set the value as the org.opencontainers.image.documentation image label
  • If $BP_OCI_LICENSES is set, it will set the value as the org.opencontainers.image.licenses image label
  • If $BP_OCI_REF_NAME is set, it will set the value as the org.opencontainers.image.ref.name image label
  • If $BP_OCI_REVISION is set, it will set the value as the org.opencontainers.image.revision image label
  • If $BP_OCI_SOURCE is set, it will set the value as the org.opencontainers.image.source image label
  • If $BP_OCI_TITLE is set, it will set the value as the org.opencontainers.image.title image label
  • If $BP_OCI_URL is set, it will set the value as the org.opencontainers.image.url image label
  • If $BP_OCI_VENDOR is set, it will set the value as the org.opencontainers.image.vendor image label
  • If $BP_OCI_VERSION is set, it will set the value as the org.opencontainers.image.version image label

Configuration

Environment Variable Description
$BP_IMAGE_LABELS A collection of space-delimited key-value pairs (e.g. alpha=bravo charlie="delta echo") to be set as image labels. Values containing spaces can be quoted.
$BP_OCI_AUTHORS The value for the org.opencontainers.image.authors image label
$BP_OCI_CREATED The value for the org.opencontainers.image.created image label
$BP_OCI_DESCRIPTION The value for the org.opencontainers.image.description image label
$BP_OCI_DOCUMENTATION The value for the org.opencontainers.image.documentation image label
$BP_OCI_LICENSES The value for the org.opencontainers.image.licenses image label
$BP_OCI_REF_NAME The value for the org.opencontainers.image.ref.name image label
$BP_OCI_REVISION The value for the org.opencontainers.image.revision image label
$BP_OCI_SOURCE The value for the org.opencontainers.image.source image label
$BP_OCI_TITLE The value for the org.opencontainers.image.title image label
$BP_OCI_URL The value for the org.opencontainers.image.url image label
$BP_OCI_VENDOR The value for the org.opencontainers.image.vendor image label
$BP_OCI_VERSION The value for the org.opencontainers.image.version image label

License

This buildpack is released under version 2.0 of the Apache License.

image-labels's People

Contributors

adamzr avatar anthonydahanne avatar dependabot[bot] avatar dmikusa avatar ekcasey avatar foresteckhardt avatar nebhale avatar paketo-bot avatar pivotal-david-osullivan avatar sophiewigmore avatar thitch97 avatar tomkuipers avatar twoseat avatar zer0keefie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

image-labels's Issues

Unexpected characters must be quoted in BP_IMAGE_LABELS

What happened?

The presence of certain characters in $BP_IMAGE_LABELS causes the build to fail unless they are quoted. This is due to the use of shellword.Parse to split space delimited labels: https://github.com/paketo-buildpacks/image-labels/blob/d436a7740635aecfb2db08d14a8ec89fced40c35/labels/build.go#L499

This is unexpected by the value is space delimeted as requested. However it can be worked around by quoting the value.

Because of the workaround this is probably low priority. Resolution would likely require writing custom logic to parse space delimited labels, respecting quotes, unless we wanted to change the input format or (better yet) make arbitrary custom labels a feature of the CNB lifecycle.

  • What were you attempting to do?
pack build samples/jar --env 'BP_IMAGE_LABELS=some-label=(example)value'

This is unexpected by the value is space delimited as requested. However it can be worked around by quoting the value.

pack build samples/jar --env 'BP_IMAGE_LABELS=some-label="(example)value"' --builder paketobuildpacks/builder:base
  • What did you expect to happen?

A label with key some-label and value (example)value to be applied.

  • What was the actual behavior? Please provide log output, if possible.
Paketo Image Labels Buildpack 2.0.6-16-g3e0991d
  unable to parse some-label=(example)value
  invalid command line string
ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 145

Build Configuration

  • What platform (pack, kpack, tekton buildpacks plugin, etc.) are you
    using? Please include a version.

pack version
0.16.0+git-e0f6c50.build-1898


* What buildpacks are you using? Please include versions.

Paketo Image Labels Buildpack 2.0.7


* What builder are you using?
`paketobuildpacks/builder:base`

* Can you provide a sample app or relevant configuration (`buildpack.yml`,
  `nginx.conf`, etc.)?
 https://github.com/paketo-buildpacks/samples/tree/main/java/jar

## Checklist
<!-- Please confirm the following -->
* [x] I have included log output.
* [x] The log output includes an error message.
* [x] I have included steps for reproduction.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.