mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-08 16:57:29 +00:00
Add export resource helper function
This commit is contained in:
parent
67e0acd044
commit
4136eb1444
5 changed files with 14 additions and 6 deletions
|
|
@ -17,6 +17,8 @@ limitations under the License.
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
|
@ -35,3 +37,9 @@ func init() {
|
|||
|
||||
rootCmd.AddCommand(exportCmd)
|
||||
}
|
||||
|
||||
func resourceToString(data []byte) string {
|
||||
data = bytes.Replace(data, []byte("creationTimestamp: null\n"), []byte(""), 1)
|
||||
data = bytes.Replace(data, []byte("status: {}\n"), []byte(""), 1)
|
||||
return string(data)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,6 +115,6 @@ func exportHelmRelease(helmRelease helmv2.HelmRelease) error {
|
|||
}
|
||||
|
||||
fmt.Println("---")
|
||||
fmt.Println(string(data))
|
||||
fmt.Println(resourceToString(data))
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,6 +115,6 @@ func exportKs(kustomization kustomizev1.Kustomization) error {
|
|||
}
|
||||
|
||||
fmt.Println("---")
|
||||
fmt.Println(string(data))
|
||||
fmt.Println(resourceToString(data))
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ func exportGit(source sourcev1.GitRepository) error {
|
|||
}
|
||||
|
||||
fmt.Println("---")
|
||||
fmt.Println(string(data))
|
||||
fmt.Println(resourceToString(data))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ func exportGitCredentials(ctx context.Context, kubeClient client.Client, source
|
|||
}
|
||||
|
||||
fmt.Println("---")
|
||||
fmt.Println(string(data))
|
||||
fmt.Println(resourceToString(data))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ func exportHelmRepository(source sourcev1.HelmRepository) error {
|
|||
}
|
||||
|
||||
fmt.Println("---")
|
||||
fmt.Println(string(data))
|
||||
fmt.Println(resourceToString(data))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ func exportHelmCredentials(ctx context.Context, kubeClient client.Client, source
|
|||
}
|
||||
|
||||
fmt.Println("---")
|
||||
fmt.Println(string(data))
|
||||
fmt.Println(resourceToString(data))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue