mirror of
				https://github.com/ClusterCockpit/cc-backend
				synced 2025-10-31 07:55:06 +01:00 
			
		
		
		
	Set all versions and print in version flag
This commit is contained in:
		
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ TARGET = ./cc-backend | ||||
| VAR = ./var | ||||
| DB = ./var/job.db | ||||
| FRONTEND = ./web/frontend | ||||
| VERSION = 0.1 | ||||
| VERSION = 1 | ||||
| GIT_HASH := $(shell git rev-parse --short HEAD || echo 'development') | ||||
| CURRENT_TIME = $(shell date +"%Y-%m-%d:T%H:%M:%S") | ||||
| LD_FLAGS = '-s -X main.buildTime=${CURRENT_TIME} -X main.version=${VERSION} -X main.hash=${GIT_HASH}' | ||||
|   | ||||
| @@ -84,6 +84,8 @@ func main() { | ||||
| 		fmt.Printf("Version:\t%s\n", version) | ||||
| 		fmt.Printf("Git hash:\t%s\n", hash) | ||||
| 		fmt.Printf("Build time:\t%s\n", buildTime) | ||||
| 		fmt.Printf("SQL db version:\t%d\n", repository.Version) | ||||
| 		fmt.Printf("Job archive version:\t%d\n", archive.Version) | ||||
| 		os.Exit(0) | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -30,7 +30,7 @@ import ( | ||||
| ) | ||||
|  | ||||
| // @title                      ClusterCockpit REST API | ||||
| // @version                    0.2.0 | ||||
| // @version                    1 | ||||
| // @description                API for batch job control. | ||||
|  | ||||
| // @tag.name Job API | ||||
|   | ||||
| @@ -17,7 +17,7 @@ import ( | ||||
| 	"github.com/golang-migrate/migrate/v4/source/iofs" | ||||
| ) | ||||
|  | ||||
| const supportedVersion uint = 3 | ||||
| const Version uint = 3 | ||||
|  | ||||
| //go:embed migrations/* | ||||
| var migrationFiles embed.FS | ||||
| @@ -65,13 +65,13 @@ func checkDBVersion(backend string, db *sql.DB) { | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if v < supportedVersion { | ||||
| 		log.Warnf("Unsupported database version %d, need %d.\nPlease backup your database file and run cc-backend --migrate-db", v, supportedVersion) | ||||
| 	if v < Version { | ||||
| 		log.Warnf("Unsupported database version %d, need %d.\nPlease backup your database file and run cc-backend --migrate-db", v, Version) | ||||
| 		os.Exit(0) | ||||
| 	} | ||||
|  | ||||
| 	if v > supportedVersion { | ||||
| 		log.Warnf("Unsupported database version %d, need %d.\nPlease refer to documentation how to downgrade db with external migrate tool!", v, supportedVersion) | ||||
| 	if v > Version { | ||||
| 		log.Warnf("Unsupported database version %d, need %d.\nPlease refer to documentation how to downgrade db with external migrate tool!", v, Version) | ||||
| 		os.Exit(0) | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -13,10 +13,10 @@ import ( | ||||
| 	"github.com/ClusterCockpit/cc-backend/pkg/schema" | ||||
| ) | ||||
|  | ||||
| const Version = 1 | ||||
| const Version uint64 = 1 | ||||
|  | ||||
| type ArchiveBackend interface { | ||||
| 	Init(rawConfig json.RawMessage) (int, error) | ||||
| 	Init(rawConfig json.RawMessage) (uint64, error) | ||||
|  | ||||
| 	LoadJobMeta(job *schema.Job) (*schema.JobMeta, error) | ||||
|  | ||||
|   | ||||
| @@ -101,7 +101,7 @@ func loadJobData(filename string, isCompressed bool) (schema.JobData, error) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (fsa *FsArchive) Init(rawConfig json.RawMessage) (int, error) { | ||||
| func (fsa *FsArchive) Init(rawConfig json.RawMessage) (uint64, error) { | ||||
|  | ||||
| 	var config FsArchiveConfig | ||||
| 	if err := json.Unmarshal(rawConfig, &config); err != nil { | ||||
| @@ -121,7 +121,7 @@ func (fsa *FsArchive) Init(rawConfig json.RawMessage) (int, error) { | ||||
| 		return 0, err | ||||
| 	} | ||||
|  | ||||
| 	version, err := strconv.Atoi(strings.TrimSuffix(string(b), "\n")) | ||||
| 	version, err := strconv.ParseUint(strings.TrimSuffix(string(b), "\n"), 10, 64) | ||||
| 	if err != nil { | ||||
| 		log.Errorf("fsBackend Init()- %v", err) | ||||
| 		return 0, err | ||||
|   | ||||
		Reference in New Issue
	
	Block a user