-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds commands to print default plugin definitions
We have the `sonobuoy gen` command which prints a lot of different types of resources and `sonobuoy gen plugin` which prints custom plugin definitions. Sometimes it would be helpful to be able to print the default e2e or sytemdlogs plugin definitions so that they can be tweaked. Added two commands `sonobuoy gen plugins e2e` and `sonobuoy gen plugins systemd-logs` which does this. Minor tweak to code organization to improve code reuse. Fixes #991 Signed-off-by: John Schnake <[email protected]>
- Loading branch information
1 parent
be8e183
commit e41ac6e
Showing
5 changed files
with
109 additions
and
15 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
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
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,37 @@ | ||
/* | ||
Copyright 2019 Sonobuoy contributors 2019 | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package manifest | ||
|
||
import ( | ||
"github.com/vmware-tanzu/sonobuoy/pkg/plugin/driver" | ||
"github.com/vmware-tanzu/sonobuoy/pkg/plugin/manifest" | ||
|
||
"github.com/pkg/errors" | ||
kuberuntime "k8s.io/apimachinery/pkg/runtime" | ||
) | ||
|
||
// ToYAML will serialize the manifest and add the default podspec (based on the appropriate drive) | ||
// if not already set in the manifest. | ||
func ToYAML(m *manifest.Manifest, showDefaultPodSpec bool) ([]byte, error) { | ||
if showDefaultPodSpec && m.PodSpec == nil { | ||
m.PodSpec = &manifest.PodSpec{ | ||
PodSpec: driver.DefaultPodSpec(m.SonobuoyConfig.Driver), | ||
} | ||
} | ||
yaml, err := kuberuntime.Encode(manifest.Encoder, m) | ||
return yaml, errors.Wrapf(err, "serializing plugin %v as YAML", m.SonobuoyConfig.PluginName) | ||
} |