Skip to content
Closed
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
20 changes: 20 additions & 0 deletions pkg/cli/admin/release/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ import (
imagemanifest "github.com/openshift/oc/pkg/cli/image/manifest"
)

const profileAnnotationPrefix = "include.release.openshift.io/"

func NewNewOptions(streams genericclioptions.IOStreams) *NewOptions {
return &NewOptions{
IOStreams: streams,
Expand Down Expand Up @@ -737,6 +739,24 @@ func (o *NewOptions) Run() error {
if s, ok := m["apiVersion"].(string); !ok || s == "" {
return fmt.Errorf("%s: manifests must contain Kubernetes API objects with 'kind' and 'apiVersion' set: %s", filename, s)
}
metadata, ok := m["metadata"].(map[string]interface{})
if !ok || metadata == nil {
return fmt.Errorf("%s: missing metadata; manifests must set at least one profile annotation", filename)
}
annotations, ok := metadata["annotations"].(map[string]interface{})
if !ok || annotations == nil {
return fmt.Errorf("%s: missing annotations; manifests must set at least one profile annotation", filename)
}
hasProfileAnnotation := false
for key := range annotations {
if strings.HasPrefix(key, profileAnnotationPrefix) {
hasProfileAnnotation = true
break
}
}
if !hasProfileAnnotation {
return fmt.Errorf("%s: missing profile annotation; manifests must set at least one profile annotation", filename)
}
break
}
return nil
Expand Down