github.com/openshift/installer@v1.4.17/pkg/destroy/quota/quota.go (about) 1 package quota 2 3 import ( 4 "encoding/json" 5 "os" 6 "path/filepath" 7 8 "github.com/pkg/errors" 9 "github.com/sirupsen/logrus" 10 11 "github.com/openshift/installer/pkg/types" 12 ) 13 14 const ( 15 quotaFileName = "quota.json" 16 ) 17 18 // WriteQuota writes the cluster quota footprint into the asset directory. 19 func WriteQuota(dir string, quota *types.ClusterQuota) error { 20 path := filepath.Join(dir, quotaFileName) 21 logrus.Infof("Writing quota footprint to %s", path) 22 23 raw, err := json.Marshal(quota) 24 if err != nil { 25 return errors.Wrap(err, "failed to marshal quota") 26 } 27 if err := os.WriteFile(path, raw, 0o777); err != nil { //nolint:gosec // no sensitive info 28 return errors.Wrap(err, "failed to write quota") 29 } 30 return nil 31 }