IsVersioned returns a version if the file data sent can be unmarshaled into a stub and matches a known version in the VersionList
(data []byte)
| 101 | // can be unmarshaled into a stub and matches a known |
| 102 | // version in the VersionList |
| 103 | func (instance *Instance) IsVersioned(data []byte) ([]*Output, error) { |
| 104 | var outputs []*Output |
| 105 | stubs, err := containsStub(data) |
| 106 | if err != nil { |
| 107 | return nil, err |
| 108 | } |
| 109 | if len(stubs) > 0 { |
| 110 | for _, stub := range stubs { |
| 111 | var output Output |
| 112 | version := instance.checkVersion(stub) |
| 113 | if version != nil { |
| 114 | output.Name = stub.Metadata.Name |
| 115 | output.Namespace = stub.Metadata.Namespace |
| 116 | output.APIVersion = version |
| 117 | } else { |
| 118 | continue |
| 119 | } |
| 120 | outputs = append(outputs, &output) |
| 121 | } |
| 122 | return outputs, nil |
| 123 | } |
| 124 | return nil, nil |
| 125 | } |
| 126 | |
| 127 | // containsStub checks to see if a []byte has a stub in it |
| 128 | func containsStub(data []byte) ([]*Stub, error) { |