Skip to content

Commit a47ebc9

Browse files
committed
fix: lint errors
Signed-off-by: NucleoFusion <lakshit.singh.mail@gmail.com>
1 parent 40dd390 commit a47ebc9

File tree

10 files changed

+158
-31
lines changed

10 files changed

+158
-31
lines changed

cmd/harbor/root/usergroup/cmd.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package usergroup
215

316
import (

cmd/harbor/root/usergroup/create.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package usergroup
215

316
import (

cmd/harbor/root/usergroup/delete.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package usergroup
215

316
import (

cmd/harbor/root/usergroup/list.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package usergroup
215

316
import (

cmd/harbor/root/usergroup/update.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package usergroup
215

316
import (
@@ -33,4 +46,4 @@ func UserGroupUpdateCommand() *cobra.Command {
3346
}
3447

3548
return cmd
36-
}
49+
}

pkg/api/usergroup_handler.go

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,48 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package api
216

317
import (
18+
"encoding/json"
19+
"fmt"
20+
421
"github.com/goharbor/go-client/pkg/sdk/v2.0/client/usergroup"
522
"github.com/goharbor/go-client/pkg/sdk/v2.0/models"
623
"github.com/goharbor/harbor-cli/pkg/utils"
7-
"fmt"
824
log "github.com/sirupsen/logrus"
9-
"encoding/json"
1025
)
1126

12-
1327
func CreateUserGroup(groupName string, groupType int64, ldapGroupDn string) error {
14-
ctx, client, err := utils.ContextWithClient()
15-
if err != nil {
16-
return fmt.Errorf("failed to create client: %v", err)
17-
}
18-
19-
userGroup := &models.UserGroup{
20-
GroupName: groupName,
21-
GroupType: groupType,
22-
}
23-
24-
if groupType == 1 {
25-
userGroup.LdapGroupDn = ldapGroupDn
26-
}
27-
28-
_, err = client.Usergroup.CreateUserGroup(ctx, &usergroup.CreateUserGroupParams{
29-
Usergroup: userGroup,
30-
})
31-
32-
if err != nil {
28+
ctx, client, err := utils.ContextWithClient()
29+
if err != nil {
30+
return fmt.Errorf("failed to create client: %v", err)
31+
}
32+
33+
userGroup := &models.UserGroup{
34+
GroupName: groupName,
35+
GroupType: groupType,
36+
}
37+
38+
if groupType == 1 {
39+
userGroup.LdapGroupDn = ldapGroupDn
40+
}
41+
42+
_, err = client.Usergroup.CreateUserGroup(ctx, &usergroup.CreateUserGroupParams{
43+
Usergroup: userGroup,
44+
})
45+
if err != nil {
3346
switch e := err.(type) {
3447
case *usergroup.CreateUserGroupBadRequest:
3548
payload, _ := json.MarshalIndent(e.Payload, "", " ")
@@ -40,10 +53,9 @@ func CreateUserGroup(groupName string, groupType int64, ldapGroupDn string) erro
4053
default:
4154
return fmt.Errorf("failed to create user group: %v", err)
4255
}
43-
}
44-
45-
return nil
56+
}
4657

58+
return nil
4759
}
4860

4961
func DeleteUserGroup(groupId int64) error {
@@ -115,9 +127,8 @@ func UpdateUserGroup(groupId int64, groupName string, groupType int64) error {
115127
GroupType: groupType,
116128
},
117129
})
118-
119130
if err != nil {
120131
return err
121132
}
122133
return nil
123-
}
134+
}

pkg/views/usergroup/create/view.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package create
215

316
import (

pkg/views/usergroup/delete/delete.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package delete
215

316
import (

pkg/views/usergroup/list/view.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package list
215

316
import (

pkg/views/usergroup/update/view.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package update
215

316
import (
417
"fmt"
518
"strconv"
619

720
sdkUserGroup "github.com/goharbor/go-client/pkg/sdk/v2.0/client/usergroup"
8-
21+
922
"github.com/charmbracelet/huh"
10-
1123
)
1224

1325
type UpdateUserGroupInput struct {
@@ -61,4 +73,4 @@ func UpdateUserGroupView(userGroups *sdkUserGroup.ListUserGroupsOK) (*UpdateUser
6173
GroupName: groupName,
6274
GroupType: groupType,
6375
}, nil
64-
}
76+
}

0 commit comments

Comments
 (0)