Skip to content

Commit 4aa5d3a

Browse files
committed
Update error writer
1 parent ebcb245 commit 4aa5d3a

20 files changed

Lines changed: 78 additions & 55 deletions

File tree

plugins/auth0/pkg/app/fetch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ func (f *FetchCmd) Run(ctx *cc.CommonCtx) error {
4646
WithSAML(f.SAML).
4747
WithConnectionName(f.ConnectionName)
4848

49-
return fetcher.Fetch(ctx.Context, os.Stdout, common.ErrorWriter{Writer: os.Stderr})
49+
return fetcher.Fetch(ctx.Context, os.Stdout, common.NewErrorWriter(os.Stderr))
5050
}

plugins/azuread/pkg/app/fetch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ func (cmd *FetchCmd) Run(ctx *cc.CommonCtx) error {
3030
return err
3131
}
3232

33-
return fetcher.WithGroups(cmd.Groups).Fetch(ctx.Context, os.Stdout, common.ErrorWriter{Writer: os.Stderr})
33+
return fetcher.WithGroups(cmd.Groups).Fetch(ctx.Context, os.Stdout, common.NewErrorWriter(os.Stderr))
3434
}

plugins/azuread/pkg/fetch/fetch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ func (f *Fetcher) Fetch(ctx context.Context, outputWriter io.Writer, errorWriter
4242
errorWriter.Error(err)
4343

4444
err := jsonWriter.Write(obj)
45-
errorWriter.ErrorNoExitCode(err)
45+
errorWriter.Error(err, common.NoExitCode)
4646
}
4747
}
4848

4949
for user, err := range f.fetchUsers(ctx) {
5050
errorWriter.Error(err)
5151

5252
err := jsonWriter.Write(user)
53-
errorWriter.ErrorNoExitCode(err)
53+
errorWriter.Error(err, common.NoExitCode)
5454
}
5555

5656
return nil

plugins/azureadb2c/pkg/app/fetch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ func (cmd *FetchCmd) Run(ctx *cc.CommonCtx) error {
3030
return err
3131
}
3232

33-
return fetcher.WithGroups(cmd.Groups).Fetch(ctx.Context, os.Stdout, common.ErrorWriter{Writer: os.Stderr})
33+
return fetcher.WithGroups(cmd.Groups).Fetch(ctx.Context, os.Stdout, common.NewErrorWriter(os.Stderr))
3434
}

plugins/azureadb2c/pkg/fetch/fetch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ func (f *Fetcher) Fetch(ctx context.Context, outputWriter io.Writer, errorWriter
4242
errorWriter.Error(err)
4343

4444
err := jsonWriter.Write(obj)
45-
errorWriter.ErrorNoExitCode(err)
45+
errorWriter.Error(err, common.NoExitCode)
4646
}
4747
}
4848

4949
for user, err := range f.fetchUsers(ctx) {
5050
errorWriter.Error(err)
5151

5252
err := jsonWriter.Write(user)
53-
errorWriter.ErrorNoExitCode(err)
53+
errorWriter.Error(err, common.NoExitCode)
5454
}
5555

5656
return nil

plugins/cognito/pkg/app/fetch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ func (cmd *FetchCmd) Run(ctx *cc.CommonCtx) error {
3030

3131
fetcher = fetcher.WithGroups(cmd.Groups)
3232

33-
return fetcher.Fetch(ctx.Context, os.Stdout, common.ErrorWriter{Writer: os.Stderr})
33+
return fetcher.Fetch(ctx.Context, os.Stdout, common.NewErrorWriter(os.Stderr))
3434
}

plugins/cognito/pkg/fetch/fetch.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ func (f *Fetcher) Fetch(ctx context.Context, outputWriter io.Writer, errorWriter
3838
errorWriter.Error(err)
3939

4040
err := writer.Write(obj)
41-
errorWriter.ErrorNoExitCode(err)
41+
errorWriter.Error(err, common.NoExitCode)
4242
}
4343
}
4444

4545
users, err := f.cognitoClient.ListUsers(ctx)
46-
errorWriter.ErrorNoExitCode(err)
46+
errorWriter.Error(err, common.NoExitCode)
4747

