-
-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(clustertool): cut down on useless dependencies
- Loading branch information
1 parent
1edb8f9
commit 61a01f3
Showing
14 changed files
with
65 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,4 @@ embeded/linux* | |
embeded/darwin* | ||
embeded/windows* | ||
embeded/freebsd* | ||
.devcontainer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package helper | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
|
||
"sigs.k8s.io/yaml" | ||
) | ||
|
||
// Encoder is a custom encoder for YAML that writes to an io.Writer. | ||
type Encoder struct { | ||
writer io.Writer | ||
indent int | ||
} | ||
|
||
// NewEncoder creates a new Encoder that writes to the specified writer. | ||
func YamlNewEncoder(w io.Writer) *Encoder { | ||
return &Encoder{writer: w} | ||
} | ||
|
||
// SetIndent sets the number of spaces for indentation. | ||
func (e *Encoder) SetIndent(indent int) { | ||
e.indent = indent | ||
} | ||
|
||
// Encode encodes the value and writes it to the underlying writer with indentation. | ||
func (e *Encoder) Encode(v interface{}) error { | ||
data, err := yaml.Marshal(v) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// If indent is set, format the output accordingly | ||
if e.indent > 0 { | ||
var indentedData bytes.Buffer | ||
for _, line := range bytes.Split(data, []byte{'\n'}) { | ||
if len(line) > 0 { | ||
indentedData.Write(bytes.Repeat([]byte{' '}, e.indent)) | ||
} | ||
indentedData.Write(line) | ||
indentedData.WriteByte('\n') | ||
} | ||
data = indentedData.Bytes() | ||
} | ||
|
||
_, err = e.writer.Write(data) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters