forked from gnuoy/snap-openstack
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from hemanthnakkina/merge-feat-manifest
Merge feat manifest to main
- Loading branch information
Showing
73 changed files
with
4,547 additions
and
1,634 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,14 +37,15 @@ resource "juju_application" "microceph" { | |
units = length(var.machine_ids) # need to manage the number of units | ||
|
||
charm { | ||
name = "microceph" | ||
channel = var.charm_microceph_channel | ||
name = "microceph" | ||
channel = var.charm_microceph_channel | ||
revision = var.charm_microceph_revision | ||
base = "[email protected]" | ||
} | ||
|
||
config = { | ||
config = merge({ | ||
snap-channel = var.microceph_channel | ||
} | ||
}, var.charm_microceph_config) | ||
} | ||
|
||
# juju_offer.microceph_offer will be created | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,16 +37,17 @@ resource "juju_application" "microk8s" { | |
units = length(var.machine_ids) # need to manage the number of units | ||
|
||
charm { | ||
name = "microk8s" | ||
channel = var.charm_microk8s_channel | ||
name = "microk8s" | ||
channel = var.charm_microk8s_channel | ||
revision = var.charm_microk8s_revision | ||
base = "[email protected]" | ||
} | ||
|
||
config = { | ||
config = merge({ | ||
channel = var.microk8s_channel | ||
addons = join(" ", [for key, value in var.addons : "${key}:${value}"]) | ||
disable_cert_reissue = true | ||
kubelet_serialize_image_pulls = false | ||
skip_verify = true | ||
} | ||
}, var.charm_microk8s_config) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,14 +38,15 @@ resource "juju_application" "openstack-hypervisor" { | |
units = length(var.machine_ids) # need to manage the number of units | ||
|
||
charm { | ||
name = "openstack-hypervisor" | ||
channel = var.charm_channel | ||
name = "openstack-hypervisor" | ||
channel = var.charm_channel | ||
revision = var.charm_revision | ||
base = "[email protected]" | ||
} | ||
|
||
config = { | ||
config = merge({ | ||
snap-channel = var.snap_channel | ||
} | ||
}, var.charm_config) | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,9 +33,12 @@ resource "juju_application" "sunbeam-machine" { | |
units = length(var.machine_ids) # need to manage the number of units | ||
|
||
charm { | ||
name = "sunbeam-machine" | ||
channel = var.charm_channel | ||
name = "sunbeam-machine" | ||
channel = var.charm_channel | ||
revision = var.charm_revision | ||
base = "[email protected]" | ||
} | ||
|
||
config = var.charm_config | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,6 @@ var Endpoints = []rest.Endpoint{ | |
jujuusersCmd, | ||
jujuuserCmd, | ||
configCmd, | ||
manifestsCmd, | ||
manifestCmd, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package api | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
"net/url" | ||
|
||
"github.com/canonical/lxd/lxd/response" | ||
"github.com/canonical/lxd/shared/api" | ||
"github.com/canonical/microcluster/rest" | ||
"github.com/canonical/microcluster/state" | ||
"github.com/gorilla/mux" | ||
|
||
"github.com/canonical/snap-openstack/sunbeam-microcluster/api/types" | ||
"github.com/canonical/snap-openstack/sunbeam-microcluster/sunbeam" | ||
) | ||
|
||
// /1.0/manifests endpoint. | ||
var manifestsCmd = rest.Endpoint{ | ||
Path: "manifests", | ||
|
||
Get: rest.EndpointAction{Handler: cmdManifestsGetAll, ProxyTarget: true}, | ||
Post: rest.EndpointAction{Handler: cmdManifestsPost, ProxyTarget: true}, | ||
} | ||
|
||
// /1.0/manifests/<manifestid> endpoint. | ||
// /1.0/manifests/latest will give the latest inserted manifest record | ||
var manifestCmd = rest.Endpoint{ | ||
Path: "manifests/{manifestid}", | ||
|
||
Get: rest.EndpointAction{Handler: cmdManifestGet, ProxyTarget: true}, | ||
Delete: rest.EndpointAction{Handler: cmdManifestDelete, ProxyTarget: true}, | ||
} | ||
|
||
func cmdManifestsGetAll(s *state.State, _ *http.Request) response.Response { | ||
|
||
manifests, err := sunbeam.ListManifests(s) | ||
if err != nil { | ||
return response.InternalError(err) | ||
} | ||
|
||
return response.SyncResponse(true, manifests) | ||
} | ||
|
||
func cmdManifestGet(s *state.State, r *http.Request) response.Response { | ||
var manifestid string | ||
manifestid, err := url.PathUnescape(mux.Vars(r)["manifestid"]) | ||
if err != nil { | ||
return response.InternalError(err) | ||
} | ||
manifest, err := sunbeam.GetManifest(s, manifestid) | ||
if err != nil { | ||
if err, ok := err.(api.StatusError); ok { | ||
if err.Status() == http.StatusNotFound { | ||
return response.NotFound(err) | ||
} | ||
} | ||
return response.InternalError(err) | ||
} | ||
|
||
return response.SyncResponse(true, manifest) | ||
} | ||
|
||
func cmdManifestsPost(s *state.State, r *http.Request) response.Response { | ||
var req types.Manifest | ||
|
||
err := json.NewDecoder(r.Body).Decode(&req) | ||
if err != nil { | ||
return response.InternalError(err) | ||
} | ||
|
||
err = sunbeam.AddManifest(s, req.ManifestID, req.Data) | ||
if err != nil { | ||
return response.InternalError(err) | ||
} | ||
|
||
return response.EmptySyncResponse | ||
} | ||
|
||
func cmdManifestDelete(s *state.State, r *http.Request) response.Response { | ||
manifestid, err := url.PathUnescape(mux.Vars(r)["manifestid"]) | ||
if err != nil { | ||
return response.SmartError(err) | ||
} | ||
err = sunbeam.DeleteManifest(s, manifestid) | ||
if err != nil { | ||
return response.InternalError(err) | ||
} | ||
|
||
return response.EmptySyncResponse | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Package types provides shared types and structs. | ||
package types | ||
|
||
// Manifests holds list of manifest type | ||
type Manifests []Manifest | ||
|
||
// Manifest structure to hold manifest applytime and manifest data | ||
type Manifest struct { | ||
ManifestID string `json:"manifestid" yaml:"manifestid"` | ||
AppliedDate string `json:"applieddate" yaml:"applieddate"` | ||
Data string `json:"data" yaml:"data"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.