4848
for _, user := range users {
4949
attributes := make(map[string]string)
@@ -59,32 +59,32 @@ func (f *Fetcher) Fetch(ctx context.Context, outputWriter io.Writer, errorWriter
5959

6060
var obj map[string]any
6161
err = json.Unmarshal(userBytes, &obj)
62-
errorWriter.ErrorNoExitCode(err)
62+
errorWriter.Error(err, common.NoExitCode)
6363

6464
obj["Attributes"] = attributes
6565

6666
if f.groups {
6767
groups, err := f.cognitoClient.GetGroupsForUser(*user.Username)
6868
if err != nil {
69-
errorWriter.ErrorNoExitCode(err)
69+
errorWriter.Error(err, common.NoExitCode)
7070
continue
7171
}
7272

7373
groupBytes, err := json.Marshal(groups.Groups)
7474
if err != nil {
75-
errorWriter.ErrorNoExitCode(err)
75+
errorWriter.Error(err, common.NoExitCode)
7676
return err
7777
}
7878

7979
var grps []map[string]string
8080
err = json.Unmarshal(groupBytes, &grps)
81-
errorWriter.ErrorNoExitCode(err)
81+
errorWriter.Error(err, common.NoExitCode)
8282

8383
obj["Groups"] = grps
8484
}
8585

8686
err = writer.Write(obj)
87-
errorWriter.ErrorNoExitCode(err)
87+
errorWriter.Error(err, common.NoExitCode)
8888
}
8989

9090
return nil

plugins/fusionauth/pkg/app/fetch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ func (cmd *FetchCmd) Run(ctx *cc.CommonCtx) error {
2828

2929
fetcher = fetcher.WithGroups(cmd.Groups).WithHost(cmd.HostURL)
3030

31-
return fetcher.Fetch(ctx.Context, os.Stdout, common.ErrorWriter{Writer: os.Stderr})
31+
return fetcher.Fetch(ctx.Context, os.Stdout, common.NewErrorWriter(os.Stderr))
3232
}

plugins/fusionauth/pkg/fetch/fetch.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ func (f *Fetcher) Fetch(ctx context.Context, outputWriter io.Writer, errorWriter
3838
defer writer.Close()
3939

4040
users, err := f.fusionauthClient.ListUsers(ctx)
41-
errorWriter.ErrorNoExitCode(err)
41+
errorWriter.Error(err, common.NoExitCode)
4242

4343
for i := range users {
4444
user := &users[i]
4545

4646
userBytes, err := json.Marshal(user)
4747
if err != nil {
48-
errorWriter.ErrorNoExitCode(err)
48+
errorWriter.Error(err, common.NoExitCode)
4949
return err
5050
}
5151

5252
var obj map[string]any
5353
if err := json.Unmarshal(userBytes, &obj); err != nil {
54-
errorWriter.ErrorNoExitCode(err)
54+
errorWriter.Error(err, common.NoExitCode)
5555
return err
5656
}
5757

@@ -60,17 +60,17 @@ func (f *Fetcher) Fetch(ctx context.Context, outputWriter io.Writer, errorWriter
6060
}
6161

6262
err = writer.Write(obj)
63-
errorWriter.ErrorNoExitCode(err)
63+
errorWriter.Error(err, common.NoExitCode)
6464
}
6565

6666
if f.groups {
6767
groups, err := f.fusionauthClient.ListGroups(ctx)
68-
errorWriter.ErrorNoExitCode(err)
68+
errorWriter.Error(err, common.NoExitCode)
6969

7070
for i := range groups {
7171
group := &groups[i]
7272
err := writer.Write(group)
73-
errorWriter.ErrorNoExitCode(err)
73+
errorWriter.Error(err, common.NoExitCode)
7474
}
7575
}
7676

plugins/google/pkg/app/fetch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ func (cmd *FetchCmd) Run(ctx *cc.CommonCtx) error {
3030

3131
fetcher = fetcher.WithGroups(cmd.Groups)
3232

33-
return fetcher.Fetch(ctx.Context, os.Stdout, common.ErrorWriter{Writer: os.Stderr})
33+
return fetcher.Fetch(ctx.Context, os.Stdout, common.NewErrorWriter(os.Stderr))
3434
}

0 commit comments

Comments
 (0)