diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 73172587..3414f344 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,23 +1,12 @@ name: Test Baton Gitlab Integration -on: pull_request +on: + pull_request: + push: + branches: + - main jobs: - go-lint: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version-file: "go.mod" - - name: Run linters - uses: golangci/golangci-lint-action@v8 - with: - version: latest - args: --timeout=3m - go-test: strategy: matrix: @@ -190,6 +179,7 @@ jobs: # jq --exit-status ".grants[].principal.id.resource == \"${{ env.USER_ID }}\"" test-cloud-version: + if: github.event_name == 'pull_request' runs-on: ubuntu-latest env: BATON_LOG_LEVEL: debug diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml deleted file mode 100644 index dba9bd2d..00000000 --- a/.github/workflows/main.yaml +++ /dev/null @@ -1,41 +0,0 @@ -name: main ci -on: - push: - branches: - - main -jobs: - go-lint: - runs-on: ubuntu-latest - steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: 1.23.x - - name: Checkout code - uses: actions/checkout@v3 - - name: Run linters - uses: golangci/golangci-lint-action@v8 - with: - version: latest - args: --timeout=3m - go-test: - strategy: - matrix: - go-version: [ 1.23.x ] - platform: [ ubuntu-latest ] - runs-on: ${{ matrix.platform }} - steps: - - name: Install Go - if: success() - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v4 - - name: go tests - run: (set -o pipefail && go test -v -covermode=count -json ./... | tee test.json) - - name: annotate go tests - if: always() - uses: guyarb/golang-test-annotations@v0.5.1 - with: - test-results: test.json \ No newline at end of file diff --git a/pkg/connector/groups.go b/pkg/connector/groups.go index a75e5c32..94337da8 100644 --- a/pkg/connector/groups.go +++ b/pkg/connector/groups.go @@ -427,9 +427,8 @@ func groupResource(group *client.Group, parentResourceID *v2.ResourceId, isOnPre group.FullName, groupResourceType, toGroupResourceId(strconv.Itoa(group.ID)), - []resourceSdk.GroupTraitOption{ - resourceSdk.WithGroupProfile(profile), - }, + []resourceSdk.GroupTraitOption{}, + resourceSdk.WithResourceProfile(profile), resourceSdk.WithAnnotation(annos...), resourceSdk.WithParentResourceID(parentResourceID), ) diff --git a/pkg/connector/projects.go b/pkg/connector/projects.go index f3c9f4be..da18abb4 100644 --- a/pkg/connector/projects.go +++ b/pkg/connector/projects.go @@ -342,15 +342,14 @@ func projectResource(project *client.Project, parentResourceID *v2.ResourceId, i project.NameWithNamespace, projectResourceType, project.ID, - []resourceSdk.GroupTraitOption{ - resourceSdk.WithGroupProfile( - map[string]interface{}{ - "id": project.ID, - profileFieldName: project.Name, - "description": project.Description, - }, - ), - }, + []resourceSdk.GroupTraitOption{}, + resourceSdk.WithResourceProfile( + map[string]interface{}{ + "id": project.ID, + profileFieldName: project.Name, + "description": project.Description, + }, + ), resourceSdk.WithAnnotation(annotations...), resourceSdk.WithParentResourceID(parentResourceID), ) diff --git a/pkg/connector/users.go b/pkg/connector/users.go index 3a60b1ed..08ae3716 100644 --- a/pkg/connector/users.go +++ b/pkg/connector/users.go @@ -276,8 +276,8 @@ func (u *userBuilder) createCloudUser( []resourceSdk.UserTraitOption{ resourceSdk.WithEmail(email, true), resourceSdk.WithUserLogin(email), - resourceSdk.WithStatus(v2.UserTrait_Status_STATUS_DISABLED), }, + resourceSdk.WithResourceStatus(v2.Status_RESOURCE_STATUS_DISABLED, ""), ) if err != nil { return nil, nil, nil, fmt.Errorf("failed to build pending user resource: %w", err) @@ -447,20 +447,20 @@ func userResource(user any) (*v2.Resource, error) { []resourceSdk.UserTraitOption{ resourceSdk.WithEmail(email, true), resourceSdk.WithUserLogin(email), - resourceSdk.WithUserProfile(profile), - resourceSdk.WithStatus(v2.UserTrait_Status_STATUS_DISABLED), }, + resourceSdk.WithResourceProfile(profile), + resourceSdk.WithResourceStatus(v2.Status_RESOURCE_STATUS_DISABLED, ""), ) default: return nil, fmt.Errorf("unknown user type: %T", user) } - userStatus := v2.UserTrait_Status_STATUS_ENABLED + userStatus := v2.Status_RESOURCE_STATUS_ENABLED switch state { case "blocked", "deactivated", "ldap_blocked", "banned": - userStatus = v2.UserTrait_Status_STATUS_DISABLED + userStatus = v2.Status_RESOURCE_STATUS_DISABLED case "pending": - userStatus = v2.UserTrait_Status_STATUS_UNSPECIFIED + userStatus = v2.Status_RESOURCE_STATUS_UNSPECIFIED name = pendingInvitationUser + strings.ToLower(email) } @@ -479,8 +479,6 @@ func userResource(user any) (*v2.Resource, error) { userTraitOptions := []resourceSdk.UserTraitOption{ resourceSdk.WithEmail(email, true), - resourceSdk.WithStatus(userStatus), - resourceSdk.WithUserProfile(profile), resourceSdk.WithUserLogin(email), } @@ -493,6 +491,8 @@ func userResource(user any) (*v2.Resource, error) { userResourceType, id, userTraitOptions, + resourceSdk.WithResourceProfile(profile), + resourceSdk.WithResourceStatus(userStatus, ""), ) }