Skip to content

Commit

Permalink
last commit should have said: minor changes. added getversion, added …
Browse files Browse the repository at this point in the history
…version field to struct .. bisect code still not implemented... need to make changes to how i store the data for bisect to work for slices and maps
  • Loading branch information
djarotech committed Aug 11, 2018
1 parent d7ff686 commit 45a3784
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
29 changes: 11 additions & 18 deletions pkg/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,32 +167,31 @@ func getWebService() *restful.WebService {
func getVersions(request *restful.Request, response *restful.Response) {
resourceName := request.PathParameter("resource-id")
requestPath := request.Request.URL.Path
//fmt.Printf("Printing Provenance\n")
//provenance.TotalClusterProvenance.PrintProvenance()

// Path looks as follows:
// /apis/kubeprovenance.cloudark.io/v1/namespaces/default/deployments/dep1/compositions
resourcePathSlice := strings.Split(requestPath, "/")
resourceKind := resourcePathSlice[6] // Kind is 7th element in the slice
//provenanceInfo := provenance.TotalClusterProvenance.GetProvenance(resourceKind, resourceName)
provenanceInfo := "Resource Name:" + resourceName + " Resource Kind:" + resourceKind
fmt.Println(provenanceInfo)

response.Write([]byte(provenanceInfo))
intendedProvObj := provenance.FindProvenanceObjectByName(resourceName, provenance.AllProvenanceObjects)

//TODO: Validate request based on the correct namespace and the correct plural type. right now
//deployments is sort of just ignored intentionally. I have the namespace/pluralkind data
//in my ProvenanceOfObject struct so it is easy to make these changes later
if intendedProvObj == nil {
s := fmt.Sprintf("Could not find any provenance history for resource name: %s", resourceName)
response.Write([]byte(s))
} else {
response.Write([]byte(intendedProvObj.ObjectFullHistory.GetVersions()))
}
}

func getHistory(request *restful.Request, response *restful.Response) {
fmt.Println("Inside getHistory")
resourceName := request.PathParameter("resource-id")
requestPath := request.Request.URL.Path
//fmt.Printf("Printing Provenance\n")
//provenance.TotalClusterProvenance.PrintProvenance()

// Path looks as follows:
// /apis/kubeprovenance.cloudark.io/v1/namespaces/default/deployments/dep1/compositions
resourcePathSlice := strings.Split(requestPath, "/")
resourceKind := resourcePathSlice[6] // Kind is 7th element in the slice
// provenanceInfo := provenance.TotalClusterProvenance.GetProvenance(resourceKind, resourceName)

provenanceInfo := "Resource Name:" + resourceName + " Resource Kind:" + resourceKind + "\n"
response.Write([]byte(provenanceInfo))
Expand All @@ -214,16 +213,10 @@ func bisect(request *restful.Request, response *restful.Response) {
fmt.Println("Inside bisect")
resourceName := request.PathParameter("resource-id")
requestPath := request.Request.URL.Path
//fmt.Printf("Printing Provenance\n")
//provenance.TotalClusterProvenance.PrintProvenance()

// Path looks as follows:
// /apis/kubeprovenance.cloudark.io/v1/namespaces/default/deployments/dep1/compositions
resourcePathSlice := strings.Split(requestPath, "/")
resourceKind := resourcePathSlice[6] // Kind is 7th element in the slice

var provenanceInfo string
//provenanceInfo = provenance.TotalClusterProvenance.GetProvenance(resourceKind, resourceName)
provenanceInfo = "Resource Name:" + resourceName + " Resource Kind:" + resourceKind
fmt.Println(provenanceInfo)

Expand Down
5 changes: 1 addition & 4 deletions pkg/provenance/provenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (o ObjectLineage) LatestVersion() int {
return len(o)
}

func (o ObjectLineage) GetVersion() string {
func (o ObjectLineage) GetVersions() string {
arr := make([]string, 0)
versions := o.LatestVersion()
for index := 1; index <= versions; index++ {
Expand All @@ -166,7 +166,6 @@ func (o ObjectLineage) SpecHistory() string {
return strings.Join(s, "\n")
}

//add type of ObjectFullProvenance, postgreses for example
func (o ObjectLineage) SpecHistoryInterval(vNumStart, vNumEnd int) []Spec {
s := make([]Spec, vNumEnd-vNumStart+1)
for v, spec := range o {
Expand All @@ -177,7 +176,6 @@ func (o ObjectLineage) SpecHistoryInterval(vNumStart, vNumEnd int) []Spec {
return s
}

//add type of ObjectFullProvenance, postgreses for example
func (o ObjectLineage) FullDiff(vNumStart, vNumEnd int) string {
var b strings.Builder
sp1 := o[vNumStart]
Expand Down Expand Up @@ -208,7 +206,6 @@ func (o ObjectLineage) FullDiff(vNumStart, vNumEnd int) string {
return b.String()
}

//add type of ObjectFullProvenance, postgreses for example
func (o ObjectLineage) FieldDiff(fieldName string, vNumStart, vNumEnd int) string {
var b strings.Builder
data1, ok1 := o[vNumStart].AttributeToData[fieldName]
Expand Down

0 comments on commit 45a3784

Please sign in to comment.