in hack/operatorhub/internal/operatorhub/operatorhub.go [390:466]
func buildRenderParams(conf *flags.Config, packageIndex int, extracts *yamlExtracts, imageDigest string) (*RenderParams, error) {
for _, c := range conf.CRDs {
if crd, ok := extracts.crds[c.Name]; ok {
crd.DisplayName = c.DisplayName
crd.Description = c.Description
}
}
crdList := make([]*CRD, 0, len(extracts.crds))
var missing []string
for _, crd := range extracts.crds {
if strings.TrimSpace(crd.Description) == "" || strings.TrimSpace(crd.DisplayName) == "" {
missing = append(missing, crd.Name)
}
crdList = append(crdList, crd)
}
if len(missing) > 0 {
return nil, fmt.Errorf("config file does not contain descriptions for some CRDs: %+v", missing)
}
sort.Slice(crdList, func(i, j int) bool {
return crdList[i].Name <= crdList[j].Name
})
var webhookDefinitionList []WebhookDefinition
for _, webhook := range extracts.operatorWebhooks {
webhookDefinitionList = append(webhookDefinitionList, validatingWebhookConfigurationToWebhookDefinition(webhook)...)
}
webhooks, err := gyaml.Marshal(webhookDefinitionList)
if err != nil {
return nil, fmt.Errorf("while marshaling operator webhook rules: %w", err)
}
versionParts := strings.Split(conf.NewVersion, ".")
if len(versionParts) < 2 {
return nil, fmt.Errorf("newVersion in config file appears to be invalid [%s]", conf.NewVersion)
}
rbac, err := gyaml.Marshal(extracts.operatorRBAC)
if err != nil {
return nil, fmt.Errorf("while marshaling operator RBAC rules: %w", err)
}
var additionalArgs []string
if conf.Packages[packageIndex].UbiOnly {
additionalArgs = append(additionalArgs, "--ubi-only")
}
additionalArgs = append(additionalArgs, "--distribution-channel="+conf.Packages[packageIndex].DistributionChannel)
tag := ":" + conf.NewVersion
if conf.Packages[packageIndex].DigestPinning {
tag = "@" + imageDigest
}
return &RenderParams{
NewVersion: conf.NewVersion,
ShortVersion: strings.Join(versionParts[:2], "."),
PrevVersion: conf.PrevVersion,
StackVersion: conf.StackVersion,
OperatorRepo: conf.Packages[packageIndex].OperatorRepo,
AdditionalArgs: additionalArgs,
CRDList: crdList,
OperatorWebhooks: string(webhooks),
OperatorRBAC: string(rbac),
PackageName: conf.Packages[packageIndex].PackageName,
Tag: tag,
UbiOnly: conf.Packages[packageIndex].UbiOnly,
MinSupportedOpenShiftVersion: conf.Packages[packageIndex].MinSupportedOpenShiftVersion,
}, nil
}