RunManifest is the same as Run(*RunConfig) execpt that the []byte given should represent the output from `sonobuoy gen`, a series of YAML resources separated by `---`. This method will disregard the RunConfig.GenConfig and instead use the given []byte as the manifest.
(cfg *RunConfig, manifest []byte)
| 60 | // separated by `---`. This method will disregard the RunConfig.GenConfig |
| 61 | // and instead use the given []byte as the manifest. |
| 62 | func (c *SonobuoyClient) RunManifest(cfg *RunConfig, manifest []byte) error { |
| 63 | buf := bytes.NewBuffer(manifest) |
| 64 | d := yaml.NewYAMLOrJSONDecoder(buf, bufferSize) |
| 65 | |
| 66 | for { |
| 67 | ext := runtime.RawExtension{} |
| 68 | if err := d.Decode(&ext); err != nil { |
| 69 | if err == io.EOF { |
| 70 | break |
| 71 | } |
| 72 | return errors.Wrap(err, "couldn't decode template") |
| 73 | } |
| 74 | |
| 75 | // Skip over empty or partial objects |
| 76 | ext.Raw = bytes.TrimSpace(ext.Raw) |
| 77 | if len(ext.Raw) == 0 || bytes.Equal(ext.Raw, []byte("null")) { |
| 78 | continue |
| 79 | } |
| 80 | |
| 81 | obj := &unstructured.Unstructured{} |
| 82 | if err := runtime.DecodeInto(scheme.Codecs.UniversalDecoder(), ext.Raw, obj); err != nil { |
| 83 | return errors.Wrap(err, "couldn't decode template") |
| 84 | } |
| 85 | name, err := c.dynamicClient.Name(obj) |
| 86 | if err != nil { |
| 87 | return errors.Wrap(err, "could not get object name") |
| 88 | } |
| 89 | namespace, err := c.dynamicClient.Namespace(obj) |
| 90 | if err != nil { |
| 91 | return errors.Wrap(err, "could not get object namespace") |
| 92 | } |
| 93 | |
| 94 | // err is used to determine output for user; but first extract resource |
| 95 | _, err = c.dynamicClient.CreateObject(obj) |
| 96 | resource, err2 := c.dynamicClient.ResourceVersion(obj) |
| 97 | if err2 != nil { |
| 98 | return errors.Wrap(err, "could not get resource of object") |
| 99 | } |
| 100 | if err := handleCreateError(name, namespace, resource, err); err != nil { |
| 101 | return errors.Wrap(err, "failed to create object") |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | if cfg.Wait > time.Duration(0) { |
| 106 | return c.WaitForRun(cfg) |
| 107 | } |
| 108 | |
| 109 | return nil |
| 110 | } |
| 111 | |
| 112 | // WaitForRun handles the 'wait' from sonobuoy run --wait. "Attaches" to the sonobuoy run |
| 113 | // in the configured namespace and then returns when completed. Returns errors encountered |
no test coverage detected