-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
registry+v1: support webhooks, add simple converter CLI
- Loading branch information
1 parent
e51c0c2
commit ae93540
Showing
18 changed files
with
2,519 additions
and
882 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/spf13/cobra" | ||
"helm.sh/helm/v3/pkg/chartutil" | ||
|
||
"github.com/operator-framework/operator-controller/internal/features" | ||
"github.com/operator-framework/operator-controller/internal/rukpak/convert" | ||
) | ||
|
||
func main() { | ||
if err := rootCmd().Execute(); err != nil { | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func rootCmd() *cobra.Command { | ||
var registryV1CertProviderName string | ||
cmd := &cobra.Command{ | ||
Use: "registryv1-to-helm <registry+v1-directory-path> [output-path]", | ||
Args: cobra.RangeArgs(1, 2), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
registryv1Path := args[0] | ||
|
||
saveDir := "." | ||
if len(args) == 2 { | ||
saveDir = args[1] | ||
} | ||
|
||
rv1, err := convert.LoadRegistryV1(cmd.Context(), os.DirFS(registryv1Path)) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "failed to load registry+v1 bundle: %v\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
rv1CertProvider, err := convert.CertProviderByName(registryV1CertProviderName) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "failed to load certificate provider: %v\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
chrt, err := rv1.ToHelmChart(convert.WithCertificateProvider(rv1CertProvider)) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "failed to convert registry v1 to helm chart: %v\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
if err := chartutil.SaveDir(chrt, saveDir); err != nil { | ||
fmt.Fprintf(os.Stderr, "failed to write helm chart to directory: %v\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
origChartDir := filepath.Join(saveDir, chrt.Metadata.Name) | ||
desiredChartDir := filepath.Join(saveDir, fmt.Sprintf("%s-%s", chrt.Metadata.Name, chrt.Metadata.Version)) | ||
if err := os.Rename(origChartDir, desiredChartDir); err != nil { | ||
fmt.Fprintf(os.Stderr, "failed to rename helm chart directory: %v\n", err) | ||
os.Exit(1) | ||
} | ||
cmd.Printf("Chart saved to %s\n", desiredChartDir) | ||
}, | ||
} | ||
features.InitializeFromCLIFlags(cmd.Flags()) | ||
if features.OperatorControllerFeatureGate.Enabled(features.RegistryV1WebhookSupport) { | ||
cmd.Flags().StringVar(®istryV1CertProviderName, "registry-v1-cert-provider", "", "a certificate provider to use to generate certificates for registry+v1-defined webhooks (if unset, registry+v1 bundles that define webhooks are unsupported)") | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: node-role.kubernetes.io/master | ||
operator: Exists | ||
nodeSelector: | ||
overrideKey1: overrideValue1 | ||
|
||
selector: | ||
overrideKey2: overrideValue2 | ||
|
||
tolerations: | ||
- effect: NoSchedule | ||
key: node-role.kubernetes.io/master2 | ||
|
||
volumes: | ||
- name: argocd-operator-token-5z5z2 | ||
emptyDir: {} | ||
|
||
env: | ||
- name: WATCH_NAMESPACE | ||
value: BAR | ||
|
||
envFrom: | ||
- configMapRef: | ||
name: my-configmap | ||
- secretRef: | ||
name: my-secret | ||
|
||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 100Mi | ||
|
||
volumeMounts: | ||
- name: tmp | ||
mountPath: override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.