Skip to content

Commit ea1a067

Browse files
committed
Update error writer
1 parent ebcb245 commit ea1a067

20 files changed

Lines changed: 85 additions & 64 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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ func (f *Fetcher) Fetch(ctx context.Context, outputWriter io.Writer, errorWriter
3939

4040
if f.Groups {
4141
for obj, err := range f.fetchGroups(ctx) {
42-
errorWriter.Error(err)
42+
errorWriter.Error(err, common.WithExitCode)
4343

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

4949
for user, err := range f.fetchUsers(ctx) {
50-
errorWriter.Error(err)
50+
errorWriter.Error(err, common.WithExitCode)
5151

5252
err := jsonWriter.Write(user)
53-
errorWriter.ErrorNoExitCode(err)
53+
errorWriter.Error(err)
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ func (f *Fetcher) Fetch(ctx context.Context, outputWriter io.Writer, errorWriter
3939

4040
if f.Groups {
4141
for obj, err := range f.fetchGroups(ctx) {
42-
errorWriter.Error(err)
42+
errorWriter.Error(err, common.WithExitCode)
4343

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

4949
for user, err := range f.fetchUsers(ctx) {
50-
errorWriter.Error(err)
50+
errorWriter.Error(err, common.WithExitCode)
5151

5252
err := jsonWriter.Write(user)
53-
errorWriter.ErrorNoExitCode(err)
53+
errorWriter.Error(err)
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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ func (f *Fetcher) Fetch(ctx context.Context, outputWriter io.Writer, errorWriter
3535

3636
if f.groups {
3737
for obj, err := range f.fetchGroups() {
38-
errorWriter.Error(err)
38+
errorWriter.Error(err, common.WithExitCode)
3939

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

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

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

5454
userBytes, err := json.Marshal(user)
5555
if err != nil {
56-
errorWriter.Error(err)
56+
errorWriter.Error(err, common.WithExitCode)
5757
return err
5858
}
5959

6060
var obj map[string]any
6161
err = json.Unmarshal(userBytes, &obj)
62-
errorWriter.ErrorNoExitCode(err)
62+
errorWriter.Error(err)
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)
7070
continue
7171
}
7272

7373
groupBytes, err := json.Marshal(groups.Groups)
7474
if err != nil {
75-
errorWriter.ErrorNoExitCode(err)
75+
errorWriter.Error(err)
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)
8282

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

8686
err = writer.Write(obj)
87-
errorWriter.ErrorNoExitCode(err)
87+
errorWriter.Error(err)
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)
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)
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)
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)
6464
}
6565

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

7070
for i := range groups {
7171
group := &groups[i]
7272
err := writer.Write(group)
73-
errorWriter.ErrorNoExitCode(err)
73+
errorWriter.Error(err)
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)