-
Notifications
You must be signed in to change notification settings - Fork 220
NE-1269: Replace bindata using embed #905
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| /ingress-operator | ||
| /pkg/manifests/manifests | ||
|
|
||
| tmp/ | ||
| _output/ | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package manifests | |
|
|
||
| import ( | ||
| "bytes" | ||
| "embed" | ||
| "encoding/base64" | ||
| "fmt" | ||
| "io" | ||
|
|
@@ -74,10 +75,45 @@ const ( | |
| // ClusterIngressConfigName is the name of the cluster Ingress Config | ||
| ClusterIngressConfigName = "cluster" | ||
|
|
||
| NamespaceManifest = "manifests/00-namespace.yaml" | ||
| // NamespaceManifest is the asset for the operator namespace manifest. | ||
| // This manifest is usually installed by CVO, but it is also used by the | ||
| // "ingress-operator render" command to write out manifests that are | ||
| // required in order to customize ingress at installation time, before | ||
| // CVO installs the manifests. | ||
| NamespaceManifest = "manifests/00-namespace.yaml" | ||
| // CustomResourceDefinitionManifest is the asset for the | ||
| // ingresscontrollers CRD. This manifest is usually installed by CVO, | ||
| // but it is also used by the "ingress-operator render" command to write | ||
| // out manifests that are required in order to customize ingress at | ||
| // installation time, before CVO installs the manifests. | ||
| CustomResourceDefinitionManifest = "manifests/00-custom-resource-definition.yaml" | ||
| ) | ||
|
|
||
| // Copy needed files from the manifests/ directory. This is necessary in order | ||
| // to embed these files here because manifests/ is a top-level directory in the | ||
| // source tree, and go:embed does not allow paths containing "../". | ||
| // | ||
| //go:generate mkdir -p manifests | ||
| //go:generate cp ../../manifests/00-namespace.yaml manifests/ | ||
| //go:generate cp ../../manifests/00-custom-resource-definition.yaml manifests/ | ||
|
|
||
| //go:embed assets manifests | ||
| var content embed.FS | ||
|
|
||
| // MustAsset returns the bytes for the named asset. | ||
| func MustAsset(asset string) []byte { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this the https://pkg.go.dev/github.com/abice/go-enum/generator/assets#MustAsset in the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| b, err := content.ReadFile(asset) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| return b | ||
| } | ||
|
|
||
| // MustAssetString returns a string with the named asset. | ||
| func MustAssetString(asset string) string { | ||
| return string(MustAsset(asset)) | ||
| } | ||
|
|
||
| func MustAssetReader(asset string) io.Reader { | ||
| return bytes.NewReader(MustAsset(asset)) | ||
| } | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of questions. Why are these two files the only ones needed from the manifests/ directory? And why not permanently move them to assets/ instead of creating a temporary directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are the only two files that the
ingress-operator rendercommand uses:cluster-ingress-operator/cmd/ingress-operator/render.go
Lines 42 to 45 in e93984f
#309 added the
ingress-operator rendercommand for the installer to use in openshift/installer#2523 for configuring ingresscontrollers at installation time.Then they wouldn't be in the right place for CVO to read them. The manifests still need to be installed by CVO if the cluster admin doesn't configure them with the installer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a worthwhile comment to add so that somebody doesn't move things in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/openshift/cluster-ingress-operator/compare/62697d237725ec70f45138087875c3e644b901f1..3dafe96f29556f24a6cfdcd199b669681c83221b adds comments.