gobindata_util.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. Copyright 2016 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package framework
  14. //go:generate ../../../hack/update-bindata.sh
  15. // See https://github.com/kubernetes/kubernetes/issues/23987
  16. import "k8s.io/kubernetes/test/e2e/generated"
  17. /*
  18. ReadOrDie reads a file from gobindata.
  19. Relies heavily on the successful generation of build artifacts as per the go:generate directives above.
  20. */
  21. func ReadOrDie(filePath string) []byte {
  22. fileBytes, err := generated.Asset(filePath)
  23. if err != nil {
  24. gobindata_msg := "An error occured, possibly gobindata doesn't know about the file you're opening. For questions on maintaining gobindata, contact the sig-testing group."
  25. Logf("Available gobindata files: %v ", generated.AssetNames())
  26. Failf("Failed opening %v , with error %v. %v.", filePath, err, gobindata_msg)
  27. }
  28. return fileBytes
  29. }