-
Notifications
You must be signed in to change notification settings - Fork 74
[OCPCLOUD-1162] Implement render binary for use in installer #45
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
Merged
openshift-merge-robot
merged 8 commits into
openshift:master
from
Danil-Grigorev:implement-render
Jun 4, 2021
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
234a1e2
Implement render inital structure
dfbb9c5
Add infrastructure file path to arguments
cc18a84
Pass path to configMap with rendered images.json references to render
aa68952
Implement config composition for render command
988ee05
Implement rendering run for bootstrap manifests
c161640
Write rendered manifests to destination bootstrap dir
d7ddbf6
Ensure bootstrap dir is always present
1e0cc60
Revendor with cobra
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,96 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "flag" | ||
| "fmt" | ||
| "os" | ||
|
|
||
| "github.com/openshift/cluster-cloud-controller-manager-operator/pkg/render" | ||
| "github.com/spf13/cobra" | ||
| utilerrors "k8s.io/apimachinery/pkg/util/errors" | ||
|
|
||
| "k8s.io/klog/v2" | ||
| ) | ||
|
|
||
| var ( | ||
| renderCmd = &cobra.Command{ | ||
| Use: "run", | ||
| Short: "Starts Cluster Cloud Controller Manager in render mode", | ||
| Long: "", | ||
| RunE: runRenderCmd, | ||
| } | ||
|
|
||
| renderOpts struct { | ||
| destinationDir string | ||
| clusterInfrastructure string | ||
| imagesFile string | ||
| } | ||
| ) | ||
|
|
||
| func init() { | ||
| renderCmd.PersistentFlags().AddGoFlagSet(flag.CommandLine) | ||
| renderCmd.PersistentFlags().StringVar(&renderOpts.destinationDir, "dest-dir", "", "The destination dir where CCCMO writes the generated static pods for CCM.") | ||
| renderCmd.PersistentFlags().StringVar(&renderOpts.clusterInfrastructure, "cluster-infrastructure-file", "", "Input path for the cluster infrastructure file.") | ||
| renderCmd.PersistentFlags().StringVar(&renderOpts.imagesFile, "images-file", "", "Input path for the images config map file.") | ||
| renderCmd.MarkFlagRequired("dest-dir") | ||
| renderCmd.MarkFlagRequired("cluster-infrastructure-file") | ||
| renderCmd.MarkFlagRequired("images-file") | ||
| } | ||
|
|
||
| func runRenderCmd(cmd *cobra.Command, args []string) error { | ||
| flag.Set("logtostderr", "true") | ||
| flag.Parse() | ||
|
|
||
| if err := validate( | ||
| renderOpts.destinationDir, | ||
| renderOpts.clusterInfrastructure, | ||
| renderOpts.imagesFile); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| if err := render.New(renderOpts.clusterInfrastructure, renderOpts.imagesFile).Run(renderOpts.destinationDir); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // validate verifies all file and dirs exist | ||
| func validate(destinationDir, clusterInfrastructure, imagesFile string) error { | ||
| errs := []error{} | ||
| if err := isFile(clusterInfrastructure); err != nil { | ||
| klog.Errorf("error reading --cluster-infrastructure-file=%q: %s", clusterInfrastructure, err) | ||
| errs = append(errs, fmt.Errorf("error reading --cluster-infrastructure-file: %s", err)) | ||
| } | ||
| if err := isFile(imagesFile); err != nil { | ||
| klog.Errorf("error reading --images-file=%q: %s", imagesFile, err) | ||
| errs = append(errs, fmt.Errorf("error reading --images-file: %s", err)) | ||
| } | ||
|
|
||
| if len(errs) > 0 { | ||
| return utilerrors.NewAggregate(errs) | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func isFile(path string) error { | ||
| st, err := os.Stat(path) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if !st.Mode().IsRegular() { | ||
| return fmt.Errorf("%q is not a regular file", path) | ||
| } | ||
| if st.Size() <= 0 { | ||
| return fmt.Errorf("%q is empty", path) | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func main() { | ||
| if err := renderCmd.Execute(); err != nil { | ||
| klog.Exitf("Error executing render: %v", err) | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.