Documentation
¶
Index ¶
- Constants
- type ReadWriter
- func (rw *ReadWriter) AppendModuleReference(rootSyncDir string, ownerName string, repoName string, reference string, ...) error
- func (rw *ReadWriter) LatestModuleDigest(rootSyncDir string, ownerName string, repoName string) (string, error)
- func (rw *ReadWriter) ReadGlobalState(reader io.ReadCloser) (_ *statev1alpha1.GlobalState, retErr error)
- func (rw *ReadWriter) ReadModStateFile(readCloser io.ReadCloser) (_ *statev1alpha1.ModuleState, retErr error)
- func (rw *ReadWriter) WriteGlobalState(writer io.WriteCloser, globalState *statev1alpha1.GlobalState) (retErr error)
- func (rw *ReadWriter) WriteModStateFile(writeCloser io.WriteCloser, moduleState *statev1alpha1.ModuleState) (retErr error)
Constants ¶
const GlobalStateFileName = "state.json"
const ModStateFileName = "state.json"
const SyncRoot = "modules/sync"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReadWriter ¶
type ReadWriter struct {
// contains filtered or unexported fields
}
func NewReadWriter ¶
func NewReadWriter() (*ReadWriter, error)
func (*ReadWriter) AppendModuleReference ¶
func (rw *ReadWriter) AppendModuleReference( rootSyncDir string, ownerName string, repoName string, reference string, digest string, ) error
AppendModuleReference appends a reference-digest pair at the end of the module state, and updates the module's latest reference in the global state. It assumes the structure of the sync dir is `root-sync-dir/owner-name/repo-name/state.json` for module state file, and `root-sync-dir/state.json` for global state file.
func (*ReadWriter) LatestModuleDigest ¶
func (rw *ReadWriter) LatestModuleDigest( rootSyncDir string, ownerName string, repoName string, ) (string, error)
LatestModuleDigest returns the digest of the last reference appended to the module state, or an empty string if the module has no state file yet or its state file has no references. It assumes the same sync dir structure as AppendModuleReference.
func (*ReadWriter) ReadGlobalState ¶
func (rw *ReadWriter) ReadGlobalState(reader io.ReadCloser) (_ *statev1alpha1.GlobalState, retErr error)
ReadGlobalState reads a JSON encoded GlobalState from the given reader before closing it.
func (*ReadWriter) ReadModStateFile ¶
func (rw *ReadWriter) ReadModStateFile(readCloser io.ReadCloser) (_ *statev1alpha1.ModuleState, retErr error)
ReadModStateFile reads a JSON encoded ModuleState from the given reader before closing it.
func (*ReadWriter) WriteGlobalState ¶
func (rw *ReadWriter) WriteGlobalState(writer io.WriteCloser, globalState *statev1alpha1.GlobalState) (retErr error)
WriteGlobalState takes a global state and writes it to the given writer before closing it.
func (*ReadWriter) WriteModStateFile ¶
func (rw *ReadWriter) WriteModStateFile(writeCloser io.WriteCloser, moduleState *statev1alpha1.ModuleState) (retErr error)
WriteModStateFile takes a module state and writes it to the given writer before closing it.