From 685880c8a803feaf3511ec8ccb448077ac39260c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=B3=20=D0=91=D0=BE=D1=80=D0=BE=D0=B4?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Sat, 21 Feb 2026 20:07:37 +0200 Subject: [PATCH] working commit --- Makefile.am | 23 ++-- Makefile.in | 141 ++++++++--------------- app/config/config.go | 27 ----- app/server/server.go | 11 +- cmd/mstorectl/command/main.go | 84 -------------- cmd/mstorectl/main.go | 3 +- cmd/mstored/main.go | 30 +---- configure | 4 +- docs/main.go | 49 ++++++++ mans/Makefile.am | 8 ++ mans/Makefile.in | 14 ++- mans/docs | 168 ---------------------------- mans/makeman-mstorectl.go | 2 +- mans/makeman-mstored.go | 48 ++++++++ mans/mstorectl-accounts-create.1 | 2 +- mans/mstorectl-accounts-delete.1 | 2 +- mans/mstorectl-accounts-get.1 | 2 +- mans/mstorectl-accounts-list.1 | 2 +- mans/mstorectl-accounts-update.1 | 2 +- mans/mstorectl-accounts.1 | 2 +- mans/mstorectl-collections-delete.1 | 2 +- mans/mstorectl-collections-list.1 | 2 +- mans/mstorectl-collections.1 | 2 +- mans/mstorectl-files-delete.1 | 2 +- mans/mstorectl-files-export.1 | 2 +- mans/mstorectl-files-get.1 | 2 +- mans/mstorectl-files-import.1 | 2 +- mans/mstorectl-files-info.1 | 2 +- mans/mstorectl-files-list.1 | 2 +- mans/mstorectl-files-put.1 | 2 +- mans/mstorectl-files.1 | 2 +- mans/mstorectl-grants-create.1 | 2 +- mans/mstorectl-grants-delete.1 | 2 +- mans/mstorectl-grants-get.1 | 2 +- mans/mstorectl-grants-list.1 | 2 +- mans/mstorectl-grants-update.1 | 2 +- mans/mstorectl-grants.1 | 2 +- mans/mstorectl-images-delete.1 | 2 +- mans/mstorectl-images-info.1 | 2 +- mans/mstorectl-images-pull.1 | 2 +- mans/mstorectl-images-push.1 | 2 +- mans/mstorectl-images.1 | 2 +- mans/mstorectl.1 | 6 +- mans/mstored.8 | 31 +++++ pkg/auxtool/fileex.go | 3 + 45 files changed, 255 insertions(+), 453 deletions(-) delete mode 100644 cmd/mstorectl/command/main.go create mode 100644 docs/main.go delete mode 100644 mans/docs create mode 100644 mans/makeman-mstored.go create mode 100644 mans/mstored.8 diff --git a/Makefile.am b/Makefile.am index 9b39e91..6fd3d66 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,27 +7,32 @@ bin_PROGRAMS = mstorectl sbin_PROGRAMS = mstored mstorectl_SOURCES = \ - cmd/mstorectl/filecmd.go \ - cmd/mstorectl/imagecmd.go \ - cmd/mstorectl/accountcmd.go \ - cmd/mstorectl/grantcmd.go \ cmd/mstorectl/main.go -mstored_SOURCES = \ - cmd/mstored/main.go +EXTRA_mstorectl_SOURCES = \ + cmd/mstorectl/command/accountcmd.go \ + cmd/mstorectl/command/grantcmd.go \ + cmd/mstorectl/command/imagecmd.go \ + cmd/mstorectl/command/util.go \ + cmd/mstorectl/command/filecmd.go -mstorectl$(EXEEXT): $(mstorectl_SOURCES) $(EXTRA_mstored_SOURCES) + +mstored_SOURCES = cmd/mstored/main.go +EXTRA_mstored_SOURCES = cmd/mstored/starter/starter.go + + +mstorectl$(EXEEXT): $(mstorectl_SOURCES) $(EXTRA_mstorectl_SOURCES) $(EXTRA_mstored_SOURCES) env CGO_ENABLED=0 $(GO) build $(GOFLAGS) -o mstorectl$(EXEEXT) $(mstorectl_SOURCES) mstored$(EXEEXT): $(mstored_SOURCES) $(EXTRA_mstored_SOURCES) env CGO_ENABLED=1 $(GO) build $(GOFLAGS) -o mstored$(EXEEXT) $(mstored_SOURCES) run: $(mstored_SOURCES) - cd cmd/mstored && env CGO_ENABLED=1 $(GO) run . -daemon=false + cd cmd/mstored && env CGO_ENABLED=1 $(GO) run . CWD=$(shell pwd) -EXTRA_mstored_SOURCES = \ +EXTRA_mstored_SOURCES += \ app/config/config.go \ app/config/variant.go \ \ diff --git a/Makefile.in b/Makefile.in index 50f31db..4d46933 100644 --- a/Makefile.in +++ b/Makefile.in @@ -141,10 +141,10 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(mstorectl_SOURCES) $(mstored_SOURCES) \ - $(EXTRA_mstored_SOURCES) -DIST_SOURCES = $(mstorectl_SOURCES) $(mstored_SOURCES) \ - $(EXTRA_mstored_SOURCES) +SOURCES = $(mstorectl_SOURCES) $(EXTRA_mstorectl_SOURCES) \ + $(mstored_SOURCES) $(EXTRA_mstored_SOURCES) +DIST_SOURCES = $(mstorectl_SOURCES) $(EXTRA_mstorectl_SOURCES) \ + $(mstored_SOURCES) $(EXTRA_mstored_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ @@ -350,99 +350,54 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign no-dependencies no-installinfo -SUBDIRS = docs +SUBDIRS = mans GOFLAGS = -v mstorectl_SOURCES = \ - cmd/mstorectl/filecmd.go \ - cmd/mstorectl/imagecmd.go \ - cmd/mstorectl/accountcmd.go \ - cmd/mstorectl/grantcmd.go \ cmd/mstorectl/main.go -mstored_SOURCES = \ - cmd/mstored/main.go +EXTRA_mstorectl_SOURCES = \ + cmd/mstorectl/command/accountcmd.go \ + cmd/mstorectl/command/grantcmd.go \ + cmd/mstorectl/command/imagecmd.go \ + cmd/mstorectl/command/util.go \ + cmd/mstorectl/command/filecmd.go +mstored_SOURCES = cmd/mstored/main.go +EXTRA_mstored_SOURCES = cmd/mstored/starter/starter.go \ + app/config/config.go app/config/variant.go \ + pkg/descr/account.go pkg/descr/blob.go pkg/descr/file.go \ + pkg/descr/grant.go pkg/descr/manifest.go pkg/descr/server.go \ + app/handler/aaafunc.go app/handler/account.go \ + app/handler/blob.go app/handler/file.go app/handler/grant.go \ + app/handler/handler.go app/handler/manifest.go \ + app/handler/notfound.go app/handler/response.go \ + app/handler/service.go app/handler/version.go \ + app/logger/logger.go app/maindb/account.go app/maindb/blob.go \ + app/maindb/file.go app/maindb/grant.go app/maindb/init.go \ + app/maindb/maindb.go app/maindb/manifest.go \ + app/maindb/scheme.go app/operator/account.go \ + app/operator/blob.go app/operator/file.go \ + app/operator/grant.go app/operator/imgaux.go \ + app/operator/manifest.go app/operator/ociaux.go \ + app/operator/operator.go app/operator/service.go \ + app/operator/version.go app/router/bindobj.go \ + app/router/context.go app/router/corsmw.go \ + app/router/loggingmw.go app/router/pathc.go \ + app/router/recovermw.go app/router/router.go \ + app/server/server.go app/service/service.go \ + app/storage/storage.go pkg/auxhttp/basic.go \ + pkg/auxhttp/crange.go pkg/auxoci/ociaux.go \ + pkg/auxpwd/passwd.go pkg/auxtool/cleandir.go \ + pkg/auxtool/fileex.go pkg/auxtool/randstr.go \ + pkg/auxtool/tmpfile.go pkg/auxtool/unixnow.go \ + pkg/auxutar/utar.go pkg/auxuuid/uuid.go \ + pkg/auxx509/x509cert.go pkg/client/account.go \ + pkg/client/client.go pkg/client/fileaux.go pkg/client/file.go \ + pkg/client/grant.go pkg/client/httpcall.go \ + pkg/client/imageaux.go pkg/client/imagedelete.go \ + pkg/client/imageinfo.go pkg/client/imagepull.go \ + pkg/client/imagepush.go pkg/client/service.go CWD = $(shell pwd) -EXTRA_mstored_SOURCES = \ - app/config/config.go \ - app/config/variant.go \ - \ - pkg/descr/account.go \ - pkg/descr/blob.go \ - pkg/descr/file.go \ - pkg/descr/grant.go \ - pkg/descr/manifest.go \ - pkg/descr/server.go \ - \ - app/handler/aaafunc.go \ - app/handler/account.go \ - app/handler/blob.go \ - app/handler/file.go \ - app/handler/grant.go \ - app/handler/handler.go \ - app/handler/manifest.go \ - app/handler/notfound.go \ - app/handler/response.go \ - app/handler/service.go \ - app/handler/version.go \ - app/logger/logger.go \ - \ - app/maindb/account.go \ - app/maindb/blob.go \ - app/maindb/file.go \ - app/maindb/grant.go \ - app/maindb/init.go \ - app/maindb/maindb.go \ - app/maindb/manifest.go \ - app/maindb/scheme.go \ - \ - app/operator/account.go \ - app/operator/blob.go \ - app/operator/file.go \ - app/operator/grant.go \ - app/operator/imgaux.go \ - app/operator/manifest.go \ - app/operator/ociaux.go \ - app/operator/operator.go \ - app/operator/service.go \ - app/operator/version.go \ - app/router/bindobj.go \ - app/router/context.go \ - app/router/corsmw.go \ - app/router/loggingmw.go \ - app/router/pathc.go \ - app/router/recovermw.go \ - app/router/router.go \ - \ - app/server/server.go \ - app/service/service.go \ - app/storage/storage.go \ - \ - pkg/auxhttp/basic.go \ - pkg/auxhttp/crange.go \ - pkg/auxoci/ociaux.go \ - pkg/auxpwd/passwd.go \ - pkg/auxtool/cleandir.go \ - pkg/auxtool/fileex.go \ - pkg/auxtool/randstr.go \ - pkg/auxtool/tmpfile.go \ - pkg/auxtool/unixnow.go \ - pkg/auxutar/utar.go \ - pkg/auxuuid/uuid.go \ - pkg/auxx509/x509cert.go \ - pkg/client/account.go \ - pkg/client/client.go \ - pkg/client/fileaux.go \ - pkg/client/file.go \ - pkg/client/grant.go \ - pkg/client/httpcall.go \ - pkg/client/imageaux.go \ - pkg/client/imagedelete.go \ - pkg/client/imageinfo.go \ - pkg/client/imagepull.go \ - pkg/client/imagepush.go \ - pkg/client/service.go - EXTRA_DIST = vendor/ \ \ Containerfile \ @@ -1100,14 +1055,14 @@ uninstall-am: uninstall-binPROGRAMS uninstall-sbinPROGRAMS .PRECIOUS: Makefile -mstorectl$(EXEEXT): $(mstorectl_SOURCES) $(EXTRA_mstored_SOURCES) +mstorectl$(EXEEXT): $(mstorectl_SOURCES) $(EXTRA_mstorectl_SOURCES) $(EXTRA_mstored_SOURCES) env CGO_ENABLED=0 $(GO) build $(GOFLAGS) -o mstorectl$(EXEEXT) $(mstorectl_SOURCES) mstored$(EXEEXT): $(mstored_SOURCES) $(EXTRA_mstored_SOURCES) env CGO_ENABLED=1 $(GO) build $(GOFLAGS) -o mstored$(EXEEXT) $(mstored_SOURCES) run: $(mstored_SOURCES) - cd cmd/mstored && env CGO_ENABLED=1 $(GO) run . -daemon=false + cd cmd/mstored && env CGO_ENABLED=1 $(GO) run . format: @dirs=$$($(FIND) $(CWD)/app $(CWD)/cmd $(CWD)/pkg $(CWD)/test \ diff --git a/app/config/config.go b/app/config/config.go index 4847673..f243fc8 100644 --- a/app/config/config.go +++ b/app/config/config.go @@ -10,7 +10,6 @@ package config import ( - "flag" "fmt" "io/ioutil" "os" @@ -103,32 +102,6 @@ func (conf *Config) ReadConfigfile() error { return err } -func (conf *Config) ReadOptions() error { - var err error - exename := filepath.Base(os.Args[0]) - - // TODO: make local scope of flags - - flagSet := flag.NewFlagSet(exename, flag.ExitOnError) - flagSet.Int64Var(&conf.Service.Port, "port", conf.Service.Port, "listen port") - flagSet.BoolVar(&conf.AsDaemon, "daemon", conf.AsDaemon, "run as daemon") - - help := func() { - fmt.Println("") - fmt.Printf("Usage: %s [option]\n", exename) - fmt.Println("") - fmt.Println("Options:") - flagSet.PrintDefaults() - fmt.Println("") - } - flagSet.Usage = help - args := flag.Args() - if len(args) > 1 { - flagSet.Parse(args) - } - return err -} - func (conf *Config) ReadX509Cert() error { var err error if conf.Certpath != "" && conf.Keypath != "" { diff --git a/app/server/server.go b/app/server/server.go index decdb8a..2e4766a 100644 --- a/app/server/server.go +++ b/app/server/server.go @@ -78,6 +78,10 @@ func (srv *Server) SetPort(port int64) { srv.conf.Service.Port = port } +func (srv *Server) SetAsDaemon(asDaemon bool) { + srv.conf.AsDaemon = asDaemon +} + func (srv *Server) Configure() error { var err error srv.logg.Infof("Configuration server") @@ -94,11 +98,6 @@ func (srv *Server) Configure() error { if err != nil { return err } - - err = srv.conf.ReadOptions() - if err != nil { - return err - } return err } @@ -159,7 +158,7 @@ func (srv *Server) Build() error { // Creating datadir datadir := srv.conf.Datadir - if !auxtool.DirExists(datadir) { + if !auxtool.DirExists(datadir) { // TODO: check access to dir srv.logg.Infof("Creating data directory %s ", datadir) err = os.MkdirAll(datadir, 0750) if err != nil { diff --git a/cmd/mstorectl/command/main.go b/cmd/mstorectl/command/main.go deleted file mode 100644 index acbe27b..0000000 --- a/cmd/mstorectl/command/main.go +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2026 Oleg Borodin - * - * This work is published and licensed under a Creative Commons - * Attribution-NonCommercial-NoDerivatives 4.0 International License. - * - * Distribution of this work is permitted, but commercial use and - * modifications are strictly prohibited. - */ -package command - -import ( - "fmt" - "os" - "path/filepath" - - "github.com/spf13/cobra" - yaml "go.yaml.in/yaml/v4" -) - -type Util struct { - FileUtil - ImageUtil - AccountUtil - GrantUtil - rootCmd *cobra.Command -} - -func NewUtil() *Util { - return &Util{} -} - -func (util *Util) GetRooCmd() *cobra.Command { - return util.rootCmd -} - -func (util *Util) Build() error { - var err error - execName := filepath.Base(os.Args[0]) - rootCmd := &cobra.Command{ - Use: execName, - Short: "\nA brief description the command", - //SilenceUsage: true, - } - rootCmd.CompletionOptions.DisableDefaultCmd = true - - rootCmd.AddCommand(util.CreateFileCmds()) - rootCmd.AddCommand(util.CreateCollectionCmds()) - rootCmd.AddCommand(util.CreateImageCmds()) - rootCmd.AddCommand(util.CreateAccountCmds()) - rootCmd.AddCommand(util.CreateGrantCmds()) - - util.rootCmd = rootCmd - - return err -} - -func (util *Util) Exec(args []string) error { - var err error - util.rootCmd.SetArgs(args) - err = util.rootCmd.Execute() - return err -} - -func (util *Util) Hello(cmd *cobra.Command, args []string) { - fmt.Println("hello, world!") -} - -func printResponse(res any, err error) { - type Response struct { - Error bool `yaml:"error" yaml:"error"` - Message string `yaml:"message,omitempty" yaml:"message,omitempty"` - Result any `yaml:"result,omitempty" yaml:"result,omitempty"` - } - resp := Response{} - if err != nil { - resp.Error = true - resp.Message = err.Error() - } else { - resp.Result = res - } - respBytes, _ := yaml.Marshal(resp) - fmt.Printf("---\n%s\n", string(respBytes)) -} diff --git a/cmd/mstorectl/main.go b/cmd/mstorectl/main.go index 9779ef7..0b0ad1a 100644 --- a/cmd/mstorectl/main.go +++ b/cmd/mstorectl/main.go @@ -12,7 +12,7 @@ package main import ( "os" - "mstore/cmd/mstorectl/command" + "mstore/cmd/mstorectl/command" ) func main() { @@ -27,4 +27,3 @@ func main() { os.Exit(1) } } - diff --git a/cmd/mstored/main.go b/cmd/mstored/main.go index aa40cc2..ac7b74a 100644 --- a/cmd/mstored/main.go +++ b/cmd/mstored/main.go @@ -13,37 +13,13 @@ import ( "os" "mstore/app/logger" - "mstore/app/server" + "mstore/cmd/mstored/starter" ) -func run() error { - var err error - srv, err := server.NewServer() - if err != nil { - return err - } - err = srv.Configure() - if err != nil { - return err - } - err = srv.Daemonize() - if err != nil { - return err - } - err = srv.Build() - if err != nil { - return err - } - err = srv.Run() - if err != nil { - return err - } - return err -} - func main() { log := logger.NewLoggerWithSubject("main") - err := run() + sta := starter.NewStarter() + err := sta.Exec() if err != nil { log.Errorf("%v", err) os.Exit(1) diff --git a/configure b/configure index 24a26dd..afa7ba3 100755 --- a/configure +++ b/configure @@ -3865,7 +3865,7 @@ printf "%s\n" "$as_me: srv_datadir set as ${SRV_DATADIR}" >&6;} -ac_config_files="$ac_config_files Makefile app/config/variant.go initrc/mstored.service initrc/mstored chart/Chart.yaml chart/values.yaml debian/control debian/changelog docs/Makefile" +ac_config_files="$ac_config_files Makefile app/config/variant.go initrc/mstored.service initrc/mstored chart/Chart.yaml chart/values.yaml debian/control debian/changelog mans/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -4624,7 +4624,7 @@ do "chart/values.yaml") CONFIG_FILES="$CONFIG_FILES chart/values.yaml" ;; "debian/control") CONFIG_FILES="$CONFIG_FILES debian/control" ;; "debian/changelog") CONFIG_FILES="$CONFIG_FILES debian/changelog" ;; - "docs/Makefile") CONFIG_FILES="$CONFIG_FILES docs/Makefile" ;; + "mans/Makefile") CONFIG_FILES="$CONFIG_FILES mans/Makefile" ;; *) as_fn_error $? "invalid argument: '$ac_config_target'" "$LINENO" 5;; esac diff --git a/docs/main.go b/docs/main.go new file mode 100644 index 0000000..86dfe07 --- /dev/null +++ b/docs/main.go @@ -0,0 +1,49 @@ +package main + +import ( + "fmt" + "time" + "os" + + "github.com/spf13/cobra/doc" + + "mstore/cmd/mstorectl/command" +) + +func run() error { + var err error + os.Args[0] = "mstorectl" + util := command.NewUtil() + err = util.Build() + if err != nil { + return err + } + + cmd := util.GetRooCmd() + now := time.Now() + header := &doc.GenManHeader{ + Title: "mstore", + Section: "1", + Manual: "User commands", + Source: "mstorectl command", + Date: &now, + } + opts := doc.GenManTreeOptions { + Header: header, + Path: "./", + CommandSeparator: "-", + } + err = doc.GenManTreeFromOpts(cmd, opts) + if err != nil { + return err + } + return err +} + +func main() { + err := run() + if err != nil { + fmt.Printf("err: %v\n", err) + } + +} diff --git a/mans/Makefile.am b/mans/Makefile.am index 5242189..981111b 100644 --- a/mans/Makefile.am +++ b/mans/Makefile.am @@ -31,3 +31,11 @@ dist_man1_MANS = \ mstorectl-images-info.1 \ mstorectl-images-pull.1 \ mstorectl-images-push.1 + +man: + $(GO) run makeman-mstorectl.go + $(GO) run makeman-mstored.go + +EXTRA_DIST = \ + makeman-mstorectl.go \ + makeman-mstored.go diff --git a/mans/Makefile.in b/mans/Makefile.in index 1255615..3efb220 100644 --- a/mans/Makefile.in +++ b/mans/Makefile.in @@ -89,7 +89,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -subdir = docs +subdir = mans ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -294,6 +294,10 @@ dist_man1_MANS = \ mstorectl-images-pull.1 \ mstorectl-images-push.1 +EXTRA_DIST = \ + makeman-mstorectl.go \ + makeman-mstored.go + all: all-am .SUFFIXES: @@ -306,9 +310,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign docs/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign mans/Makefile'; \ $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign docs/Makefile + $(AUTOMAKE) --foreign mans/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -533,6 +537,10 @@ uninstall-man: uninstall-man1 .PRECIOUS: Makefile +man: + $(GO) run makeman-mstorectl.go + $(GO) run makeman-mstored.go + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/mans/docs b/mans/docs deleted file mode 100644 index e529a01..0000000 --- a/mans/docs +++ /dev/null @@ -1,168 +0,0 @@ -package main - -//********************************************************************************************** -//github.com/google/go-containerregistry - -type IndexManifest struct { - SchemaVersion int64 `json:"schemaVersion"` - MediaType types.MediaType `json:"mediaType,omitempty"` - Manifests []Descriptor `json:"manifests"` - Annotations map[string]string `json:"annotations,omitempty"` - Subject *Descriptor `json:"subject,omitempty"` -} - -type Manifest struct { - SchemaVersion int64 `json:"schemaVersion"` - MediaType types.MediaType `json:"mediaType,omitempty"` - Config Descriptor `json:"config"` - Layers []Descriptor `json:"layers"` - Annotations map[string]string `json:"annotations,omitempty"` - Subject *Descriptor `json:"subject,omitempty"` -} - -type Descriptor struct { - MediaType types.MediaType `json:"mediaType"` - Size int64 `json:"size"` - Digest Hash `json:"digest"` - Data []byte `json:"data,omitempty"` - URLs []string `json:"urls,omitempty"` - Annotations map[string]string `json:"annotations,omitempty"` - Platform *Platform `json:"platform,omitempty"` - ArtifactType string `json:"artifactType,omitempty"` -} - -//********************************************************************************************** -//github.com/opencontainers/image-spec/specs-go/v1 - -// application/vnd.oci.image.index.v1+json -type Index struct { - specs.Versioned - // MediaType specifies the type of this document data structure e.g. `application/vnd.oci.image.index.v1+json` - MediaType string `json:"mediaType,omitempty"` - // ArtifactType specifies the IANA media type of artifact when the manifest is used for an artifact. - ArtifactType string `json:"artifactType,omitempty"` - // Manifests references platform specific manifests. - Manifests []Descriptor `json:"manifests"` - // Subject is an optional link from the image manifest to another manifest forming an association between the image manifest and the other manifest. - Subject *Descriptor `json:"subject,omitempty"` - // Annotations contains arbitrary metadata for the image index. - Annotations map[string]string `json:"annotations,omitempty"` -} - -// application/vnd.oci.image.manifest.v1+json -type Manifest struct { - specs.Versioned - // MediaType specifies the type of this document data structure e.g. `application/vnd.oci.image.manifest.v1+json` - MediaType string `json:"mediaType,omitempty"` - // ArtifactType specifies the IANA media type of artifact when the manifest is used for an artifact. - ArtifactType string `json:"artifactType,omitempty"` - // Config references a configuration object for a container, by digest. - // The referenced configuration object is a JSON blob that the runtime uses to set up the container. - Config Descriptor `json:"config"` - // Layers is an indexed list of layers referenced by the manifest. - Layers []Descriptor `json:"layers"` - // Subject is an optional link from the image manifest to another manifest forming an association between the image manifest and the other manifest. - Subject *Descriptor `json:"subject,omitempty"` - // Annotations contains arbitrary metadata for the image manifest. - Annotations map[string]string `json:"annotations,omitempty"` -} - -type Descriptor struct { - // MediaType is the media type of the object this schema refers to. - MediaType string `json:"mediaType"` - // Digest is the digest of the targeted content. - Digest digest.Digest `json:"digest"` - // Size specifies the size in bytes of the blob. - Size int64 `json:"size"` - // URLs specifies a list of URLs from which this object MAY be downloaded - URLs []string `json:"urls,omitempty"` - // Annotations contains arbitrary metadata relating to the targeted content. - Annotations map[string]string `json:"annotations,omitempty"` - // Data is an embedding of the targeted content. This is encoded as a base64 - // string when marshalled to JSON (automatically, by encoding/json). If - // present, Data can be used directly to avoid fetching the targeted content. - Data []byte `json:"data,omitempty"` - // Platform describes the platform which the image in the manifest runs on. - // This should only be used when referring to a manifest. - Platform *Platform `json:"platform,omitempty"` - // ArtifactType is the IANA media type of this artifact. - ArtifactType string `json:"artifactType,omitempty"` -} - -// ********************************************************************************************* -// https://github.com/opencontainers/image-spec/blob/v1.1.1/media-types.md - -// application/vnd.oci.image.config.v1+json -// application/vnd.oci.image.config.v1+json -// application/vnd.docker.container.image.v1+json - -type Image struct { - // Platform describes the platform which the image in the manifest runs on. - Platform - // Created is the combined date and time at which the image was created, formatted as defined by RFC 3339, section 5.6. - Created *time.Time `json:"created,omitempty"` - // Author defines the name and/or email address of the person or entity which created and is responsible for maintaining the image. - Author string `json:"author,omitempty"` - // Config defines the execution parameters which should be used as a base when running a container using the image. - Config ImageConfig `json:"config,omitempty"` - // RootFS references the layer content addresses used by the image. - RootFS RootFS `json:"rootfs"` - // History describes the history of each layer. - History []History `json:"history,omitempty"` -} - -type RootFS struct { - // Type is the type of the rootfs. - Type string `json:"type"` - // DiffIDs is an array of layer content hashes (DiffIDs), in order from bottom-most to top-most. - DiffIDs []digest.Digest `json:"diff_ids"` -} - -type ImageConfig struct { - // User defines the username or UID which the process in the container should run as. - User string `json:"User,omitempty"` - // ExposedPorts a set of ports to expose from a container running this image. - ExposedPorts map[string]struct{} `json:"ExposedPorts,omitempty"` - // Env is a list of environment variables to be used in a container. - Env []string `json:"Env,omitempty"` - // Entrypoint defines a list of arguments to use as the command to execute when the container starts. - Entrypoint []string `json:"Entrypoint,omitempty"` - // Cmd defines the default arguments to the entrypoint of the container. - Cmd []string `json:"Cmd,omitempty"` - // Volumes is a set of directories describing where the process is likely write data specific to a container instance. - Volumes map[string]struct{} `json:"Volumes,omitempty"` - // WorkingDir sets the current working directory of the entrypoint process in the container. - WorkingDir string `json:"WorkingDir,omitempty"` - // Labels contains arbitrary metadata for the container. - Labels map[string]string `json:"Labels,omitempty"` - // StopSignal contains the system call signal that will be sent to the container to exit. - StopSignal string `json:"StopSignal,omitempty"` - // ArgsEscaped - // - // Deprecated: This field is present only for legacy compatibility with - // Docker and should not be used by new image builders. It is used by Docker - // for Windows images to indicate that the `Entrypoint` or `Cmd` or both, - // contains only a single element array, that is a pre-escaped, and combined - // into a single string `CommandLine`. If `true` the value in `Entrypoint` or - // `Cmd` should be used as-is to avoid double escaping. - // https://github.com/opencontainers/image-spec/pull/892 - ArgsEscaped bool `json:"ArgsEscaped,omitempty"` -} - -// ********************************************************************************************** -type Platform struct { - // Architecture field specifies the CPU architecture, for example - // `amd64` or `ppc64le`. - Architecture string `json:"architecture"` - // OS specifies the operating system, for example `linux` or `windows`. - OS string `json:"os"` - // OSVersion is an optional field specifying the operating system - // version, for example on Windows `10.0.14393.1066`. - OSVersion string `json:"os.version,omitempty"` - // OSFeatures is an optional field specifying an array of strings, - // each listing a required OS feature (for example on Windows `win32k`). - OSFeatures []string `json:"os.features,omitempty"` - // Variant is an optional field specifying a variant of the CPU, for - // example `v7` to specify ARMv7 when architecture is `arm`. - Variant string `json:"variant,omitempty"` -} diff --git a/mans/makeman-mstorectl.go b/mans/makeman-mstorectl.go index a7b50a8..abf7a29 100644 --- a/mans/makeman-mstorectl.go +++ b/mans/makeman-mstorectl.go @@ -22,7 +22,7 @@ func run() error { cmd := util.GetRooCmd() now := time.Now() header := &doc.GenManHeader{ - Title: "mstore", + Title: "mstorectl", Section: "1", Manual: "User commands", Source: "mstorectl command", diff --git a/mans/makeman-mstored.go b/mans/makeman-mstored.go new file mode 100644 index 0000000..8baf7f0 --- /dev/null +++ b/mans/makeman-mstored.go @@ -0,0 +1,48 @@ +package main + +import ( + "fmt" + "os" + "time" + + "github.com/spf13/cobra/doc" + + "mstore/cmd/mstored/starter" +) + +func run() error { + var err error + os.Args[0] = "mstored" + util := starter.NewStarter() + if err != nil { + return err + } + + cmd := util.GetCmd() + now := time.Now() + header := &doc.GenManHeader{ + Title: "mstored", + Section: "8", + Manual: "User commands", + Source: "mstored command", + Date: &now, + } + opts := doc.GenManTreeOptions{ + Header: header, + Path: "./", + CommandSeparator: "-", + } + err = doc.GenManTreeFromOpts(cmd, opts) + if err != nil { + return err + } + return err +} + +func main() { + err := run() + if err != nil { + fmt.Printf("err: %v\n", err) + } + +} diff --git a/mans/mstorectl-accounts-create.1 b/mans/mstorectl-accounts-create.1 index ff261c8..ea4e119 100644 --- a/mans/mstorectl-accounts-create.1 +++ b/mans/mstorectl-accounts-create.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-accounts-create - Create user account diff --git a/mans/mstorectl-accounts-delete.1 b/mans/mstorectl-accounts-delete.1 index 5cd1ea2..a73e6dc 100644 --- a/mans/mstorectl-accounts-delete.1 +++ b/mans/mstorectl-accounts-delete.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-accounts-delete - Delete account diff --git a/mans/mstorectl-accounts-get.1 b/mans/mstorectl-accounts-get.1 index 7223905..dc1ea39 100644 --- a/mans/mstorectl-accounts-get.1 +++ b/mans/mstorectl-accounts-get.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-accounts-get - Get account info diff --git a/mans/mstorectl-accounts-list.1 b/mans/mstorectl-accounts-list.1 index b10aaff..b6b1015 100644 --- a/mans/mstorectl-accounts-list.1 +++ b/mans/mstorectl-accounts-list.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-accounts-list - list accounts diff --git a/mans/mstorectl-accounts-update.1 b/mans/mstorectl-accounts-update.1 index 4eca6bd..117c70b 100644 --- a/mans/mstorectl-accounts-update.1 +++ b/mans/mstorectl-accounts-update.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-accounts-update - Update account parameters diff --git a/mans/mstorectl-accounts.1 b/mans/mstorectl-accounts.1 index 0c81464..2e22a14 100644 --- a/mans/mstorectl-accounts.1 +++ b/mans/mstorectl-accounts.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-accounts - Account operations diff --git a/mans/mstorectl-collections-delete.1 b/mans/mstorectl-collections-delete.1 index af4bc6e..30aeede 100644 --- a/mans/mstorectl-collections-delete.1 +++ b/mans/mstorectl-collections-delete.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-collections-delete - Delete all files in collection diff --git a/mans/mstorectl-collections-list.1 b/mans/mstorectl-collections-list.1 index 3e792a2..97d6c23 100644 --- a/mans/mstorectl-collections-list.1 +++ b/mans/mstorectl-collections-list.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-collections-list - List collections in storage diff --git a/mans/mstorectl-collections.1 b/mans/mstorectl-collections.1 index 38417e1..2544d47 100644 --- a/mans/mstorectl-collections.1 +++ b/mans/mstorectl-collections.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-collections - Colletion operations diff --git a/mans/mstorectl-files-delete.1 b/mans/mstorectl-files-delete.1 index 0408668..4f164b4 100644 --- a/mans/mstorectl-files-delete.1 +++ b/mans/mstorectl-files-delete.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-files-delete - Delete file in storage diff --git a/mans/mstorectl-files-export.1 b/mans/mstorectl-files-export.1 index b90a322..03f419b 100644 --- a/mans/mstorectl-files-export.1 +++ b/mans/mstorectl-files-export.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-files-export - Download file tree to storage as is diff --git a/mans/mstorectl-files-get.1 b/mans/mstorectl-files-get.1 index fe889a9..6bddf88 100644 --- a/mans/mstorectl-files-get.1 +++ b/mans/mstorectl-files-get.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-files-get - Get file from storage diff --git a/mans/mstorectl-files-import.1 b/mans/mstorectl-files-import.1 index 128bcf6..e44d1c4 100644 --- a/mans/mstorectl-files-import.1 +++ b/mans/mstorectl-files-import.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-files-import - Send file tree to storage as is diff --git a/mans/mstorectl-files-info.1 b/mans/mstorectl-files-info.1 index b49d0e3..4ffaaab 100644 --- a/mans/mstorectl-files-info.1 +++ b/mans/mstorectl-files-info.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-files-info - Show file information diff --git a/mans/mstorectl-files-list.1 b/mans/mstorectl-files-list.1 index 78c9c73..6b18ab1 100644 --- a/mans/mstorectl-files-list.1 +++ b/mans/mstorectl-files-list.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-files-list - List files in storage diff --git a/mans/mstorectl-files-put.1 b/mans/mstorectl-files-put.1 index 73f7325..042dba7 100644 --- a/mans/mstorectl-files-put.1 +++ b/mans/mstorectl-files-put.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-files-put - Put file to storage diff --git a/mans/mstorectl-files.1 b/mans/mstorectl-files.1 index bc39b9e..de8bd69 100644 --- a/mans/mstorectl-files.1 +++ b/mans/mstorectl-files.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-files - File operations diff --git a/mans/mstorectl-grants-create.1 b/mans/mstorectl-grants-create.1 index 9a558e9..fb82808 100644 --- a/mans/mstorectl-grants-create.1 +++ b/mans/mstorectl-grants-create.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-grants-create - Create grant diff --git a/mans/mstorectl-grants-delete.1 b/mans/mstorectl-grants-delete.1 index 39e4872..3b1fb0c 100644 --- a/mans/mstorectl-grants-delete.1 +++ b/mans/mstorectl-grants-delete.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-grants-delete - Delete grant diff --git a/mans/mstorectl-grants-get.1 b/mans/mstorectl-grants-get.1 index c4f863c..6d50dec 100644 --- a/mans/mstorectl-grants-get.1 +++ b/mans/mstorectl-grants-get.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-grants-get - Get detail grant info diff --git a/mans/mstorectl-grants-list.1 b/mans/mstorectl-grants-list.1 index 5474cae..195c1d3 100644 --- a/mans/mstorectl-grants-list.1 +++ b/mans/mstorectl-grants-list.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-grants-list - list user grants diff --git a/mans/mstorectl-grants-update.1 b/mans/mstorectl-grants-update.1 index 481b100..821c165 100644 --- a/mans/mstorectl-grants-update.1 +++ b/mans/mstorectl-grants-update.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-grants-update - Update grant parameters diff --git a/mans/mstorectl-grants.1 b/mans/mstorectl-grants.1 index c622c3d..5ea38ae 100644 --- a/mans/mstorectl-grants.1 +++ b/mans/mstorectl-grants.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-grants - Grant operations diff --git a/mans/mstorectl-images-delete.1 b/mans/mstorectl-images-delete.1 index e249a0c..a994564 100644 --- a/mans/mstorectl-images-delete.1 +++ b/mans/mstorectl-images-delete.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-images-delete - Delete container image from registry diff --git a/mans/mstorectl-images-info.1 b/mans/mstorectl-images-info.1 index efe07de..311fc7b 100644 --- a/mans/mstorectl-images-info.1 +++ b/mans/mstorectl-images-info.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-images-info - Show container image info diff --git a/mans/mstorectl-images-pull.1 b/mans/mstorectl-images-pull.1 index 5ad206f..c541036 100644 --- a/mans/mstorectl-images-pull.1 +++ b/mans/mstorectl-images-pull.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-images-pull - Pull container image from registry into local file diff --git a/mans/mstorectl-images-push.1 b/mans/mstorectl-images-push.1 index 043d3dc..691ad3b 100644 --- a/mans/mstorectl-images-push.1 +++ b/mans/mstorectl-images-push.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-images-push - Push container image from local tar file into registry diff --git a/mans/mstorectl-images.1 b/mans/mstorectl-images.1 index 54b0571..b8164e1 100644 --- a/mans/mstorectl-images.1 +++ b/mans/mstorectl-images.1 @@ -1,5 +1,5 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl-images - Image operations diff --git a/mans/mstorectl.1 b/mans/mstorectl.1 index decb89d..71ef845 100644 --- a/mans/mstorectl.1 +++ b/mans/mstorectl.1 @@ -1,9 +1,9 @@ .nh -.TH "mstore" "1" "Feb 2026" "mstorectl command" "User commands" +.TH "mstorectl" "1" "Feb 2026" "mstorectl command" "User commands" .SH NAME mstorectl - -A brief description the command +Operation with artefacts: files, images, service accounts and grants .SH SYNOPSIS @@ -11,7 +11,7 @@ A brief description the command .SH DESCRIPTION -A brief description the command +Operation with artefacts: files, images, service accounts and grants .SH OPTIONS diff --git a/mans/mstored.8 b/mans/mstored.8 new file mode 100644 index 0000000..1f3779e --- /dev/null +++ b/mans/mstored.8 @@ -0,0 +1,31 @@ +.nh +.TH "mstored" "8" "Feb 2026" "mstored command" "User commands" + +.SH NAME +mstored - +Artifact storage service + + +.SH SYNOPSIS +\fBmstored [flags]\fP + + +.SH DESCRIPTION +Artifact storage service + + +.SH OPTIONS +\fB-D\fP, \fB--asDaemon\fP[=true] + Run service as daemon + +.PP +\fB-h\fP, \fB--help\fP[=false] + help for mstored + +.PP +\fB-P\fP, \fB--port\fP=1025 + Service port + + +.SH HISTORY +21-Feb-2026 Auto generated by spf13/cobra diff --git a/pkg/auxtool/fileex.go b/pkg/auxtool/fileex.go index 4123c78..b6d1815 100644 --- a/pkg/auxtool/fileex.go +++ b/pkg/auxtool/fileex.go @@ -24,5 +24,8 @@ func DirExists(name string) bool { return false } } + if fileStat == nil { + return false + } return fileStat.IsDir() }