(ctx devspacecontext.Context)
| 70 | } |
| 71 | |
| 72 | func (p *pipeline) Exclude(ctx devspacecontext.Context) error { |
| 73 | // get parent |
| 74 | if p.Parent() != nil { |
| 75 | parent := p.Parent() |
| 76 | for parent.Parent() != nil { |
| 77 | parent = parent.Parent() |
| 78 | } |
| 79 | |
| 80 | return parent.Exclude(ctx) |
| 81 | } |
| 82 | |
| 83 | // make sure we are locked |
| 84 | p.m.Lock() |
| 85 | defer p.m.Unlock() |
| 86 | |
| 87 | if p.excluded { |
| 88 | return p.excludedErr |
| 89 | } |
| 90 | |
| 91 | p.excluded = true |
| 92 | |
| 93 | // create namespace if necessary |
| 94 | if ctx.KubeClient() != nil { |
| 95 | p.excludedErr = kubectl.EnsureNamespace(ctx.Context(), ctx.KubeClient(), ctx.KubeClient().Namespace(), ctx.Log()) |
| 96 | if p.excludedErr != nil { |
| 97 | p.excludedErr = errors.Errorf("unable to create namespace: %v", p.excludedErr) |
| 98 | return p.excludedErr |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // exclude ourselves |
| 103 | var couldExclude map[string]registry.LockType |
| 104 | couldExclude, p.excludedErr = p.dependencyRegistry.TryLockDependencies(ctx, p.name, []string{p.name}, true) |
| 105 | if p.excludedErr != nil { |
| 106 | return p.excludedErr |
| 107 | } else if couldExclude[p.name] != registry.Locked && ctx.KubeClient() != nil { |
| 108 | return fmt.Errorf("couldn't execute '%s', because there is another DevSpace session for the project (%s) already running inside this namespace\n\n%s\n ", strings.Join(os.Args, " "), p.name, `You may want to use one of these commands instead: |
| 109 | - devspace enter: opens a terminal session for a container |
| 110 | - devspace attach: attaches to the PID 1 process (entrypoint) of a container |
| 111 | - devspace logs: streams the logs of a container |
| 112 | - devspace sync: syncs files between your local filesyste and a container's filesystem |
| 113 | - devspace ui: starts the DevSpace localhost UI`) |
| 114 | } |
| 115 | ctx.Log().Debugf("Marked project excluded: %v", p.name) |
| 116 | return nil |
| 117 | } |
| 118 | |
| 119 | func (p *pipeline) Parent() types.Pipeline { |
| 120 | return p.parent |
nothing calls this directly
no test coverage detected