MCPcopy Create free account
hub / github.com/anchordotdev/cli / systemConfig

Method systemConfig

lcl/lcl.go:90–158  ·  view source on GitHub ↗
(ctx context.Context, drv *ui.Driver)

Source from the content-addressed store, hash-verified

88}
89
90func (c *Command) systemConfig(ctx context.Context, drv *ui.Driver) error {
91 // audit diagnostic service
92
93 userInfo, err := c.anc.UserInfo(ctx)
94 if err != nil {
95 return err
96 }
97
98 orgSlug := userInfo.PersonalOrg.Slug
99 realmSlug := "localhost"
100
101 localCAs, err := trust.FetchLocalDevCAs(ctx, c.anc)
102 if err != nil {
103 return err
104 }
105
106 personalCAs, err := trust.FetchExpectedCAs(ctx, c.anc, orgSlug, realmSlug)
107 if err != nil {
108 return err
109 }
110
111 // audit CA certs
112
113 cmdAudit := &Audit{
114 anc: c.anc,
115 cas: localCAs,
116 }
117
118 auditInfo, err := cmdAudit.perform(ctx, drv)
119 if err != nil {
120 return err
121 }
122
123 isLocalhostCA := func(ca *truststore.CA) bool {
124 for _, ca2 := range personalCAs {
125 if ca.UniqueName == ca2.UniqueName {
126 return true
127 }
128 }
129 return false
130 }
131
132 switch {
133 case len(auditInfo.Missing) == 0:
134 drv.Activate(ctx, models.BootstrapSkip)
135
136 return nil
137 case slices.ContainsFunc(auditInfo.Missing, isLocalhostCA):
138 drv.Activate(ctx, models.BootstrapHeader)
139 drv.Activate(ctx, models.BootstrapHint)
140
141 cmdBootstrap := &Bootstrap{
142 anc: c.anc,
143 auditInfo: auditInfo,
144 }
145
146 return cmdBootstrap.perform(ctx, drv)
147 default:

Callers 1

runMethod · 0.95

Calls 7

performMethod · 0.95
performMethod · 0.95
performMethod · 0.95
FetchLocalDevCAsFunction · 0.92
FetchExpectedCAsFunction · 0.92
UserInfoMethod · 0.80
ActivateMethod · 0.80

Tested by

no test coverage detected