Skip to content

Commit

Permalink
fix: GitHub App Token not saved for modules (#1432)
Browse files Browse the repository at this point in the history
When the module is saved, the ID of GitHubAppToken is not saved, this
change fixes it by using the right JPA annotation.
  • Loading branch information
stanleyz authored Oct 20, 2024
1 parent 0def631 commit 97426dc
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions api/src/main/java/org/terrakube/api/rs/module/Module.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.terrakube.api.rs.module;

import com.yahoo.elide.annotation.*;
import com.yahoo.elide.core.RequestScope;
import lombok.Getter;
import lombok.Setter;
import java.sql.Types;
import java.util.List;
import java.util.UUID;

import org.hibernate.annotations.JdbcTypeCode;
import org.terrakube.api.plugin.security.audit.GenericAuditFields;
import org.terrakube.api.rs.IdConverter;
Expand All @@ -13,10 +13,28 @@
import org.terrakube.api.rs.vcs.GitHubAppToken;
import org.terrakube.api.rs.vcs.Vcs;

import jakarta.persistence.*;
import com.yahoo.elide.annotation.ComputedAttribute;
import com.yahoo.elide.annotation.CreatePermission;
import com.yahoo.elide.annotation.DeletePermission;
import com.yahoo.elide.annotation.Exclude;
import com.yahoo.elide.annotation.Include;
import com.yahoo.elide.annotation.LifeCycleHookBinding;
import com.yahoo.elide.annotation.ReadPermission;
import com.yahoo.elide.annotation.UpdatePermission;
import com.yahoo.elide.core.RequestScope;

import java.sql.Types;
import java.util.*;
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Transient;
import lombok.Getter;
import lombok.Setter;

@ReadPermission(expression = "team view module")
@CreatePermission(expression = "team manage module")
Expand Down Expand Up @@ -81,7 +99,7 @@ public List<String> getVersions(RequestScope requestScope) {
private Ssh ssh;

// This can go if the the logic in the above GitTagsCache is moved to serivce layer
@OneToOne
@PrimaryKeyJoinColumn(name = "github_app_token_id")
@ManyToOne
@JoinColumn(name = "github_app_token_id")
private GitHubAppToken gitHubAppToken;
}

0 comments on commit 97426dc

Please sign in to comment.