-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Would like a nicer way to detect config as code projects #133
Comments
Throwing ideas out: 1 We could define a type-aliased string, like we did with AccountType For this example it would be something like type ProjectPersistenceType string
const ProjectPersistenceTypeVersionControlled = ProjectPersistenceType("VersionControlled")
const ProjectPersistenceTypeDatabase = ProjectPersistenceType("Database") A possible issue with this approach is that it appears as though the persistence type can be sent in JSON from the server If indeed it is, then this opens up the possibility of there being additional persistence types other than VersionControlled/Database in the future, and we might want to consider what to do there. |
Throwing ideas out: 2 The different persistence settings are actually represented by different structs in Go We could therefore use the go casting operator to detect a project persistence type, e.g. dbSettings, ok := project.PersistenceSettings.(DatabasePersistenceSettings)
if ok {
// we know it's a database project
} This is a bit awkward though and makes the code longer, it's not a clear win |
The current approach expects the caller to do this:
project.PersistenceSettings.GetType() != "VersionControlled"
Reference:
go-octopusdeploy/pkg/projects/project_service.go
Line 252 in 6bd1cc8
It would be nice if there was a cleaner way to detect a version-controlled project other than comparing with this magic string
The text was updated successfully, but these errors were encountered: