• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cinode / go / 15633973488

13 Jun 2025 11:57AM UTC coverage: 95.318%. Remained the same
15633973488

Pull #45

github

byo
fixup
Pull Request #45: Fix github action issues

3013 of 3161 relevant lines covered (95.32%)

1.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.82
/pkg/cinodefs/node_link.go
1
/*
2
Copyright © 2023 Bartłomiej Święcki (byo)
3

4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7

8
    http://www.apache.org/licenses/LICENSE-2.0
9

10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16

17
package cinodefs
18

19
import (
20
        "context"
21

22
        "github.com/cinode/go/pkg/utilities/golang"
23
)
24

25
// Entry is a link loaded into memory
26
type nodeLink struct {
27
        ep     *Entrypoint // entrypoint of the link itself
28
        target node        // target for the link
29
        dState dirtyState
30
}
31

32
func (c *nodeLink) dirty() dirtyState {
×
33
        return c.dState
×
34
}
×
35

36
func (c *nodeLink) flush(ctx context.Context, gc *graphContext) (node, *Entrypoint, error) {
1✔
37
        if c.dState == dsClean {
1✔
38
                // all clear
×
39
                return c, c.ep, nil
×
40
        }
×
41

42
        golang.Assert(c.dState == dsSubDirty, "link can be clean or sub-dirty")
1✔
43
        target, targetEP, err := c.target.flush(ctx, gc)
1✔
44
        if err != nil {
2✔
45
                return nil, nil, err
1✔
46
        }
1✔
47

48
        err = gc.updateProtobufMessage(ctx, c.ep, &targetEP.ep)
1✔
49
        if err != nil {
2✔
50
                return nil, nil, err
1✔
51
        }
1✔
52

53
        ret := &nodeLink{
1✔
54
                ep:     c.ep,
1✔
55
                target: target,
1✔
56
                dState: dsClean,
1✔
57
        }
1✔
58

1✔
59
        return ret, ret.ep, nil
1✔
60
}
61

62
func (c *nodeLink) traverse(
63
        ctx context.Context,
64
        gc *graphContext,
65
        path []string,
66
        pathPosition int,
67
        linkDepth int,
68
        isWritable bool,
69
        opts traverseOptions,
70
        whenReached traverseGoalFunc,
71
) (
72
        node,
73
        dirtyState,
74
        error,
75
) {
1✔
76
        if linkDepth >= opts.maxLinkRedirects {
2✔
77
                return nil, 0, ErrTooManyRedirects
1✔
78
        }
1✔
79

80
        // Note: we don't stop here even if we've reached the end of
81
        // traverse path, delegate traversal to target node instead
82

83
        // crossing link border, whether sub-graph is writeable is determined
84
        // by availability of corresponding writer info
85
        _, hasAuthInfo := gc.authInfos[c.ep.bn.String()]
1✔
86

1✔
87
        newTarget, targetState, err := c.target.traverse(
1✔
88
                ctx,
1✔
89
                gc,
1✔
90
                path,
1✔
91
                pathPosition,
1✔
92
                linkDepth+1,
1✔
93
                hasAuthInfo,
1✔
94
                opts,
1✔
95
                whenReached,
1✔
96
        )
1✔
97
        if err != nil {
2✔
98
                return nil, 0, err
1✔
99
        }
1✔
100

101
        if opts.doNotCache {
2✔
102
                return c, dsClean, nil
1✔
103
        }
1✔
104

105
        c.target = newTarget
1✔
106
        if targetState == dsClean {
1✔
107
                // Nothing to do
×
108
                //
×
109
                // Note: this path will happen once we keep clean nodes
×
110
                //       in the memory for caching purposes
×
111
                return c, dsClean, nil
×
112
        }
×
113

114
        golang.Assert(
1✔
115
                targetState == dsDirty || targetState == dsSubDirty,
1✔
116
                "ensure correct dirtiness state",
1✔
117
        )
1✔
118

1✔
119
        // sub-dirty propagates normally, dirty becomes sub-dirty
1✔
120
        // because link's entrypoint never changes
1✔
121
        c.dState = dsSubDirty
1✔
122
        return c, dsSubDirty, nil
1✔
123
}
124

125
func (c *nodeLink) entrypoint() (*Entrypoint, error) {
1✔
126
        return c.ep, nil
1✔
127
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc