Exemple #1
0
 public static DockerComposeUpFlags SetOrClear(this DockerComposeUpFlags current, DockerComposeUpFlags value, bool add)
 {
     if (add)
     {
         return(current | value);
     }
     else
     {
         return(current & ~value);
     }
 }
Exemple #2
0
        public static void CheckConflicts(this DockerComposeUpFlags value)
        {
            var flagsFilter = DockerComposeUpFlags.AbortOnContainerExit | DockerComposeUpFlags.Detach;

            if ((value & flagsFilter) == flagsFilter)
            {
                throw new Exception("options --abort-on-container-exit and --detach can't be used together");
            }
            flagsFilter = DockerComposeUpFlags.AlwaysRecreateDeps | DockerComposeUpFlags.NoRecreate;
            if ((value & flagsFilter) == flagsFilter)
            {
                throw new Exception("options --always-recreate-deps and --no-recreate can't be used together");
            }
            flagsFilter = DockerComposeUpFlags.ForceRecreate | DockerComposeUpFlags.NoRecreate;
            if ((value & flagsFilter) == flagsFilter)
            {
                throw new Exception("options --force-recreate and --no-recreate can't be used together");
            }
            flagsFilter = DockerComposeUpFlags.NoRecreate | DockerComposeUpFlags.RenewAnonVolumes;
            if ((value & flagsFilter) == flagsFilter)
            {
                throw new Exception("options --no-recreate and --renew-anon-volumes can't be used together");
            }
        }
Exemple #3
0
 public static IEnumerable <string> OptionsToString(this DockerComposeUpFlags value, OptionPreference preferLongNames = OptionPreference.Short)
 {
     // generator : SingleTaskEnumsGenerator
     CheckConflicts(value);
     // -d, --detach: Detached mode: Run containers in the background, print new container names. Incompatible with --abort-on-container-exit.
     if ((value & DockerComposeUpFlags.Detach) != 0)
     {
         yield return(preferLongNames == OptionPreference.Long ? "--detach" : "-d");
     }
     // --no-color: Produce monochrome output.
     if ((value & DockerComposeUpFlags.NoColor) != 0)
     {
         yield return("--no-color");
     }
     // --quiet-pull: Pull without printing progress information
     if ((value & DockerComposeUpFlags.QuietPull) != 0)
     {
         yield return("--quiet-pull");
     }
     // --no-deps: Don't start linked services.
     if ((value & DockerComposeUpFlags.NoDeps) != 0)
     {
         yield return("--no-deps");
     }
     // --force-recreate: Recreate containers even if their configuration and image haven't changed.
     if ((value & DockerComposeUpFlags.ForceRecreate) != 0)
     {
         yield return("--force-recreate");
     }
     // --always-recreate-deps: Recreate dependent containers. Incompatible with --no-recreate.
     if ((value & DockerComposeUpFlags.AlwaysRecreateDeps) != 0)
     {
         yield return("--always-recreate-deps");
     }
     // --no-recreate: If containers already exist, don't recreate them. Incompatible with --force-recreate and --renew-anon-volumes.
     if ((value & DockerComposeUpFlags.NoRecreate) != 0)
     {
         yield return("--no-recreate");
     }
     // --no-build: Don't build an image, even if it's missing.
     if ((value & DockerComposeUpFlags.NoBuild) != 0)
     {
         yield return("--no-build");
     }
     // --no-start: Don't start the services after creating them.
     if ((value & DockerComposeUpFlags.NoStart) != 0)
     {
         yield return("--no-start");
     }
     // --build: Build images before starting containers.
     if ((value & DockerComposeUpFlags.Build) != 0)
     {
         yield return("--build");
     }
     // --abort-on-container-exit: Stops all containers if any container was stopped. Incompatible with --detach.
     if ((value & DockerComposeUpFlags.AbortOnContainerExit) != 0)
     {
         yield return("--abort-on-container-exit");
     }
     // --attach-dependencies: Attach to dependent containers.
     if ((value & DockerComposeUpFlags.AttachDependencies) != 0)
     {
         yield return("--attach-dependencies");
     }
     // -V, --renew-anon-volumes: Recreate anonymous volumes instead of retrieving data from the previous containers.
     if ((value & DockerComposeUpFlags.RenewAnonVolumes) != 0)
     {
         yield return(preferLongNames == OptionPreference.Long ? "--renew-anon-volumes" : "-V");
     }
     // --remove-orphans: Remove containers for services not defined in the Compose file.
     if ((value & DockerComposeUpFlags.RemoveOrphans) != 0)
     {
         yield return("--remove-orphans");
     }
 }