forked from LaconicNetwork/kompose
Removed unused functions
Fixes #534 by removing functions askForConfirmation in app.go, TransformData and RandStringBytes in utils.go
This commit is contained in:
parent
a24084d2a6
commit
3a086b4f2f
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
@ -306,19 +305,3 @@ func getTransformer(opt kobject.ConvertOptions) transformer.Transformer {
|
|||||||
}
|
}
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
func askForConfirmation() bool {
|
|
||||||
var response string
|
|
||||||
_, err := fmt.Scanln(&response)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
if response == "yes" {
|
|
||||||
return true
|
|
||||||
} else if response == "no" {
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
fmt.Println("Please type yes or no and then press enter:")
|
|
||||||
return askForConfirmation()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -17,37 +17,21 @@ limitations under the License.
|
|||||||
package transformer
|
package transformer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/ghodss/yaml"
|
|
||||||
"github.com/kubernetes-incubator/kompose/pkg/kobject"
|
"github.com/kubernetes-incubator/kompose/pkg/kobject"
|
||||||
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
|
||||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const letterBytes = "abcdefghijklmnopqrstuvwxyz0123456789"
|
|
||||||
const Selector = "io.kompose.service"
|
const Selector = "io.kompose.service"
|
||||||
|
|
||||||
// RandStringBytes generates randomly n-character string
|
|
||||||
func RandStringBytes(n int) string {
|
|
||||||
b := make([]byte, n)
|
|
||||||
for i := range b {
|
|
||||||
b[i] = letterBytes[rand.Intn(len(letterBytes))]
|
|
||||||
}
|
|
||||||
return string(b)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateOutFile creates the file to write to if --out is specified
|
// CreateOutFile creates the file to write to if --out is specified
|
||||||
func CreateOutFile(out string) (*os.File, error) {
|
func CreateOutFile(out string) (*os.File, error) {
|
||||||
var f *os.File
|
var f *os.File
|
||||||
@ -130,28 +114,6 @@ func ConfigAnnotations(service kobject.ServiceConfig) map[string]string {
|
|||||||
return annotations
|
return annotations
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransformData transforms data to json/yaml
|
|
||||||
func TransformData(obj runtime.Object, GenerateJSON bool) ([]byte, error) {
|
|
||||||
// Convert to versioned object
|
|
||||||
objectVersion := obj.GetObjectKind().GroupVersionKind()
|
|
||||||
version := unversioned.GroupVersion{Group: objectVersion.Group, Version: objectVersion.Version}
|
|
||||||
versionedObj, err := api.Scheme.ConvertToVersion(obj, version)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert data to json / yaml
|
|
||||||
data, err := yaml.Marshal(versionedObj)
|
|
||||||
if GenerateJSON == true {
|
|
||||||
data, err = json.MarshalIndent(versionedObj, "", " ")
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
log.Debugf("%s\n", data)
|
|
||||||
return data, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print either prints to stdout or to file/s
|
// Print either prints to stdout or to file/s
|
||||||
func Print(name, path string, trailing string, data []byte, toStdout, generateJSON bool, f *os.File) (string, error) {
|
func Print(name, path string, trailing string, data []byte, toStdout, generateJSON bool, f *os.File) (string, error) {
|
||||||
file := ""
|
file := ""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user